Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
699f41e1
Commit
699f41e1
authored
Aug 11, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/EventPipe: use AtScopeExit() in PoorSocketPair()
parent
424e1363
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
14 deletions
+8
-14
EventPipe.cxx
src/system/EventPipe.cxx
+8
-14
No files found.
src/system/EventPipe.cxx
View file @
699f41e1
...
...
@@ -21,6 +21,7 @@
#include "EventPipe.hxx"
#include "system/fd_util.h"
#include "system/FatalError.hxx"
#include "util/ScopeExit.hxx"
#include "Compiler.h"
#include <assert.h>
...
...
@@ -107,6 +108,10 @@ static bool PoorSocketPair(int fd[2])
if
(
listen_socket
==
INVALID_SOCKET
)
return
false
;
AtScopeExit
(
listen_socket
)
{
closesocket
(
listen_socket
);
};
sockaddr_in
address
;
std
::
memset
(
&
address
,
0
,
sizeof
(
address
));
address
.
sin_family
=
AF_INET
;
...
...
@@ -116,31 +121,24 @@ static bool PoorSocketPair(int fd[2])
reinterpret_cast
<
sockaddr
*>
(
&
address
),
sizeof
(
address
));
if
(
ret
<
0
)
{
SafeCloseSocket
(
listen_socket
);
if
(
ret
<
0
)
return
false
;
}
ret
=
listen
(
listen_socket
,
1
);
if
(
ret
<
0
)
{
SafeCloseSocket
(
listen_socket
);
if
(
ret
<
0
)
return
false
;
}
int
address_len
=
sizeof
(
address
);
ret
=
getsockname
(
listen_socket
,
reinterpret_cast
<
sockaddr
*>
(
&
address
),
&
address_len
);
if
(
ret
<
0
)
{
SafeCloseSocket
(
listen_socket
);
if
(
ret
<
0
)
return
false
;
}
SOCKET
socket0
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
socket0
==
INVALID_SOCKET
)
{
SafeCloseSocket
(
listen_socket
);
return
false
;
}
...
...
@@ -149,20 +147,16 @@ static bool PoorSocketPair(int fd[2])
sizeof
(
address
));
if
(
ret
<
0
)
{
SafeCloseSocket
(
listen_socket
);
SafeCloseSocket
(
socket0
);
return
false
;
}
SOCKET
socket1
=
accept
(
listen_socket
,
nullptr
,
nullptr
);
if
(
socket1
==
INVALID_SOCKET
)
{
SafeCloseSocket
(
listen_socket
);
SafeCloseSocket
(
socket0
);
return
false
;
}
SafeCloseSocket
(
listen_socket
);
u_long
non_block
=
1
;
if
(
ioctlsocket
(
socket0
,
FIONBIO
,
&
non_block
)
<
0
||
ioctlsocket
(
socket1
,
FIONBIO
,
&
non_block
)
<
0
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment