aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-09 18:27:14 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-09 18:27:14 +0000
commit28095476f5a76b9483e3ecc9b9a3ab7ddd4ff54b (patch)
tree85164809fc0ff8e2991afa884e6d70e3b21b0b84
parent90e14ff7321d203797540017756ab68ccfd685cd (diff)
downloadgnunet-28095476f5a76b9483e3ecc9b9a3ab7ddd4ff54b.tar.gz
gnunet-28095476f5a76b9483e3ecc9b9a3ab7ddd4ff54b.zip
-fixing #2329
-rw-r--r--src/util/server.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/util/server.c b/src/util/server.c
index 0dd100ab7..fab68d46a 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -1252,6 +1252,25 @@ GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server,
1252 1252
1253 1253
1254/** 1254/**
1255 * Destroy the connection that is passed in via 'cls'. Used
1256 * as calling 'GNUNET_CONNECTION_destroy' from within a function
1257 * that was itself called from within 'process_notify' of
1258 * 'connection.c' is not allowed (see #2329).
1259 *
1260 * @param cls connection to destroy
1261 * @param tc scheduler context (unused)
1262 */
1263static void
1264destroy_connection (void *cls,
1265 const struct GNUNET_SCHEDULER_TaskContext *tc)
1266{
1267 struct GNUNET_CONNECTION_Handle *connection = cls;
1268
1269 GNUNET_CONNECTION_destroy (connection);
1270}
1271
1272
1273/**
1255 * Ask the server to disconnect from the given client. 1274 * Ask the server to disconnect from the given client.
1256 * This is the same as returning GNUNET_SYSERR from a message 1275 * This is the same as returning GNUNET_SYSERR from a message
1257 * handler, except that it allows dropping of a client even 1276 * handler, except that it allows dropping of a client even
@@ -1338,7 +1357,8 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client)
1338 GNUNET_CONNECTION_persist_ (client->connection); 1357 GNUNET_CONNECTION_persist_ (client->connection);
1339 if (NULL != client->th.cth) 1358 if (NULL != client->th.cth)
1340 GNUNET_SERVER_notify_transmit_ready_cancel (&client->th); 1359 GNUNET_SERVER_notify_transmit_ready_cancel (&client->th);
1341 GNUNET_CONNECTION_destroy (client->connection); 1360 (void) GNUNET_SCHEDULER_add_now (&destroy_connection,
1361 client->connection);
1342 GNUNET_free (client); 1362 GNUNET_free (client);
1343 /* we might be in soft-shutdown, test if we're done */ 1363 /* we might be in soft-shutdown, test if we're done */
1344 if (NULL != server) 1364 if (NULL != server)
@@ -1375,14 +1395,12 @@ transmit_ready_callback_wrapper (void *cls, size_t size, void *buf)
1375{ 1395{
1376 struct GNUNET_SERVER_Client *client = cls; 1396 struct GNUNET_SERVER_Client *client = cls;
1377 GNUNET_CONNECTION_TransmitReadyNotify callback; 1397 GNUNET_CONNECTION_TransmitReadyNotify callback;
1378 size_t ret;
1379 1398
1380 client->th.cth = NULL; 1399 client->th.cth = NULL;
1381 callback = client->th.callback; 1400 callback = client->th.callback;
1382 client->th.callback = NULL; 1401 client->th.callback = NULL;
1383 client->last_activity = GNUNET_TIME_absolute_get (); 1402 client->last_activity = GNUNET_TIME_absolute_get ();
1384 ret = callback (client->th.callback_cls, size, buf); 1403 return callback (client->th.callback_cls, size, buf);
1385 return ret;
1386} 1404}
1387 1405
1388 1406