From 2d2a68721a463882c84ccca446899be94a31c56b Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Sat, 13 Jul 2013 01:32:57 +0000 Subject: [PATCH] - connect_notify is also called with NULL on server shutdown --- src/include/gnunet_server_lib.h | 6 +++++- src/mesh/gnunet-service-mesh.c | 2 ++ src/util/server.c | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h index c8138cd55..2c64b4698 100644 --- a/src/include/gnunet_server_lib.h +++ b/src/include/gnunet_server_lib.h @@ -476,7 +476,11 @@ GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server, /** * Ask the server to notify us whenever a client connects. * This function is called whenever the actual network connection - * is opened. + * is opened. If the server is destroyed before this + * notification is explicitly cancelled, the 'callback' will + * once be called with a 'client' argument of NULL to indicate + * that the server itself is now gone (and that the callback + * won't be called anymore and also can no longer be cancelled). * * @param server the server manageing the clients * @param callback function to call on sconnect diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 169d3ce63..d07703a7f 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -4405,6 +4405,8 @@ handle_local_client_connect (void *cls, struct GNUNET_SERVER_Client *client) { struct MeshClient *c; + if (NULL == client) + return; c = GNUNET_malloc (sizeof (struct MeshClient)); c->handle = client; GNUNET_SERVER_client_keep (client); diff --git a/src/util/server.c b/src/util/server.c index 6dbb5dc23..46410e90e 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -1342,7 +1342,11 @@ GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server, /** * Ask the server to notify us whenever a client connects. * This function is called whenever the actual network connection - * is opened. + * is opened. If the server is destroyed before this + * notification is explicitly cancelled, the 'callback' will + * once be called with a 'client' argument of NULL to indicate + * that the server itself is now gone (and that the callback + * won't be called anymore and also can no longer be cancelled). * * @param server the server manageing the clients * @param callback function to call on sconnect -- 2.25.1