+25
-5
lines changedFilter options
+25
-5
lines changed Original file line number Diff line number Diff line change
@@ -112,11 +112,31 @@ int CEPoll::create(CEPollDesc** pout)
112
112
int localid = 0;
113
113
114
114
#ifdef LINUX
115
-
int flags = 0;
116
-
#if ENABLE_SOCK_CLOEXEC
117
-
flags |= EPOLL_CLOEXEC;
118
-
#endif
119
-
localid = epoll_create1(flags);
115
+
116
+
// NOTE: epoll_create1() and EPOLL_CLOEXEC were introduced in GLIBC-2.9.
117
+
// So earlier versions of GLIBC, must use epoll_create() and set
118
+
// FD_CLOEXEC on the file descriptor returned by it after the fact.
119
+
#if defined(EPOLL_CLOEXEC)
120
+
int flags = 0;
121
+
#if ENABLE_SOCK_CLOEXEC
122
+
flags |= EPOLL_CLOEXEC;
123
+
#endif
124
+
localid = epoll_create1(flags);
125
+
#else
126
+
localid = epoll_create(1);
127
+
#if ENABLE_SOCK_CLOEXEC
128
+
if (localid != -1)
129
+
{
130
+
int fdFlags = fcntl(localid, F_GETFD);
131
+
if (fdFlags != -1)
132
+
{
133
+
fdFlags |= FD_CLOEXEC;
134
+
fcntl(localid, F_SETFD, fdFlags);
135
+
}
136
+
}
137
+
#endif
138
+
#endif
139
+
120
140
/* Possible reasons of -1 error:
121
141
EMFILE: The per-user limit on the number of epoll instances imposed by /proc/sys/fs/epoll/max_user_instances was encountered.
122
142
ENFILE: The system limit on the total number of open files has been reached.
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4