]> git.pld-linux.org Git - packages/apr.git/blob - apr-bug-46425.patch
- use fdflags not flags for consistency
[packages/apr.git] / apr-bug-46425.patch
1 diff -urN apr-1.3.3.org/file_io/unix/filedup.c apr-1.3.3/file_io/unix/filedup.c
2 --- apr-1.3.3.org/file_io/unix/filedup.c        2007-05-15 04:37:16.000000000 +0200
3 +++ apr-1.3.3/file_io/unix/filedup.c    2009-02-23 08:15:10.023641368 +0100
4 @@ -24,7 +24,7 @@
5                               apr_file_t *old_file, apr_pool_t *p,
6                               int which_dup)
7  {
8 -    int rv;
9 +    int rv, fdflags;
10      
11      if (which_dup == 2) {
12          if ((*new_file) == NULL) {
13 @@ -32,6 +32,14 @@
14              return APR_EINVAL;
15          }
16          rv = dup2(old_file->filedes, (*new_file)->filedes);
17 +        if (!(old_file->flags & APR_INHERIT)) {
18 +            fdflags = fcntl((*new_file)->filedes, F_GETFD);
19 +            if (fdflags == -1)
20 +                return errno;
21 +            fdflags |= FD_CLOEXEC;
22 +            if (fcntl((*new_file)->filedes, F_SETFD, fdflags) == -1)
23 +                return errno;
24 +        }
25      } else {
26          rv = dup(old_file->filedes);
27      }
28 diff -urN apr-1.3.3.org/file_io/unix/mktemp.c apr-1.3.3/file_io/unix/mktemp.c
29 --- apr-1.3.3.org/file_io/unix/mktemp.c 2007-06-01 19:58:04.000000000 +0200
30 +++ apr-1.3.3/file_io/unix/mktemp.c     2009-02-23 08:18:30.420011379 +0100
31 @@ -203,6 +203,11 @@
32      (*fp)->fname = apr_pstrdup(p, template);
33  
34      if (!(flags & APR_FILE_NOCLEANUP)) {
35 +        int fdflags = fcntl(fd, F_GETFD);
36 +        if (fdflags != -1) {
37 +            fdflags |= FD_CLOEXEC;
38 +            fcntl(fd, F_SETFD, fdflags);
39 +        }
40          apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
41                                    apr_unix_file_cleanup,
42                                    apr_unix_child_file_cleanup);
43 diff -urN apr-1.3.3.org/file_io/unix/open.c apr-1.3.3/file_io/unix/open.c
44 --- apr-1.3.3.org/file_io/unix/open.c   2007-05-15 04:37:16.000000000 +0200
45 +++ apr-1.3.3/file_io/unix/open.c       2009-02-23 08:13:44.356609676 +0100
46 @@ -125,7 +125,15 @@
47          oflags |= O_BINARY;
48      }
49  #endif
50 -    
51 +
52 +#ifdef O_CLOEXEC
53 +    /* Introduced in Linux 2.6.23. Silently ignored on earlier Linux kernels.
54 +     */
55 +    if (!(flag & APR_FILE_NOCLEANUP)) {
56 +        oflags |= O_CLOEXEC;
57 +}
58 +#endif
59
60  #if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE)
61      oflags |= O_LARGEFILE;
62  #elif defined(O_LARGEFILE)
63 @@ -153,6 +161,11 @@
64      if (fd < 0) {
65         return errno;
66      }
67 +    if (!(flag & APR_FILE_NOCLEANUP)) {
68 +        int fdflags = fcntl(fd, F_GETFD);
69 +        fdflags |= FD_CLOEXEC;
70 +        fcntl(fd, F_SETFD, fdflags);
71 +    }
72  
73      (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t));
74      (*new)->pool = pool;
75 diff -urN apr-1.3.3.org/include/arch/unix/apr_arch_inherit.h apr-1.3.3/include/arch/unix/apr_arch_inherit.h
76 --- apr-1.3.3.org/include/arch/unix/apr_arch_inherit.h  2006-08-03 12:55:31.000000000 +0200
77 +++ apr-1.3.3/include/arch/unix/apr_arch_inherit.h      2009-02-23 08:17:48.033064583 +0100
78 @@ -27,6 +27,12 @@
79      if (the##name->flag & APR_FILE_NOCLEANUP)                       \
80          return APR_EINVAL;                                          \
81      if (!(the##name->flag & APR_INHERIT)) {                         \
82 +        int fdflags = fcntl(the##name->name##des, F_GETFD);           \
83 +        if (fdflags == -1)                                            \
84 +            return errno;                                           \
85 +        fdflags &= ~(FD_CLOEXEC);                                     \
86 +        if (fcntl(the##name->name##des, F_SETFD, fdflags) == -1)      \
87 +            return errno;                                           \
88          the##name->flag |= APR_INHERIT;                             \
89          apr_pool_child_cleanup_set(the##name->pool,                 \
90                                     (void *)the##name,               \
91 @@ -41,6 +47,12 @@
92      if (the##name->flag & APR_FILE_NOCLEANUP)                       \
93          return APR_EINVAL;                                          \
94      if (the##name->flag & APR_INHERIT) {                            \
95 +        int fdflags = fcntl(the##name->name##des, F_GETFD);           \
96 +        if (fdflags == -1)                                            \
97 +            return errno;                                           \
98 +        fdflags |= FD_CLOEXEC;                                        \
99 +        if (fcntl(the##name->name##des, F_SETFD, fdflags) == -1)      \
100 +            return errno;                                           \
101          the##name->flag &= ~APR_INHERIT;                            \
102          apr_pool_child_cleanup_set(the##name->pool,                 \
103                                     (void *)the##name,               \
104 diff -urN apr-1.3.3.org/network_io/unix/sockets.c apr-1.3.3/network_io/unix/sockets.c
105 --- apr-1.3.3.org/network_io/unix/sockets.c     2009-02-23 08:08:40.966440943 +0100
106 +++ apr-1.3.3/network_io/unix/sockets.c 2009-02-23 08:19:02.086419869 +0100
107 @@ -83,7 +83,7 @@
108  apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type,
109                                 int protocol, apr_pool_t *cont)
110  {
111 -    int family = ofamily;
112 +    int family = ofamily, fdflags;
113  
114      if (family == APR_UNSPEC) {
115  #if APR_HAVE_IPV6
116 @@ -130,6 +130,13 @@
117      }
118      set_socket_vars(*new, family, type, protocol);
119  
120 +    fdflags = fcntl((*new)->socketdes, F_GETFD);
121 +    if (fdflags == -1)
122 +        return errno;
123 +    fdflags |= FD_CLOEXEC;
124 +    if (fcntl((*new)->socketdes, F_SETFD, fdflags) == -1)
125 +        return errno;
126 +
127      (*new)->timeout = -1;
128      (*new)->inherit = 0;
129      apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup,
130 @@ -183,7 +183,7 @@
131  apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
132                                 apr_pool_t *connection_context)
133  {
134 -    int s;
135 +    int s, fdflags;
136      apr_sockaddr_t sa;
137  
138      sa.salen = sizeof(sa.sa);
139 @@ -255,6 +262,13 @@
140          (*new)->local_interface_unknown = 1;
141      }
142  
143 +    fdflags = fcntl((*new)->socketdes, F_GETFD);
144 +    if (fdflags == -1)
145 +        return errno;
146 +    fdflags |= FD_CLOEXEC;
147 +    if (fcntl((*new)->socketdes, F_SETFD, fdflags) == -1)
148 +        return errno;
149 +
150      (*new)->inherit = 0;
151      apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup,
152                                socket_cleanup);
153 diff -urN apr-1.3.3.org/poll/unix/epoll.c apr-1.3.3/poll/unix/epoll.c
154 --- apr-1.3.3.org/poll/unix/epoll.c     2008-04-13 13:37:52.000000000 +0200
155 +++ apr-1.3.3/poll/unix/epoll.c 2009-02-23 08:20:07.663209400 +0100
156 @@ -91,7 +91,7 @@
157                                               apr_uint32_t flags)
158  {
159      apr_status_t rv;
160 -    int fd;
161 +    int fd, fdflags;
162  
163      fd = epoll_create(size);
164      if (fd < 0) {
165 @@ -99,6 +99,12 @@
166          return errno;
167      }
168  
169 +    fdflags = fcntl(fd, F_GETFD);
170 +    if (fdflags != -1) {
171 +        fdflags |= FD_CLOEXEC;
172 +        fcntl(fd, F_SETFD, fdflags);
173 +    }
174 +
175      *pollset = apr_palloc(p, sizeof(**pollset));
176  #if APR_HAS_THREADS
177      if ((flags & APR_POLLSET_THREADSAFE) &&
178 @@ -315,14 +321,20 @@
179                                              apr_pool_t *p,
180                                              apr_uint32_t flags)
181  {
182 -    int fd;
183 -    
184 +    int fd, fdflags;
185 +   
186      fd = epoll_create(size);
187      
188      if (fd < 0) {
189          *pollcb = NULL;
190          return apr_get_netos_error();
191      }
192 +
193 +    fdflags = fcntl(fd, F_GETFD);
194 +    if (fdflags != -1) {
195 +        fdflags |= FD_CLOEXEC;
196 +        fcntl(fd, F_SETFD, fdflags);
197 +    }
198      
199      *pollcb = apr_palloc(p, sizeof(**pollcb));
200      (*pollcb)->nalloc = size;
This page took 0.057539 seconds and 3 git commands to generate.