aboutsummaryrefslogtreecommitdiff
path: root/src/util/connection.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-05-06 09:59:08 +0000
committerNathan S. Evans <evans@in.tum.de>2010-05-06 09:59:08 +0000
commitcbf929c31e8afdd30b2ba6a6bf85c7942f9afac5 (patch)
tree160cc5e35666cca195451e909f9fa75229c05b75 /src/util/connection.c
parent998cb5efab59bfc5cdf9b324273b367fa8278c0b (diff)
downloadgnunet-cbf929c31e8afdd30b2ba6a6bf85c7942f9afac5.tar.gz
gnunet-cbf929c31e8afdd30b2ba6a6bf85c7942f9afac5.zip
arm related changes to util things, enabling leaky sockets and shutdown messages from services
Diffstat (limited to 'src/util/connection.c')
-rw-r--r--src/util/connection.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/util/connection.c b/src/util/connection.c
index 22a75691b..4a54aed1d 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -279,8 +279,27 @@ struct GNUNET_CONNECTION_Handle
279 */ 279 */
280 uint16_t port; 280 uint16_t port;
281 281
282 /**
283 * When shutdown, do not ever actually close the socket, but
284 * free resources. Only should ever be set if using program
285 * termination as a signal (because only then will the leaked
286 * socket be freed!)
287 */
288 int persist;
289
282}; 290};
283 291
292/**
293 * Set the persist option on this connection handle. Indicates
294 * that the underlying socket or fd should never really be closed.
295 * Used for indicating process death.
296 *
297 * @param sock the connection to set persistent
298 */
299void GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock)
300{
301 sock->persist = GNUNET_YES;
302}
284 303
285/** 304/**
286 * Create a socket handle by boxing an existing OS socket. The OS 305 * Create a socket handle by boxing an existing OS socket. The OS
@@ -486,7 +505,8 @@ destroy_continuation (void *cls,
486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 505 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
487 "Shutting down socket (%p)\n", sock); 506 "Shutting down socket (%p)\n", sock);
488#endif 507#endif
489 GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR); 508 if (sock->persist != GNUNET_YES)
509 GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR);
490 } 510 }
491 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) 511 if (sock->read_task != GNUNET_SCHEDULER_NO_TASK)
492 { 512 {
@@ -518,8 +538,10 @@ destroy_continuation (void *cls,
518 sock->nth.notify_ready = NULL; 538 sock->nth.notify_ready = NULL;
519 notify (sock->nth.notify_ready_cls, 0, NULL); 539 notify (sock->nth.notify_ready_cls, 0, NULL);
520 } 540 }
521 if (sock->sock != NULL) 541
542 if ((sock->sock != NULL) && (sock->persist != GNUNET_YES))
522 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock->sock)); 543 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock->sock));
544
523 GNUNET_free_non_null (sock->addr); 545 GNUNET_free_non_null (sock->addr);
524 GNUNET_free_non_null (sock->hostname); 546 GNUNET_free_non_null (sock->hostname);
525#if DEBUG_CONNECTION 547#if DEBUG_CONNECTION