aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2012-10-08 22:41:27 +0000
committerLRN <lrn1986@gmail.com>2012-10-08 22:41:27 +0000
commitf80dcff23f0cd6584410581b7b135882d3a49feb (patch)
tree6e081c4a181f171191f9f0e4247b3adf21248fc3 /src/util
parent165988ffc93e60258cdc48c68bfad8ad0a0babab (diff)
downloadgnunet-f80dcff23f0cd6584410581b7b135882d3a49feb.tar.gz
gnunet-f80dcff23f0cd6584410581b7b135882d3a49feb.zip
Implement non-inheritable sockets for W32
Diffstat (limited to 'src/util')
-rw-r--r--src/util/network.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/util/network.c b/src/util/network.c
index edb8e21d5..86bc47677 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -163,7 +163,6 @@ socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int doBlock)
163} 163}
164 164
165 165
166#ifndef MINGW
167/** 166/**
168 * Make a socket non-inheritable to child processes 167 * Make a socket non-inheritable to child processes
169 * 168 *
@@ -174,8 +173,8 @@ socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int doBlock)
174static int 173static int
175socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h) 174socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h)
176{ 175{
176#ifndef MINGW
177 int i; 177 int i;
178
179 i = fcntl (h->fd, F_GETFD); 178 i = fcntl (h->fd, F_GETFD);
180 if (i < 0) 179 if (i < 0)
181 return GNUNET_SYSERR; 180 return GNUNET_SYSERR;
@@ -184,9 +183,18 @@ socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h)
184 i |= FD_CLOEXEC; 183 i |= FD_CLOEXEC;
185 if (fcntl (h->fd, F_SETFD, i) < 0) 184 if (fcntl (h->fd, F_SETFD, i) < 0)
186 return GNUNET_SYSERR; 185 return GNUNET_SYSERR;
186#else
187 BOOL b;
188 SetLastError (0);
189 b = SetHandleInformation (h->fd, HANDLE_FLAG_INHERIT, 0);
190 if (!b)
191 {
192 SetErrnoFromWinsockError (WSAGetLastError ());
193 return GNUNET_SYSERR;
194 }
195#endif
187 return GNUNET_OK; 196 return GNUNET_OK;
188} 197}
189#endif
190 198
191 199
192#ifdef DARWIN 200#ifdef DARWIN
@@ -266,10 +274,11 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
266 errno = EMFILE; 274 errno = EMFILE;
267 return GNUNET_SYSERR; 275 return GNUNET_SYSERR;
268 } 276 }
277#endif
269 if (GNUNET_OK != socket_set_inheritable (h)) 278 if (GNUNET_OK != socket_set_inheritable (h))
270 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 279 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
271 "socket_set_inheritable"); 280 "socket_set_inheritable");
272#endif 281
273 if (GNUNET_SYSERR == socket_set_blocking (h, GNUNET_NO)) 282 if (GNUNET_SYSERR == socket_set_blocking (h, GNUNET_NO))
274 { 283 {
275 GNUNET_break (0); 284 GNUNET_break (0);