View | Details | Raw Unified | Return to bug 46425
Collapse All | Expand All

(-)a/configure.in (+3 lines)
Lines 782-787 if test "$apr_cv_epoll" = "yes"; then Link Here
782
   AC_DEFINE([HAVE_EPOLL], 1, [Define if the epoll interface is supported])
782
   AC_DEFINE([HAVE_EPOLL], 1, [Define if the epoll interface is supported])
783
fi
783
fi
784
784
785
dnl ----------------------------- Checking for extended file descriptor handling
786
AC_CHECK_FUNCS(dup3 accept4 epoll_create1)
787
785
dnl ----------------------------- Checking for missing POSIX thread functions
788
dnl ----------------------------- Checking for missing POSIX thread functions
786
AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r])
789
AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r])
787
790
(-)a/file_io/netware/mktemp.c (+3 lines)
Lines 43-48 APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_i Link Here
43
43
44
44
45
	if (!(flags & APR_FILE_NOCLEANUP)) {
45
	if (!(flags & APR_FILE_NOCLEANUP)) {
46
            int fdflags = fcntl(fd, F_GETFD);
47
            fdflags |= FD_CLOEXEC;
48
            fcntl(fd, F_SETFD, fdflags);
46
	    apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
49
	    apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
47
				      apr_unix_file_cleanup,
50
				      apr_unix_file_cleanup,
48
				      apr_unix_child_file_cleanup);
51
				      apr_unix_child_file_cleanup);
(-)a/file_io/unix/filedup.c (-1 / +15 lines)
Lines 24-37 static apr_status_t file_dup(apr_file_t **new_file, Link Here
24
                             apr_file_t *old_file, apr_pool_t *p,
24
                             apr_file_t *old_file, apr_pool_t *p,
25
                             int which_dup)
25
                             int which_dup)
26
{
26
{
27
    int rv;
27
    int rv, flags = 0;
28
    
28
    
29
    if (which_dup == 2) {
29
    if (which_dup == 2) {
30
        if ((*new_file) == NULL) {
30
        if ((*new_file) == NULL) {
31
            /* We can't dup2 unless we have a valid new_file */
31
            /* We can't dup2 unless we have a valid new_file */
32
            return APR_EINVAL;
32
            return APR_EINVAL;
33
        }
33
        }
34
#ifdef HAVE_DUP3
35
        if (!(old_file->flags & APR_INHERIT))
36
            flags |= O_CLOEXEC;
37
        rv = dup3(old_file->filedes, (*new_file)->filedes, flags);
38
#else
34
        rv = dup2(old_file->filedes, (*new_file)->filedes);
39
        rv = dup2(old_file->filedes, (*new_file)->filedes);
40
        if (!(old_file->flags & APR_INHERIT)) {
41
            flags = fcntl((*new_file)->filedes, F_GETFD);
42
            if (flags == -1)
43
                return errno;
44
            flags |= FD_CLOEXEC;
45
            if (fcntl((*new_file)->filedes, F_SETFD, flags) == -1)
46
                return errno;
47
        }
48
#endif
35
    } else {
49
    } else {
36
        rv = dup(old_file->filedes);
50
        rv = dup(old_file->filedes);
37
    }
51
    }
(-)a/file_io/unix/mktemp.c (+3 lines)
Lines 203-208 APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_i Link Here
203
    (*fp)->fname = apr_pstrdup(p, template);
203
    (*fp)->fname = apr_pstrdup(p, template);
204
204
205
    if (!(flags & APR_FILE_NOCLEANUP)) {
205
    if (!(flags & APR_FILE_NOCLEANUP)) {
206
        int fdflags = fcntl(fd, F_GETFD);
207
        fdflags |= FD_CLOEXEC;
208
        fcntl(fd, F_SETFD, fdflags);
206
        apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
209
        apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
207
                                  apr_unix_file_cleanup,
210
                                  apr_unix_file_cleanup,
208
                                  apr_unix_child_file_cleanup);
211
                                  apr_unix_child_file_cleanup);
(-)a/file_io/unix/open.c (-1 / +20 lines)
Lines 127-133 APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, Link Here
127
        oflags |= O_BINARY;
127
        oflags |= O_BINARY;
128
    }
128
    }
