aboutsummaryrefslogtreecommitdiff
path: root/src/util/server.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-21 20:43:27 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-21 20:43:27 +0000
commita76817c408f2d8cf3b0b8619ff38f163ee882be6 (patch)
tree0ea324b5ba2ce030ef78395003ef7f54281f3731 /src/util/server.c
parent8b4685c894e24dbd9fed9457b4eec9045a0994ed (diff)
downloadgnunet-a76817c408f2d8cf3b0b8619ff38f163ee882be6.tar.gz
gnunet-a76817c408f2d8cf3b0b8619ff38f163ee882be6.zip
fix TCP plugin RC issue (#3687) by changing util API (!)
Diffstat (limited to 'src/util/server.c')
-rw-r--r--src/util/server.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/util/server.c b/src/util/server.c
index 279b65792..32ef22efd 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -397,7 +397,6 @@ process_listen_socket (void *cls,
397{ 397{
398 struct GNUNET_SERVER_Handle *server = cls; 398 struct GNUNET_SERVER_Handle *server = cls;
399 struct GNUNET_CONNECTION_Handle *sock; 399 struct GNUNET_CONNECTION_Handle *sock;
400 struct GNUNET_SERVER_Client *client;
401 unsigned int i; 400 unsigned int i;
402 401
403 server->listen_task = NULL; 402 server->listen_task = NULL;
@@ -420,9 +419,8 @@ process_listen_socket (void *cls,
420 { 419 {
421 LOG (GNUNET_ERROR_TYPE_DEBUG, 420 LOG (GNUNET_ERROR_TYPE_DEBUG,
422 "Server accepted incoming connection.\n"); 421 "Server accepted incoming connection.\n");
423 client = GNUNET_SERVER_connect_socket (server, sock); 422 (void) GNUNET_SERVER_connect_socket (server,
424 /* decrement reference count, we don't keep "client" alive */ 423 sock);
425 GNUNET_SERVER_client_drop (client);
426 } 424 }
427 } 425 }
428 i++; 426 i++;
@@ -1235,13 +1233,14 @@ restart_processing (void *cls,
1235 * received a complete message. 1233 * received a complete message.
1236 * 1234 *
1237 * @param cls closure (struct GNUNET_SERVER_Handle) 1235 * @param cls closure (struct GNUNET_SERVER_Handle)
1238 * @param client identification of the client (struct GNUNET_SERVER_Client*) 1236 * @param client identification of the client (`struct GNUNET_SERVER_Client *`)
1239 * @param message the actual message 1237 * @param message the actual message
1240 * 1238 *
1241 * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing 1239 * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
1242 */ 1240 */
1243static int 1241static int
1244client_message_tokenizer_callback (void *cls, void *client, 1242client_message_tokenizer_callback (void *cls,
1243 void *client,
1245 const struct GNUNET_MessageHeader *message) 1244 const struct GNUNET_MessageHeader *message)
1246{ 1245{
1247 struct GNUNET_SERVER_Handle *server = cls; 1246 struct GNUNET_SERVER_Handle *server = cls;
@@ -1272,8 +1271,7 @@ client_message_tokenizer_callback (void *cls, void *client,
1272 * @param server the server to use 1271 * @param server the server to use
1273 * @param connection the connection to manage (client must 1272 * @param connection the connection to manage (client must
1274 * stop using this connection from now on) 1273 * stop using this connection from now on)
1275 * @return the client handle (client should call 1274 * @return the client handle
1276 * "client_drop" on the return value eventually)
1277 */ 1275 */
1278struct GNUNET_SERVER_Client * 1276struct GNUNET_SERVER_Client *
1279GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server, 1277GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server,
@@ -1284,7 +1282,6 @@ GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server,
1284 1282
1285 client = GNUNET_new (struct GNUNET_SERVER_Client); 1283 client = GNUNET_new (struct GNUNET_SERVER_Client);
1286 client->connection = connection; 1284 client->connection = connection;
1287 client->reference_count = 1;
1288 client->server = server; 1285 client->server = server;
1289 client->last_activity = GNUNET_TIME_absolute_get (); 1286 client->last_activity = GNUNET_TIME_absolute_get ();
1290 client->idle_timeout = server->idle_timeout; 1287 client->idle_timeout = server->idle_timeout;
@@ -1491,7 +1488,7 @@ GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server,
1491/** 1488/**
1492 * Destroy the connection that is passed in via @a cls. Used 1489 * Destroy the connection that is passed in via @a cls. Used
1493 * as calling #GNUNET_CONNECTION_destroy from within a function 1490 * as calling #GNUNET_CONNECTION_destroy from within a function
1494 * that was itself called from within 'process_notify' of 1491 * that was itself called from within process_notify() of
1495 * 'connection.c' is not allowed (see #2329). 1492 * 'connection.c' is not allowed (see #2329).
1496 * 1493 *
1497 * @param cls connection to destroy 1494 * @param cls connection to destroy
@@ -1547,27 +1544,34 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client)
1547 server->clients_tail, 1544 server->clients_tail,
1548 client); 1545 client);
1549 if (NULL != server->mst_destroy) 1546 if (NULL != server->mst_destroy)
1550 server->mst_destroy (server->mst_cls, client->mst); 1547 server->mst_destroy (server->mst_cls,
1548 client->mst);
1551 else 1549 else
1552 GNUNET_SERVER_mst_destroy (client->mst); 1550 GNUNET_SERVER_mst_destroy (client->mst);
1553 client->mst = NULL; 1551 client->mst = NULL;
1554 for (n = server->disconnect_notify_list_head; NULL != n; n = n->next) 1552 for (n = server->disconnect_notify_list_head; NULL != n; n = n->next)
1555 n->callback (n->callback_cls, client); 1553 n->callback (n->callback_cls,
1554 client);
1556 } 1555 }
1557 client->reference_count--; 1556 client->reference_count--;
1558 if (client->reference_count > 0) 1557 if (client->reference_count > 0)
1559 { 1558 {
1560 LOG (GNUNET_ERROR_TYPE_DEBUG, 1559 LOG (GNUNET_ERROR_TYPE_DEBUG,
1561 "RC still positive, not destroying everything.\n"); 1560 "RC of %p still positive, not destroying everything.\n",
1561 client);
1562 client->server = NULL; 1562 client->server = NULL;
1563 return; 1563 return;
1564 } 1564 }
1565 if (GNUNET_YES == client->in_process_client_buffer) 1565 if (GNUNET_YES == client->in_process_client_buffer)
1566 { 1566 {
1567 LOG (GNUNET_ERROR_TYPE_DEBUG, 1567 LOG (GNUNET_ERROR_TYPE_DEBUG,
1568 "Still processing inputs, not destroying everything.\n"); 1568 "Still processing inputs of %p, not destroying everything.\n",
1569 client);
1569 return; 1570 return;
1570 } 1571 }
1572 LOG (GNUNET_ERROR_TYPE_DEBUG,
1573 "RC of %p now zero, destroying everything.\n",
1574 client);
1571 if (GNUNET_YES == client->persist) 1575 if (GNUNET_YES == client->persist)
1572 GNUNET_CONNECTION_persist_ (client->connection); 1576 GNUNET_CONNECTION_persist_ (client->connection);
1573 if (NULL != client->th.cth) 1577 if (NULL != client->th.cth)