diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/connection.c | 54 | ||||
-rw-r--r-- | src/util/network.c | 211 | ||||
-rw-r--r-- | src/util/server.c | 7 | ||||
-rw-r--r-- | src/util/service.c | 2 | ||||
-rw-r--r-- | src/util/test_connection.c | 2 | ||||
-rw-r--r-- | src/util/test_connection_addressing.c | 2 | ||||
-rw-r--r-- | src/util/test_connection_receive_cancel.c | 2 | ||||
-rw-r--r-- | src/util/test_connection_timeout.c | 2 | ||||
-rw-r--r-- | src/util/test_service.c | 2 |
9 files changed, 145 insertions, 139 deletions
diff --git a/src/util/connection.c b/src/util/connection.c index 1e2f1fca8..ad2bf14c0 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -342,11 +342,6 @@ GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle | |||
342 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "accept"); | 342 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "accept"); |
343 | return NULL; | 343 | return NULL; |
344 | } | 344 | } |
345 | #ifndef MINGW | ||
346 | if (GNUNET_OK != GNUNET_NETWORK_socket_set_inheritable (sock)) | ||
347 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
348 | "fcntl"); | ||
349 | #endif | ||
350 | if (addrlen > sizeof (addr)) | 345 | if (addrlen > sizeof (addr)) |
351 | { | 346 | { |
352 | GNUNET_break (0); | 347 | GNUNET_break (0); |
@@ -797,25 +792,12 @@ try_connect_using_address (void *cls, | |||
797 | GNUNET_free (ap); | 792 | GNUNET_free (ap); |
798 | return; /* not supported by us */ | 793 | return; /* not supported by us */ |
799 | } | 794 | } |
800 | ap->sock = GNUNET_NETWORK_socket_socket (ap->addr->sa_family, SOCK_STREAM, 0); | 795 | ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family, SOCK_STREAM, 0); |
801 | if (ap->sock == NULL) | 796 | if (ap->sock == NULL) |
802 | { | 797 | { |
803 | GNUNET_free (ap); | 798 | GNUNET_free (ap); |
804 | return; /* not supported by OS */ | 799 | return; /* not supported by OS */ |
805 | } | 800 | } |
806 | #ifndef MINGW | ||
807 | if (GNUNET_OK != GNUNET_NETWORK_socket_set_inheritable (ap->sock)) | ||
808 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
809 | "GNUNET_NETWORK_socket_set_inheritable"); | ||
810 | #endif | ||
811 | if (GNUNET_SYSERR == GNUNET_NETWORK_socket_set_blocking (ap->sock, GNUNET_NO)) | ||
812 | { | ||
813 | /* we might want to treat this one as fatal... */ | ||
814 | GNUNET_break (0); | ||
815 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock)); | ||
816 | GNUNET_free (ap); | ||
817 | return; | ||
818 | } | ||
819 | #if DEBUG_CONNECTION | 801 | #if DEBUG_CONNECTION |
820 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 802 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
821 | _("Trying to connect to `%s' (%p)\n"), | 803 | _("Trying to connect to `%s' (%p)\n"), |
@@ -932,27 +914,13 @@ GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle | |||
932 | struct GNUNET_NETWORK_Handle *s; | 914 | struct GNUNET_NETWORK_Handle *s; |
933 | struct GNUNET_CONNECTION_Handle *ret; | 915 | struct GNUNET_CONNECTION_Handle *ret; |
934 | 916 | ||
935 | s = GNUNET_NETWORK_socket_socket (af_family, SOCK_STREAM, 0); | 917 | s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0); |
936 | if (s == NULL) | 918 | if (s == NULL) |
937 | { | 919 | { |
938 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | 920 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | |
939 | GNUNET_ERROR_TYPE_BULK, "socket"); | 921 | GNUNET_ERROR_TYPE_BULK, "socket"); |
940 | return NULL; | 922 | return NULL; |
941 | } | 923 | } |
942 | #ifndef MINGW | ||
943 | #if 0 | ||
944 | // FIXME NILS | ||
945 | if (0 != fcntl (s, F_SETFD, fcntl (s, F_GETFD) | FD_CLOEXEC)) | ||
946 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
947 | "fcntl"); | ||
948 | #endif | ||
949 | #endif | ||
950 | if (GNUNET_SYSERR == GNUNET_NETWORK_socket_set_blocking (s, GNUNET_NO)) | ||
951 | { | ||
952 | /* we'll treat this one as fatal */ | ||
953 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); | ||
954 | return NULL; | ||
955 | } | ||
956 | if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) && (errno != EINPROGRESS)) | 924 | if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) && (errno != EINPROGRESS)) |
957 | { | 925 | { |
958 | /* maybe refused / unsupported address, try next */ | 926 | /* maybe refused / unsupported address, try next */ |
@@ -1093,14 +1061,7 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1093 | } | 1061 | } |
1094 | GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready, sh->sock)); | 1062 | GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready, sh->sock)); |
1095 | RETRY: | 1063 | RETRY: |
1096 | ret = GNUNET_NETWORK_socket_recv (sh->sock, buffer, sh->max, | 1064 | ret = GNUNET_NETWORK_socket_recv (sh->sock, buffer, sh->max); |
1097 | #ifndef MINGW | ||
1098 | // FIXME MINGW | ||
1099 | MSG_DONTWAIT | ||
1100 | #else | ||
1101 | 0 | ||
1102 | #endif | ||
1103 | ); | ||
1104 | if (ret == -1) | 1065 | if (ret == -1) |
1105 | { | 1066 | { |
1106 | if (errno == EINTR) | 1067 | if (errno == EINTR) |
@@ -1418,14 +1379,7 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1418 | RETRY: | 1379 | RETRY: |
1419 | ret = GNUNET_NETWORK_socket_send (sock->sock, | 1380 | ret = GNUNET_NETWORK_socket_send (sock->sock, |
1420 | &sock->write_buffer[sock->write_buffer_pos], | 1381 | &sock->write_buffer[sock->write_buffer_pos], |
1421 | have, | 1382 | have); |
1422 | #ifndef MINGW | ||
1423 | // FIXME NILS | ||
1424 | MSG_DONTWAIT | MSG_NOSIGNAL | ||
1425 | #else | ||
1426 | 0 | ||
1427 | #endif | ||
1428 | ); | ||
1429 | if (ret == -1) | 1383 | if (ret == -1) |
1430 | { | 1384 | { |
1431 | if (errno == EINTR) | 1385 | if (errno == EINTR) |
diff --git a/src/util/network.c b/src/util/network.c index 8bdace580..9a38dc098 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -55,6 +55,75 @@ struct GNUNET_NETWORK_FDSet | |||
55 | #define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set))) | 55 | #define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set))) |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Set if a socket should use blocking or non-blocking IO. | ||
62 | * @param fd socket | ||
63 | * @param doBlock blocking mode | ||
64 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
65 | */ | ||
66 | static int | ||
67 | socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, | ||
68 | int doBlock) | ||
69 | { | ||
70 | #if MINGW | ||
71 | u_long mode; | ||
72 | mode = !doBlock; | ||
73 | if (ioctlsocket (fd->fd, FIONBIO, &mode) == SOCKET_ERROR) | ||
74 | { | ||
75 | SetErrnoFromWinsockError (WSAGetLastError ()); | ||
76 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "ioctlsocket"); | ||
77 | return GNUNET_SYSERR; | ||
78 | } | ||
79 | return GNUNET_OK; | ||
80 | |||
81 | #else | ||
82 | /* not MINGW */ | ||
83 | int flags = fcntl (fd->fd, F_GETFL); | ||
84 | if (flags == -1) | ||
85 | { | ||
86 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl"); | ||
87 | return GNUNET_SYSERR; | ||
88 | } | ||
89 | if (doBlock) | ||
90 | flags &= ~O_NONBLOCK; | ||
91 | else | ||
92 | flags |= O_NONBLOCK; | ||
93 | if (0 != fcntl (fd->fd, F_SETFL, flags)) | ||
94 | { | ||
95 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl"); | ||
96 | return GNUNET_SYSERR; | ||
97 | } | ||
98 | return GNUNET_OK; | ||
99 | #endif | ||
100 | } | ||
101 | |||
102 | |||
103 | #ifndef MINGW | ||
104 | /** | ||
105 | * Make a non-inheritable to child processes | ||
106 | * | ||
107 | * @param h the socket to make non-inheritable | ||
108 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | ||
109 | * @warning Not implemented on Windows | ||
110 | */ | ||
111 | static int | ||
112 | socket_set_inheritable (const struct GNUNET_NETWORK_Handle | ||
113 | *h) | ||
114 | { | ||
115 | int i; | ||
116 | |||
117 | i = fcntl (h->fd, F_GETFD); | ||
118 | if (i == (i | FD_CLOEXEC)) | ||
119 | return GNUNET_OK; | ||
120 | return (fcntl (h->fd, F_SETFD, i | FD_CLOEXEC) == 0) | ||
121 | ? GNUNET_OK : GNUNET_SYSERR; | ||
122 | } | ||
123 | #endif | ||
124 | |||
125 | |||
126 | |||
58 | /** | 127 | /** |
59 | * accept a new connection on a socket | 128 | * accept a new connection on a socket |
60 | * | 129 | * |
@@ -89,6 +158,18 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | |||
89 | return NULL; | 158 | return NULL; |
90 | } | 159 | } |
91 | #endif | 160 | #endif |
161 | if (GNUNET_SYSERR == socket_set_blocking (ret, GNUNET_NO)) | ||
162 | { | ||
163 | /* we might want to treat this one as fatal... */ | ||
164 | GNUNET_break (0); | ||
165 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret)); | ||
166 | return NULL; | ||
167 | } | ||
168 | #ifndef MINGW | ||
169 | if (GNUNET_OK != socket_set_inheritable (ret)) | ||
170 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
171 | "socket_set_inheritable"); | ||
172 | #endif | ||
92 | return ret; | 173 | return ret; |
93 | } | 174 | } |
94 | 175 | ||
@@ -114,47 +195,6 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, | |||
114 | return ret == 0 ? GNUNET_OK : GNUNET_SYSERR; | 195 | return ret == 0 ? GNUNET_OK : GNUNET_SYSERR; |
115 | } | 196 | } |
116 | 197 | ||
117 | /** | ||
118 | * Set if a socket should use blocking or non-blocking IO. | ||
119 | * @param fd socket | ||
120 | * @param doBlock blocking mode | ||
121 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
122 | */ | ||
123 | int | ||
124 | GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, | ||
125 | int doBlock) | ||
126 | { | ||
127 | #if MINGW | ||
128 | u_long mode; | ||
129 | mode = !doBlock; | ||
130 | if (ioctlsocket (fd->fd, FIONBIO, &mode) == SOCKET_ERROR) | ||
131 | { | ||
132 | SetErrnoFromWinsockError (WSAGetLastError ()); | ||
133 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "ioctlsocket"); | ||
134 | return GNUNET_SYSERR; | ||
135 | } | ||
136 | return GNUNET_OK; | ||
137 | |||
138 | #else | ||
139 | /* not MINGW */ | ||
140 | int flags = fcntl (fd->fd, F_GETFL); | ||
141 | if (flags == -1) | ||
142 | { | ||
143 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl"); | ||
144 | return GNUNET_SYSERR; | ||
145 | } | ||
146 | if (doBlock) | ||
147 | flags &= ~O_NONBLOCK; | ||
148 | else | ||
149 | flags |= O_NONBLOCK; | ||
150 | if (0 != fcntl (fd->fd, F_SETFL, flags)) | ||
151 | { | ||
152 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl"); | ||
153 | return GNUNET_SYSERR; | ||
154 | } | ||
155 | return GNUNET_OK; | ||
156 | #endif | ||
157 | } | ||
158 | 198 | ||
159 | /** | 199 | /** |
160 | * Close a socket | 200 | * Close a socket |
@@ -207,6 +247,7 @@ GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, | |||
207 | 247 | ||
208 | /** | 248 | /** |
209 | * Get socket options | 249 | * Get socket options |
250 | * | ||
210 | * @param desc socket | 251 | * @param desc socket |
211 | * @param level protocol level of the option | 252 | * @param level protocol level of the option |
212 | * @param optname identifier of the option | 253 | * @param optname identifier of the option |
@@ -253,18 +294,22 @@ GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, | |||
253 | } | 294 | } |
254 | 295 | ||
255 | /** | 296 | /** |
256 | * Read data from a connected socket | 297 | * Read data from a connected socket (always non-blocking). |
257 | * @param desc socket | 298 | * @param desc socket |
258 | * @param buffer buffer | 299 | * @param buffer buffer |
259 | * @param length length of buffer | 300 | * @param length length of buffer |
260 | * @param flags type of message reception | ||
261 | */ | 301 | */ |
262 | ssize_t | 302 | ssize_t |
263 | GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle * desc, | 303 | GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle * desc, |
264 | void *buffer, size_t length, int flags) | 304 | void *buffer, size_t length) |
265 | { | 305 | { |
266 | int ret; | 306 | int ret; |
307 | int flags; | ||
267 | 308 | ||
309 | flags = 0; | ||
310 | #ifdef MSG_DONTWAIT | ||
311 | flags |= MSG_DONTWAIT; | ||
312 | #endif | ||
268 | ret = recv (desc->fd, buffer, length, flags); | 313 | ret = recv (desc->fd, buffer, length, flags); |
269 | #ifdef MINGW | 314 | #ifdef MINGW |
270 | if (SOCKET_ERROR == ret) | 315 | if (SOCKET_ERROR == ret) |
@@ -275,19 +320,27 @@ GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle * desc, | |||
275 | } | 320 | } |
276 | 321 | ||
277 | /** | 322 | /** |
278 | * Send data | 323 | * Send data (always non-blocking). |
324 | * | ||
279 | * @param desc socket | 325 | * @param desc socket |
280 | * @param buffer data to send | 326 | * @param buffer data to send |
281 | * @param length size of the buffer | 327 | * @param length size of the buffer |
282 | * @param flags type of message transmission | ||
283 | * @return number of bytes sent, GNUNET_SYSERR on error | 328 | * @return number of bytes sent, GNUNET_SYSERR on error |
284 | */ | 329 | */ |
285 | ssize_t | 330 | ssize_t |
286 | GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle * desc, | 331 | GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle * desc, |
287 | const void *buffer, size_t length, int flags) | 332 | const void *buffer, size_t length) |
288 | { | 333 | { |
289 | int ret; | 334 | int ret; |
335 | int flags; | ||
290 | 336 | ||
337 | flags = 0; | ||
338 | #ifdef MSG_DONTWAIT | ||
339 | flags |= MSG_DONTWAIT; | ||
340 | #endif | ||
341 | #ifdef MSG_NOSIGNAL | ||
342 | flags |= MSG_NOSIGNAL; | ||
343 | #endif | ||
291 | ret = send (desc->fd, buffer, length, flags); | 344 | ret = send (desc->fd, buffer, length, flags); |
292 | #ifdef MINGW | 345 | #ifdef MINGW |
293 | if (SOCKET_ERROR == ret) | 346 | if (SOCKET_ERROR == ret) |
@@ -297,24 +350,34 @@ GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle * desc, | |||
297 | return ret; | 350 | return ret; |
298 | } | 351 | } |
299 | 352 | ||
353 | |||
300 | /** | 354 | /** |
301 | * Send data | 355 | * Send data to a particular destination (always non-blocking). |
356 | * This function only works for UDP sockets. | ||
357 | * | ||
302 | * @param desc socket | 358 | * @param desc socket |
303 | * @param message data to send | 359 | * @param message data to send |
304 | * @param length size of the data | 360 | * @param length size of the data |
305 | * @param flags type of message transmission | ||
306 | * @param dest_addr destination address | 361 | * @param dest_addr destination address |
307 | * @param dest_len length of address | 362 | * @param dest_len length of address |
308 | * @return number of bytes sent, GNUNET_SYSERR on error | 363 | * @return number of bytes sent, GNUNET_SYSERR on error |
309 | */ | 364 | */ |
310 | ssize_t | 365 | ssize_t |
311 | GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle * desc, | 366 | GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle * desc, |
312 | const void *message, size_t length, int flags, | 367 | const void *message, size_t length, |
313 | const struct sockaddr * dest_addr, | 368 | const struct sockaddr * dest_addr, |
314 | socklen_t dest_len) | 369 | socklen_t dest_len) |
315 | { | 370 | { |
316 | int ret; | 371 | int ret; |
372 | int flags; | ||
317 | 373 | ||
374 | flags = 0; | ||
375 | #ifdef MSG_DONTWAIT | ||
376 | flags |= MSG_DONTWAIT; | ||
377 | #endif | ||
378 | #ifdef MSG_NOSIGNAL | ||
379 | flags |= MSG_NOSIGNAL; | ||
380 | #endif | ||
318 | ret = sendto (desc->fd, message, length, flags, dest_addr, dest_len); | 381 | ret = sendto (desc->fd, message, length, flags, dest_addr, dest_len); |
319 | #ifdef MINGW | 382 | #ifdef MINGW |
320 | if (SOCKET_ERROR == ret) | 383 | if (SOCKET_ERROR == ret) |
@@ -350,15 +413,20 @@ GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, | |||
350 | return ret == 0 ? GNUNET_OK : GNUNET_SYSERR; | 413 | return ret == 0 ? GNUNET_OK : GNUNET_SYSERR; |
351 | } | 414 | } |
352 | 415 | ||
416 | |||
417 | |||
353 | /** | 418 | /** |
354 | * Create a new socket | 419 | * Create a new socket. Configure it for non-blocking IO and |
420 | * mark it as non-inheritable to child processes (set the | ||
421 | * close-on-exec flag). | ||
422 | * | ||
355 | * @param domain domain of the socket | 423 | * @param domain domain of the socket |
356 | * @param type socket type | 424 | * @param type socket type |
357 | * @param protocol network protocol | 425 | * @param protocol network protocol |
358 | * @return new socket, NULL on error | 426 | * @return new socket, NULL on error |
359 | */ | 427 | */ |
360 | struct GNUNET_NETWORK_Handle * | 428 | struct GNUNET_NETWORK_Handle * |
361 | GNUNET_NETWORK_socket_socket (int domain, int type, int protocol) | 429 | GNUNET_NETWORK_socket_create (int domain, int type, int protocol) |
362 | { | 430 | { |
363 | struct GNUNET_NETWORK_Handle *ret; | 431 | struct GNUNET_NETWORK_Handle *ret; |
364 | 432 | ||
@@ -381,6 +449,20 @@ GNUNET_NETWORK_socket_socket (int domain, int type, int protocol) | |||
381 | return NULL; | 449 | return NULL; |
382 | } | 450 | } |
383 | #endif | 451 | #endif |
452 | |||
453 | if (GNUNET_SYSERR == socket_set_blocking (ret, GNUNET_NO)) | ||
454 | { | ||
455 | /* we might want to treat this one as fatal... */ | ||
456 | GNUNET_break (0); | ||
457 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret)); | ||
458 | return NULL; | ||
459 | } | ||
460 | #ifndef MINGW | ||
461 | if (GNUNET_OK != socket_set_inheritable (ret)) | ||
462 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
463 | "socket_set_inheritable"); | ||
464 | #endif | ||
465 | |||
384 | return ret; | 466 | return ret; |
385 | } | 467 | } |
386 | 468 | ||
@@ -405,31 +487,6 @@ GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, | |||
405 | return ret == 0 ? GNUNET_OK : GNUNET_SYSERR; | 487 | return ret == 0 ? GNUNET_OK : GNUNET_SYSERR; |
406 | } | 488 | } |
407 | 489 | ||
408 | /** | ||
409 | * Make a non-inheritable to child processes | ||
410 | * | ||
411 | * @param h the socket to make non-inheritable | ||
412 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | ||
413 | * @warning Not implemented on Windows | ||
414 | */ | ||
415 | int | ||
416 | GNUNET_NETWORK_socket_set_inheritable (const struct GNUNET_NETWORK_Handle | ||
417 | *h) | ||
418 | { | ||
419 | #ifdef MINGW | ||
420 | errno = ENOSYS; | ||
421 | return GNUNET_SYSERR; | ||
422 | #else | ||
423 | int i; | ||
424 | |||
425 | i = fcntl (h->fd, F_GETFD); | ||
426 | if (i == (i | FD_CLOEXEC)) | ||
427 | return GNUNET_OK; | ||
428 | return (fcntl (h->fd, F_SETFD, i | FD_CLOEXEC) == 0) | ||
429 | ? GNUNET_OK : GNUNET_SYSERR; | ||
430 | #endif | ||
431 | } | ||
432 | |||
433 | 490 | ||
434 | /** | 491 | /** |
435 | * Reset FD set | 492 | * Reset FD set |
diff --git a/src/util/server.c b/src/util/server.c index 7214b1939..646299718 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -382,17 +382,12 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) | |||
382 | GNUNET_break (0); | 382 | GNUNET_break (0); |
383 | return NULL; | 383 | return NULL; |
384 | } | 384 | } |
385 | sock = GNUNET_NETWORK_socket_socket (serverAddr->sa_family, SOCK_STREAM, 0); | 385 | sock = GNUNET_NETWORK_socket_create (serverAddr->sa_family, SOCK_STREAM, 0); |
386 | if (NULL == sock) | 386 | if (NULL == sock) |
387 | { | 387 | { |
388 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 388 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
389 | return NULL; | 389 | return NULL; |
390 | } | 390 | } |
391 | #ifndef MINGW | ||
392 | if (GNUNET_OK != GNUNET_NETWORK_socket_set_inheritable (sock)) | ||
393 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
394 | "fcntl"); | ||
395 | #endif | ||
396 | if (GNUNET_NETWORK_socket_setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 391 | if (GNUNET_NETWORK_socket_setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
397 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 392 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
398 | "setsockopt"); | 393 | "setsockopt"); |
diff --git a/src/util/service.c b/src/util/service.c index 36a1f05b1..ee15da268 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -815,7 +815,7 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) | |||
815 | if (!disablev6) | 815 | if (!disablev6) |
816 | { | 816 | { |
817 | /* probe IPv6 support */ | 817 | /* probe IPv6 support */ |
818 | desc = GNUNET_NETWORK_socket_socket (PF_INET6, SOCK_STREAM, 0); | 818 | desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); |
819 | if (NULL == desc) | 819 | if (NULL == desc) |
820 | { | 820 | { |
821 | if ((errno == ENOBUFS) || | 821 | if ((errno == ENOBUFS) || |
diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 549b3b840..30eee76ce 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c | |||
@@ -62,7 +62,7 @@ open_listen_socket () | |||
62 | #endif | 62 | #endif |
63 | sa.sin_port = htons (PORT); | 63 | sa.sin_port = htons (PORT); |
64 | sa.sin_family = AF_INET; | 64 | sa.sin_family = AF_INET; |
65 | desc = GNUNET_NETWORK_socket_socket (AF_INET, SOCK_STREAM, 0); | 65 | desc = GNUNET_NETWORK_socket_create (AF_INET, SOCK_STREAM, 0); |
66 | GNUNET_assert (desc != NULL); | 66 | GNUNET_assert (desc != NULL); |
67 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 67 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
68 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 68 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index ce44e6acf..f37352c67 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c | |||
@@ -61,7 +61,7 @@ open_listen_socket () | |||
61 | sa.sin_len = sizeof (sa); | 61 | sa.sin_len = sizeof (sa); |
62 | #endif | 62 | #endif |
63 | sa.sin_port = htons (PORT); | 63 | sa.sin_port = htons (PORT); |
64 | desc = GNUNET_NETWORK_socket_socket (AF_INET, SOCK_STREAM, 0); | 64 | desc = GNUNET_NETWORK_socket_create (AF_INET, SOCK_STREAM, 0); |
65 | GNUNET_assert (desc != 0); | 65 | GNUNET_assert (desc != 0); |
66 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 66 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
67 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 67 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index 6434228f7..e985bf935 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c | |||
@@ -60,7 +60,7 @@ open_listen_socket () | |||
60 | sa.sin_len = sizeof (sa); | 60 | sa.sin_len = sizeof (sa); |
61 | #endif | 61 | #endif |
62 | sa.sin_port = htons (PORT); | 62 | sa.sin_port = htons (PORT); |
63 | desc = GNUNET_NETWORK_socket_socket (AF_INET, SOCK_STREAM, 0); | 63 | desc = GNUNET_NETWORK_socket_create (AF_INET, SOCK_STREAM, 0); |
64 | GNUNET_assert (desc != NULL); | 64 | GNUNET_assert (desc != NULL); |
65 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 65 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
66 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 66 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index 73433e434..5968f797f 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c | |||
@@ -57,7 +57,7 @@ open_listen_socket () | |||
57 | sa.sin_len = sizeof (sa); | 57 | sa.sin_len = sizeof (sa); |
58 | #endif | 58 | #endif |
59 | sa.sin_port = htons (PORT); | 59 | sa.sin_port = htons (PORT); |
60 | desc = GNUNET_NETWORK_socket_socket (AF_INET, SOCK_STREAM, 0); | 60 | desc = GNUNET_NETWORK_socket_create (AF_INET, SOCK_STREAM, 0); |
61 | GNUNET_assert (desc != NULL); | 61 | GNUNET_assert (desc != NULL); |
62 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 62 | if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
63 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 63 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
diff --git a/src/util/test_service.c b/src/util/test_service.c index e9070a912..f615b0cf9 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -311,7 +311,7 @@ main (int argc, char *argv[]) | |||
311 | NULL); | 311 | NULL); |
312 | ret += check (); | 312 | ret += check (); |
313 | ret += check (); | 313 | ret += check (); |
314 | s = GNUNET_NETWORK_socket_socket (PF_INET6, SOCK_STREAM, 0); | 314 | s = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); |
315 | if (NULL == s) | 315 | if (NULL == s) |
316 | { | 316 | { |
317 | if ((errno == ENOBUFS) || | 317 | if ((errno == ENOBUFS) || |