129
#endif
129
#endif
130
    
130
131
#ifdef O_CLOEXEC
132
    /* Introduced in Linux 2.6.23. Silently ignored on earlier Linux kernels.
133
     */
134
    if (!(flag & APR_FILE_NOCLEANUP)) {
135
        oflags |= O_CLOEXEC;
136
}
137
#endif
138
 
131
#if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE)
139
#if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE)
132
    oflags |= O_LARGEFILE;
140
    oflags |= O_LARGEFILE;
133
#elif defined(O_LARGEFILE)
141
#elif defined(O_LARGEFILE)
Lines 155-160 APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, Link Here
155
    if (fd < 0) {
163
    if (fd < 0) {
156
       return errno;
164
       return errno;
157
    }
165
    }
166
    if (!(flag & APR_FILE_NOCLEANUP)) {
167
        int fdflags = fcntl(fd, F_GETFD);
168
        fdflags |= FD_CLOEXEC;
169
        fcntl(fd, F_SETFD, fdflags);
170
    }
158
171
159
    (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t));
172
    (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t));
160
    (*new)->pool = pool;
173
    (*new)->pool = pool;
Lines 337-342 APR_DECLARE(apr_status_t) apr_file_inherit_unset(apr_file_t *thefile) Link Here
337
        return APR_EINVAL;
350
        return APR_EINVAL;
338
    }
351
    }
