Skip to content

Commit 849994d

Browse files
committed
SOCK_CLOEXEC was introduced in 2008
(and SOCK_NONBLOCK along with it) Retaining the (racy!) fallback code is just silly.
1 parent 2e6a1c4 commit 849994d

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed

src/abstract_socket.cc

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,6 @@ using v8::String;
2020
using v8::Value;
2121

2222

23-
#if !defined(SOCK_NONBLOCK)
24-
void SetNonBlock(int fd) {
25-
int flags;
26-
int r;
27-
28-
flags = fcntl(fd, F_GETFL);
29-
assert(flags != -1);
30-
31-
r = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
32-
assert(r != -1);
33-
}
34-
#endif
35-
36-
37-
#if !defined(SOCK_CLOEXEC)
38-
void SetCloExec(int fd) {
39-
int flags;
40-
int r;
41-
42-
flags = fcntl(fd, F_GETFD);
43-
assert(flags != -1);
44-
45-
r = fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
46-
assert(r != -1);
47-
}
48-
#endif
49-
50-
5123
NAN_METHOD(Socket) {
5224
Nan::HandleScope scope;
5325
int fd;
@@ -56,26 +28,14 @@ NAN_METHOD(Socket) {
5628
assert(info.Length() == 0);
5729

5830
type = SOCK_STREAM;
59-
#if defined(SOCK_NONBLOCK)
60-
type |= SOCK_NONBLOCK;
61-
#endif
62-
#if defined(SOCK_CLOEXEC)
63-
type |= SOCK_CLOEXEC;
64-
#endif
31+
type |= SOCK_NONBLOCK | SOCK_CLOEXEC;
6532

6633
fd = socket(AF_UNIX, type, 0);
6734
if (fd == -1) {
6835
fd = -errno;
6936
goto out;
7037
}
7138

72-
#if !defined(SOCK_NONBLOCK)
73-
SetNonBlock(fd);
74-
#endif
75-
#if !defined(SOCK_CLOEXEC)
76-
SetCloExec(fd);
77-
#endif
78-
7939
out:
8040
info.GetReturnValue().Set(fd);
8141
}

0 commit comments

Comments
 (0)