339
    if (thefile->flags & APR_INHERIT) {
352
    if (thefile->flags & APR_INHERIT) {
353
        int fdflags = fcntl(thefile->filedes, F_GETFD);
354
        if (fdflags == -1)
355
	    return errno;
356
        fdflags |= FD_CLOEXEC;
357
        if (fcntl(thefile->filedes, F_SETFD, fdflags) == -1)
358
            return errno;
340
        thefile->flags &= ~APR_INHERIT;
359
        thefile->flags &= ~APR_INHERIT;
341
        apr_pool_child_cleanup_set(thefile->pool,
360
        apr_pool_child_cleanup_set(thefile->pool,
342
                                   (void *)thefile,
361
                                   (void *)thefile,
(-)a/include/arch/unix/apr_arch_inherit.h (+12 lines)
Lines 27-32 apr_status_t apr_##name##_inherit_set(apr_##name##_t *the##name) \ Link Here
27
    if (the##name->flag & APR_FILE_NOCLEANUP)                       \
27
    if (the##name->flag & APR_FILE_NOCLEANUP)                       \
28
        return APR_EINVAL;                                          \
28
        return APR_EINVAL;                                          \
29
    if (!(the##name->flag & APR_INHERIT)) {                         \
29
    if (!(the##name->flag & APR_INHERIT)) {                         \
30
        int flags = fcntl(the##name->name##des, F_GETFD);           \
31
        if (flags == -1)                                            \
32
            return errno;                                           \
33
        flags &= ~(FD_CLOEXEC);                                     \
34
        if (fcntl(the##name->name##des, F_SETFD, flags) == -1)      \
35
            return errno;                                           \
30
        the##name->flag |= APR_INHERIT;                             \
36
        the##name->flag |= APR_INHERIT;                             \
31
        apr_pool_child_cleanup_set(the##name->pool,                 \
37
        apr_pool_child_cleanup_set(the##name->pool,                 \
32
                                   (void *)the##name,               \
38
                                   (void *)the##name,               \
Lines 41-46 apr_status_t apr_##name##_inherit_unset(apr_##name##_t *the##name) \ Link Here
41
    if (the##name->flag & APR_FILE_NOCLEANUP)                       \
47
    if (the##name->flag & APR_FILE_NOCLEANUP)                       \
42
        return APR_EINVAL;                                          \
48
        return APR_EINVAL;                                          \
43
    if (the##name->flag & APR_INHERIT) {                            \
49
    if (the##name->flag & APR_INHERIT) {                            \
50
        int flags = fcntl(the##name->name##des, F_GETFD);           \
51
        if (flags == -1)                                            \
52
            return errno;                                           \
53
        flags |= FD_CLOEXEC;                                        \
54
        if (fcntl(the##name->name##des, F_SETFD, flags) == -1)      \
55
            return errno;                                           \
44
        the##name->flag &= ~APR_INHERIT;                            \
56
        the##name->flag &= ~APR_INHERIT;                            \
45
        apr_pool_child_cleanup_set(the##name->pool,                 \
57
        apr_pool_child_cleanup_set(the##name->pool,                 \
46
                                   (void *)the##name,               \
58
                                   (void *)the##name,               \
(-)a/network_io/unix/sockets.c (-7 / +33 lines)
Lines 108-116 apr_status_t apr_socket_protocol_get(apr_socket_t *sock, int *protocol) Link Here
108
apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type,
108
apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type,
109
                               int protocol, apr_pool_t *cont)
109
                               int protocol, apr_pool_t *cont)
110
{
110
{
111
    int family = ofamily;
111
    int family = ofamily, flags = 0;
112
    int oprotocol = protocol;
112
    int oprotocol = protocol;
113
113
114
#ifdef SOCK_CLOEXEC
115
    flags |= SOCK_CLOEXEC;
116
#endif
117
114
    if (family == APR_UNSPEC) {
118
    if (family == APR_UNSPEC) {
115
#if APR_HAVE_IPV6
119
#if APR_HAVE_IPV6
116
        family = APR_INET6;
120
        family = APR_INET6;
Lines 126-144 apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, Link Here
126
    alloc_socket(new, cont);
130
    alloc_socket(new, cont);
127
131
128
#ifndef BEOS_R5
132
#ifndef BEOS_R5
129
    (*new)->socketdes = socket(family, type, protocol);
133
    (*new)->socketdes = socket(family, type|flags, protocol);
130
#else
134
#else
131
    /* For some reason BeOS R5 has an unconventional protocol numbering,
135
    /* For some reason BeOS R5 has an unconventional protocol numbering,
132
     * so we need to translate here. */
136
     * so we need to translate here. */
133
    switch (protocol) {
137
    switch (protocol) {
134
    case 0:
138
    case 0:
135
        (*new)->socketdes = socket(family, type, 0);
139
        (*new)->socketdes = socket(family, type|flags, 0);
136
        break;
140
        break;
137
    case APR_PROTO_TCP:
141
    case APR_PROTO_TCP:
138
        (*new)->socketdes = socket(family, type, IPPROTO_TCP);
142
        (*new)->socketdes = socket(family, type|flags, IPPROTO_TCP);
139
        break;
143
        break;
140
    case APR_PROTO_UDP:
144
    case APR_PROTO_UDP:
141
        (*new)->socketdes = socket(family, type, IPPROTO_UDP);
145
        (*new)->socketdes = socket(family, type|flags, IPPROTO_UDP);
142
        break;
146
        break;
143
    case APR_PROTO_SCTP:
147
    case APR_PROTO_SCTP:
144
    default:
148
    default:
Lines 151-157 apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, Link Here
151
#if APR_HAVE_IPV6
155
#if APR_HAVE_IPV6
152
    if ((*new)->socketdes < 0 && ofamily == APR_UNSPEC) {
156
    if ((*new)->socketdes < 0 && ofamily == APR_UNSPEC) {
153
        family = APR_INET;
157
        family = APR_INET;
154
        (*new)->socketdes = socket(family, type, protocol);
158
        (*new)->socketdes = socket(family, type|flags, protocol);
155
    }
159
    }
156
#endif
160
#endif
157
161
Lines 160-165 apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, Link Here
160
    }
164
    }
161
    set_socket_vars(*new, family, type, oprotocol);
165
    set_socket_vars(*new, family, type, oprotocol);
162
166
167
#ifndef SOCK_CLOEXEC
168
    flags = fcntl((*new)->socketdes, F_GETFD);
169
    if (flags == -1)
170
        return errno;
171
    flags |= FD_CLOEXEC;
172
    if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
173
        return errno;
174
#endif
175
163
    (*new)->timeout = -1;
176
    (*new)->timeout = -1;
164
    (*new)->inherit = 0;
177
    (*new)->inherit = 0;
165
    apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup,
178
    apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup,
Lines 213-224 apr_status_t apr_socket_listen(apr_socket_t *sock, apr_int32_t backlog) Link Here
213
apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
226
apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
214
                               apr_pool_t *connection_context)
227
                               apr_pool_t *connection_context)
215
{
228
{
216
    int s;
229
    int s, flags;
217
    apr_sockaddr_t sa;
230
    apr_sockaddr_t sa;
218
231
219
    sa.salen = sizeof(sa.sa);
232
    sa.salen = sizeof(sa.sa);
220
233
234
#ifdef HAVE_ACCEPT4
235
    s = accept4(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen, SOCK_CLOEXEC);
236
#else
221
    s = accept(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen);
237
    s = accept(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen);
238
#endif
222
239
223
    if (s < 0) {
240
    if (s < 0) {
224
        return errno;
241
        return errno;
Lines 300-305 apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, Link Here
300
        (*new)->local_interface_unknown = 1;
317
        (*new)->local_interface_unknown = 1;
301
    }
318
    }
302
319
320
#ifndef HAVE_ACCEPT4
321
    flags = fcntl((*new)->socketdes, F_GETFD);
322
    if (flags == -1)
323
        return errno;
324
    flags |= FD_CLOEXEC;
325
    if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
326
        return errno;
327
#endif
328
303
    (*new)->inherit = 0;
329
    (*new)->inherit = 0;
304
    apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup,
330
    apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup,
305
                              socket_cleanup);
331
                              socket_cleanup);
(-)a/poll/unix/epoll.c (-3 / +23 lines)
Lines 93-106 static apr_status_t impl_pollset_create(apr_pollset_t *pollset, Link Here
93
                                        apr_uint32_t flags)
93
                                        apr_uint32_t flags)
94
{
94
{
95
    apr_status_t rv;
95
    apr_status_t rv;
96
    int fd;
96
    int fd, fdflags;
97
97
98
#ifdef HAVE_EPOLL_CREATE1
99
    fd = epoll_create1(EPOLL_CLOEXEC);
100
#else
98
    fd = epoll_create(size);
101
    fd = epoll_create(size);
102
#endif
99
    if (fd < 0) {
103
    if (fd < 0) {
100
        pollset->p = NULL;
104
        pollset->p = NULL;
101
        return apr_get_netos_error();
105
        return apr_get_netos_error();
102
    }
106
    }
103
107
108
#ifndef HAVE_EPOLL_CREATE1
109
    fdflags = fcntl(fd, F_GETFD);
110
    fdflags |= FD_CLOEXEC;
111
    fcntl(fd, F_SETFD, fdflags);
112
#endif
113
104
    pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
114
    pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
105
#if APR_HAS_THREADS
115
#if APR_HAS_THREADS
106
    if ((flags & APR_POLLSET_THREADSAFE) &&
116
    if ((flags & APR_POLLSET_THREADSAFE) &&
Lines 317-333 static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, Link Here
317
                                       apr_pool_t *p,
327
                                       apr_pool_t *p,
318
                                       apr_uint32_t flags)
328
                                       apr_uint32_t flags)
319
{
329
{
320
    int fd;
330
    int fd, fdflags;
321
    
331
    
332
#ifdef HAVE_EPOLL_CREATE1
333
    fd = epoll_create1(EPOLL_CLOEXEC);
334
#else
322
    fd = epoll_create(size);
335
    fd = epoll_create(size);
336
#endif
323
    
337
    
324
    if (fd < 0) {
338
    if (fd < 0) {
325
        return apr_get_netos_error();
339
        return apr_get_netos_error();
326
    }
340
    }
341
342
#ifndef HAVE_EPOLL_CREATE1
343
    fdflags = fcntl(fd, F_GETFD);
344
    fdflags |= FD_CLOEXEC;
345
    fcntl(fd, F_SETFD, fdflags);
346
#endif
327
    
347
    
328
    pollcb->fd = fd;
348
    pollcb->fd = fd;
329
    pollcb->pollset.epoll = apr_palloc(p, size * sizeof(struct epoll_event));
349
    pollcb->pollset.epoll = apr_palloc(p, size * sizeof(struct epoll_event));
330
    apr_pool_cleanup_register(p, pollcb, cb_cleanup, cb_cleanup);
350
    apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
331
351
332
    return APR_SUCCESS;
352
    return APR_SUCCESS;
333
}
353
}
(-)a/poll/unix/kqueue.c (-2 / +11 lines)
Lines 71-76 static apr_status_t impl_pollset_create(apr_pollset_t *pollset, Link Here
71
                                        apr_uint32_t flags)
71
                                        apr_uint32_t flags)
72
{
72
{
73
    apr_status_t rv = APR_SUCCESS;
73
    apr_status_t rv = APR_SUCCESS;
74
    int fdflags;
74
    pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
75
    pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
75
#if APR_HAS_THREADS
76
#if APR_HAS_THREADS
76
    if (flags & APR_POLLSET_THREADSAFE &&
77
    if (flags & APR_POLLSET_THREADSAFE &&
Lines 98-103 static apr_status_t impl_pollset_create(apr_pollset_t *pollset, Link Here
98
        return apr_get_netos_error();
99
        return apr_get_netos_error();
99
    }
100
    }
100
101
102
    fdflags = fcntl((*pollset)->kqueue_fd, F_GETFD);
103
    fdflags |= FD_CLOEXEC;
104
    fcntl((*pollset)->kqueue_fd, F_SETFD, fdflags);
105
101
    pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
106
    pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
102
107
103
    APR_RING_INIT(&pollset->p->query_ring, pfd_elem_t, link);
108
    APR_RING_INIT(&pollset->p->query_ring, pfd_elem_t, link);
Lines 306-321 static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, Link Here
306
                                       apr_pool_t *p,
311
                                       apr_pool_t *p,
307
                                       apr_uint32_t flags)
312
                                       apr_uint32_t flags)
308
{
313
{
309
    int fd;
314
    int fd, fdflags;
310
    
315
    
311
    fd = kqueue();
316
    fd = kqueue();
312
    if (fd < 0) {
317
    if (fd < 0) {
313
        return apr_get_netos_error();
318
        return apr_get_netos_error();
314
    }
319
    }
320
321
    fdflags = fcntl(fd, F_GETFD);
322
    fdflags |= FD_CLOEXEC;
323
    fcntl(fd, F_SETFD, fdflags);
315
    
324
    
316
    pollcb->fd = fd;
325
    pollcb->fd = fd;
317
    pollcb->pollset.ke = (struct kevent *)apr_pcalloc(p, size * sizeof(struct kevent));
326
    pollcb->pollset.ke = (struct kevent *)apr_pcalloc(p, size * sizeof(struct kevent));
318
    apr_pool_cleanup_register(p, pollcb, cb_cleanup, cb_cleanup);
327
    apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
319
    
328
    
320
    return APR_SUCCESS;
329
    return APR_SUCCESS;
321
}
330
}
(-)a/poll/unix/pollset.c (+10 lines)
Lines 79-84 static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset) Link Here
79
{
79
{
80
    apr_status_t rv;
80
    apr_status_t rv;
81
    apr_pollfd_t fd;
81
    apr_pollfd_t fd;
82
    int fdflags;
82
83
83
    if ((rv = apr_file_pipe_create(&pollset->wakeup_pipe[0],
84
    if ((rv = apr_file_pipe_create(&pollset->wakeup_pipe[0],
84
                                   &pollset->wakeup_pipe[1],
85
                                   &pollset->wakeup_pipe[1],
Lines 87-92 static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset) Link Here
87
    fd.reqevents = APR_POLLIN;
88
    fd.reqevents = APR_POLLIN;
88
    fd.desc_type = APR_POLL_FILE;
89
    fd.desc_type = APR_POLL_FILE;
89
    fd.desc.f = pollset->wakeup_pipe[0];
90
    fd.desc.f = pollset->wakeup_pipe[0];
91
92
    fdflags = fcntl(pollset->wakeup_pipe[0]->filedes, F_GETFD);
93
    fdflags |= FD_CLOEXEC;
94
    fcntl(pollset->wakeup_pipe[0]->filedes, F_SETFD, fdflags);
95
96
    fdflags = fcntl(pollset->wakeup_pipe[1]->filedes, F_GETFD);
97
    fdflags |= FD_CLOEXEC;
98
    fcntl(pollset->wakeup_pipe[1]->filedes, F_SETFD, fdflags);
99
90
    /* Add the pipe to the pollset
100
    /* Add the pipe to the pollset
91
     */
101
     */
92
    return apr_pollset_add(pollset, &fd);
102
    return apr_pollset_add(pollset, &fd);
(-)a/poll/unix/port.c (-1 / +11 lines)
Lines 100-105 static apr_status_t impl_pollset_create(apr_pollset_t **pollset, Link Here
100
{
100
{
101
    apr_status_t rv = APR_SUCCESS;
101
    apr_status_t rv = APR_SUCCESS;
102
    pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
102
    pollset->p = apr_palloc(p, sizeof(apr_pollset_private_t));
103
    int fdflags;
103
#if APR_HAS_THREADS
104
#if APR_HAS_THREADS
104
    if (flags & APR_POLLSET_THREADSAFE &&
105
    if (flags & APR_POLLSET_THREADSAFE &&
105
        ((rv = apr_thread_mutex_create(&pollset->p->ring_lock,
106
        ((rv = apr_thread_mutex_create(&pollset->p->ring_lock,
Lines 125-130 static apr_status_t impl_pollset_create(apr_pollset_t **pollset, Link Here
125
        return APR_ENOMEM;
126
        return APR_ENOMEM;
126
    }
127
    }
127
128
129
    fdflags = fcntl(fd, F_GETFD);
130
    fdflags |= FD_CLOEXEC;
131
    fcntl(fd, F_SETFD, fdflags);
132
128
    pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
133
    pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
129
134
130
    APR_RING_INIT(&pollset->p->query_ring, pfd_elem_t, link);
135
    APR_RING_INIT(&pollset->p->query_ring, pfd_elem_t, link);
Lines 389-402 static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, Link Here
389
                                       apr_pool_t *p,
394
                                       apr_pool_t *p,
390
                                       apr_uint32_t flags)
395
                                       apr_uint32_t flags)
391
{
396
{
397
    int fdflags;
392
    pollcb->fd = port_create();
398
    pollcb->fd = port_create();
393
399
394
    if (pollcb->fd < 0) {
400
    if (pollcb->fd < 0) {
395
        return apr_get_netos_error();
401
        return apr_get_netos_error();
396
    }
402
    }
397
403
404
    fdflags = fcntl(fd, F_GETFD);
405
    fdflags |= FD_CLOEXEC;
406
    fcntl(fd, F_SETFD, fdflags);
407
398
    pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
408
    pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
399
    apr_pool_cleanup_register(p, pollcb, cb_cleanup, cb_cleanup);
409
    apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
400
410
401
    return APR_SUCCESS;
411
    return APR_SUCCESS;
402
}
412
}

Return to bug 46425