aboutsummaryrefslogtreecommitdiff
path: root/src/util/server.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-24 08:34:28 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-24 08:34:28 +0000
commit648fcca1e3e1e1b1c60d1aab353016b21e7ae81b (patch)
tree3505d69a3cec3b846e4d899802388fe94dc1749c /src/util/server.c
parentd8b4c75703a974e5f7bdf39f77fc91d1f70d43bb (diff)
downloadgnunet-648fcca1e3e1e1b1c60d1aab353016b21e7ae81b.tar.gz
gnunet-648fcca1e3e1e1b1c60d1aab353016b21e7ae81b.zip
-formatting, doxygen
Diffstat (limited to 'src/util/server.c')
-rw-r--r--src/util/server.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/src/util/server.c b/src/util/server.c
index 11c6021c5..9e88992ca 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -174,10 +174,10 @@ struct GNUNET_SERVER_Handle
174 int require_found; 174 int require_found;
175 175
176 /** 176 /**
177 * Set to GNUNET_YES once we are in 'soft' shutdown where we wait for 177 * Set to #GNUNET_YES once we are in 'soft' shutdown where we wait for
178 * all non-monitor clients to disconnect before we call 178 * all non-monitor clients to disconnect before we call
179 * GNUNET_SERVER_destroy. See 'test_monitor_clients'. Set to 179 * #GNUNET_SERVER_destroy. See 'test_monitor_clients'. Set to
180 * GNUNET_SYSERR once the final destroy task has been scheduled 180 * #GNUNET_SYSERR once the final destroy task has been scheduled
181 * (we cannot run it in the same task). 181 * (we cannot run it in the same task).
182 */ 182 */
183 int in_soft_shutdown; 183 int in_soft_shutdown;
@@ -195,7 +195,7 @@ struct GNUNET_SERVER_TransmitHandle
195 GNUNET_CONNECTION_TransmitReadyNotify callback; 195 GNUNET_CONNECTION_TransmitReadyNotify callback;
196 196
197 /** 197 /**
198 * Closure for 'callback' 198 * Closure for @e callback
199 */ 199 */
200 void *callback_cls; 200 void *callback_cls;
201 201
@@ -250,7 +250,7 @@ struct GNUNET_SERVER_Client
250 GNUNET_SCHEDULER_TaskIdentifier restart_task; 250 GNUNET_SCHEDULER_TaskIdentifier restart_task;
251 251
252 /** 252 /**
253 * Task that warns about missing calls to 'GNUNET_SERVER_receive_done'. 253 * Task that warns about missing calls to #GNUNET_SERVER_receive_done.
254 */ 254 */
255 GNUNET_SCHEDULER_TaskIdentifier warn_task; 255 GNUNET_SCHEDULER_TaskIdentifier warn_task;
256 256
@@ -267,7 +267,7 @@ struct GNUNET_SERVER_Client
267 267
268 /** 268 /**
269 * Transmission handle we return for this client from 269 * Transmission handle we return for this client from
270 * GNUNET_SERVER_notify_transmit_ready. 270 * #GNUNET_SERVER_notify_transmit_ready.
271 */ 271 */
272 struct GNUNET_SERVER_TransmitHandle th; 272 struct GNUNET_SERVER_TransmitHandle th;
273 273
@@ -313,8 +313,9 @@ struct GNUNET_SERVER_Client
313 int shutdown_now; 313 int shutdown_now;
314 314
315 /** 315 /**
316 * Are we currently trying to receive? (YES if we are, NO if we are not, 316 * Are we currently trying to receive? (#GNUNET_YES if we are,
317 * SYSERR if data is already available in MST). 317 * #GNUNET_NO if we are not, #GNUNET_SYSERR if data is already
318 * available in MST).
318 */ 319 */
319 int receive_pending; 320 int receive_pending;
320 321
@@ -328,7 +329,7 @@ struct GNUNET_SERVER_Client
328 /** 329 /**
329 * Is this client a 'monitor' client that should not be counted 330 * Is this client a 'monitor' client that should not be counted
330 * when deciding on destroying the server during soft shutdown? 331 * when deciding on destroying the server during soft shutdown?
331 * (see also GNUNET_SERVICE_start) 332 * (see also #GNUNET_SERVICE_start)
332 */ 333 */
333 int is_monitor; 334 int is_monitor;
334 335
@@ -858,7 +859,7 @@ GNUNET_SERVER_add_handlers (struct GNUNET_SERVER_Handle *server,
858 * @param create new tokenizer initialization function 859 * @param create new tokenizer initialization function
859 * @param destroy new tokenizer destruction function 860 * @param destroy new tokenizer destruction function
860 * @param receive new tokenizer receive function 861 * @param receive new tokenizer receive function
861 * @param cls closure for 'create', 'receive', 'destroy' 862 * @param cls closure for @a create, @a receive, @a destroy
862 */ 863 */
863void 864void
864GNUNET_SERVER_set_callbacks (struct GNUNET_SERVER_Handle *server, 865GNUNET_SERVER_set_callbacks (struct GNUNET_SERVER_Handle *server,
@@ -875,13 +876,14 @@ GNUNET_SERVER_set_callbacks (struct GNUNET_SERVER_Handle *server,
875 876
876 877
877/** 878/**
878 * Task run to warn about missing calls to 'GNUNET_SERVER_receive_done'. 879 * Task run to warn about missing calls to #GNUNET_SERVER_receive_done.
879 * 880 *
880 * @param cls our 'struct GNUNET_SERVER_Client*' to process more requests from 881 * @param cls our `struct GNUNET_SERVER_Client *` to process more requests from
881 * @param tc scheduler context (unused) 882 * @param tc scheduler context (unused)
882 */ 883 */
883static void 884static void
884warn_no_receive_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 885warn_no_receive_done (void *cls,
886 const struct GNUNET_SCHEDULER_TaskContext *tc)
885{ 887{
886 struct GNUNET_SERVER_Client *client = cls; 888 struct GNUNET_SERVER_Client *client = cls;
887 889
@@ -1023,11 +1025,11 @@ process_incoming (void *cls, const void *buf, size_t available,
1023 * or shutdown. 1025 * or shutdown.
1024 * 1026 *
1025 * @param client the client to process, RC must have already been increased 1027 * @param client the client to process, RC must have already been increased
1026 * using GNUNET_SERVER_client_keep and will be decreased by one in this 1028 * using #GNUNET_SERVER_client_keep and will be decreased by one in this
1027 * function 1029 * function
1028 * @param ret GNUNET_NO to start processing from the buffer, 1030 * @param ret #GNUNET_NO to start processing from the buffer,
1029 * GNUNET_OK if the mst buffer is drained and we should instantly go back to receiving 1031 * #GNUNET_OK if the mst buffer is drained and we should instantly go back to receiving
1030 * GNUNET_SYSERR if we should instantly abort due to error in a previous step 1032 * #GNUNET_SYSERR if we should instantly abort due to error in a previous step
1031 */ 1033 */
1032static void 1034static void
1033process_mst (struct GNUNET_SERVER_Client *client, int ret) 1035process_mst (struct GNUNET_SERVER_Client *client, int ret)
@@ -1060,14 +1062,17 @@ process_mst (struct GNUNET_SERVER_Client *client, int ret)
1060 } 1062 }
1061 LOG (GNUNET_ERROR_TYPE_DEBUG, 1063 LOG (GNUNET_ERROR_TYPE_DEBUG,
1062 "Server leaves instant processing loop: ret = %d, server = %p, shutdown = %d, suspended = %u\n", 1064 "Server leaves instant processing loop: ret = %d, server = %p, shutdown = %d, suspended = %u\n",
1063 ret, client->server, client->shutdown_now, client->suspended); 1065 ret, client->server,
1066 client->shutdown_now,
1067 client->suspended);
1064 if (GNUNET_NO == ret) 1068 if (GNUNET_NO == ret)
1065 { 1069 {
1066 LOG (GNUNET_ERROR_TYPE_DEBUG, 1070 LOG (GNUNET_ERROR_TYPE_DEBUG,
1067 "Server has more data pending but is suspended.\n"); 1071 "Server has more data pending but is suspended.\n");
1068 client->receive_pending = GNUNET_SYSERR; /* data pending */ 1072 client->receive_pending = GNUNET_SYSERR; /* data pending */
1069 } 1073 }
1070 if ((GNUNET_SYSERR == ret) || (GNUNET_YES == client->shutdown_now)) 1074 if ( (GNUNET_SYSERR == ret) ||
1075 (GNUNET_YES == client->shutdown_now) )
1071 GNUNET_SERVER_client_disconnect (client); 1076 GNUNET_SERVER_client_disconnect (client);
1072} 1077}
1073 1078
@@ -1187,7 +1192,7 @@ restart_processing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1187 * @param client identification of the client (struct GNUNET_SERVER_Client*) 1192 * @param client identification of the client (struct GNUNET_SERVER_Client*)
1188 * @param message the actual message 1193 * @param message the actual message
1189 * 1194 *
1190 * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing 1195 * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
1191 */ 1196 */
1192static int 1197static int
1193client_message_tokenizer_callback (void *cls, void *client, 1198client_message_tokenizer_callback (void *cls, void *client,
@@ -1330,7 +1335,7 @@ GNUNET_SERVER_client_get_address (struct GNUNET_SERVER_Client *client,
1330 * 1335 *
1331 * @param server the server manageing the clients 1336 * @param server the server manageing the clients
1332 * @param callback function to call on disconnect 1337 * @param callback function to call on disconnect
1333 * @param callback_cls closure for callback 1338 * @param callback_cls closure for @a callback
1334 */ 1339 */
1335void 1340void
1336GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server, 1341GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server,
@@ -1339,7 +1344,7 @@ GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server,
1339{ 1344{
1340 struct NotifyList *n; 1345 struct NotifyList *n;
1341 1346
1342 n = GNUNET_malloc (sizeof (struct NotifyList)); 1347 n = GNUNET_new (struct NotifyList);
1343 n->callback = callback; 1348 n->callback = callback;
1344 n->callback_cls = callback_cls; 1349 n->callback_cls = callback_cls;
1345 GNUNET_CONTAINER_DLL_insert (server->disconnect_notify_list_head, 1350 GNUNET_CONTAINER_DLL_insert (server->disconnect_notify_list_head,
@@ -1359,15 +1364,16 @@ GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server,
1359 * 1364 *
1360 * @param server the server manageing the clients 1365 * @param server the server manageing the clients
1361 * @param callback function to call on sconnect 1366 * @param callback function to call on sconnect
1362 * @param callback_cls closure for callback 1367 * @param callback_cls closure for @a callback
1363 */ 1368 */
1364void 1369void
1365GNUNET_SERVER_connect_notify (struct GNUNET_SERVER_Handle *server, 1370GNUNET_SERVER_connect_notify (struct GNUNET_SERVER_Handle *server,
1366 GNUNET_SERVER_ConnectCallback callback, void *callback_cls) 1371 GNUNET_SERVER_ConnectCallback callback,
1372 void *callback_cls)
1367{ 1373{
1368 struct NotifyList *n; 1374 struct NotifyList *n;
1369 1375
1370 n = GNUNET_malloc (sizeof (struct NotifyList)); 1376 n = GNUNET_new (struct NotifyList);
1371 n->callback = callback; 1377 n->callback = callback;
1372 n->callback_cls = callback_cls; 1378 n->callback_cls = callback_cls;
1373 GNUNET_CONTAINER_DLL_insert (server->connect_notify_list_head, 1379 GNUNET_CONTAINER_DLL_insert (server->connect_notify_list_head,
@@ -1381,7 +1387,7 @@ GNUNET_SERVER_connect_notify (struct GNUNET_SERVER_Handle *server,
1381 * 1387 *
1382 * @param server the server manageing the clients 1388 * @param server the server manageing the clients
1383 * @param callback function to call on connect 1389 * @param callback function to call on connect
1384 * @param callback_cls closure for callback 1390 * @param callback_cls closure for @a callback
1385 */ 1391 */
1386void 1392void
1387GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server, 1393GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server,
@@ -1410,11 +1416,12 @@ GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server,
1410 * 1416 *
1411 * @param server the server manageing the clients 1417 * @param server the server manageing the clients
1412 * @param callback function to call on disconnect 1418 * @param callback function to call on disconnect
1413 * @param callback_cls closure for callback 1419 * @param callback_cls closure for @a callback
1414 */ 1420 */
1415void 1421void
1416GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server, 1422GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server,
1417 GNUNET_SERVER_ConnectCallback callback, void *callback_cls) 1423 GNUNET_SERVER_ConnectCallback callback,
1424 void *callback_cls)
1418{ 1425{
1419 struct NotifyList *pos; 1426 struct NotifyList *pos;
1420 1427
@@ -1434,8 +1441,8 @@ GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server,
1434 1441
1435 1442
1436/** 1443/**
1437 * Destroy the connection that is passed in via 'cls'. Used 1444 * Destroy the connection that is passed in via @a cls. Used
1438 * as calling 'GNUNET_CONNECTION_destroy' from within a function 1445 * as calling #GNUNET_CONNECTION_destroy from within a function
1439 * that was itself called from within 'process_notify' of 1446 * that was itself called from within 'process_notify' of
1440 * 'connection.c' is not allowed (see #2329). 1447 * 'connection.c' is not allowed (see #2329).
1441 * 1448 *
@@ -1454,7 +1461,7 @@ destroy_connection (void *cls,
1454 1461
1455/** 1462/**
1456 * Ask the server to disconnect from the given client. 1463 * Ask the server to disconnect from the given client.
1457 * This is the same as returning GNUNET_SYSERR from a message 1464 * This is the same as returning #GNUNET_SYSERR from a message
1458 * handler, except that it allows dropping of a client even 1465 * handler, except that it allows dropping of a client even
1459 * when not handling a message from that client. 1466 * when not handling a message from that client.
1460 * 1467 *
@@ -1585,10 +1592,10 @@ transmit_ready_callback_wrapper (void *cls, size_t size, void *buf)
1585 * @param timeout after how long should we give up (and call 1592 * @param timeout after how long should we give up (and call
1586 * notify with buf NULL and size 0)? 1593 * notify with buf NULL and size 0)?
1587 * @param callback function to call when space is available 1594 * @param callback function to call when space is available
1588 * @param callback_cls closure for callback 1595 * @param callback_cls closure for @a callback
1589 * @return non-NULL if the notify callback was queued; can be used 1596 * @return non-NULL if the notify callback was queued; can be used
1590 * to cancel the request using 1597 * to cancel the request using
1591 * GNUNET_SERVER_notify_transmit_ready_cancel. 1598 * #GNUNET_SERVER_notify_transmit_ready_cancel.
1592 * NULL if we are already going to notify someone else (busy) 1599 * NULL if we are already going to notify someone else (busy)
1593 */ 1600 */
1594struct GNUNET_SERVER_TransmitHandle * 1601struct GNUNET_SERVER_TransmitHandle *
@@ -1643,14 +1650,15 @@ GNUNET_SERVER_client_persist_ (struct GNUNET_SERVER_Client *client)
1643 * GNUNET_SERVER_MessageCallback (or its respective continuations). 1650 * GNUNET_SERVER_MessageCallback (or its respective continuations).
1644 * 1651 *
1645 * @param client client we were processing a message of 1652 * @param client client we were processing a message of
1646 * @param success GNUNET_OK to keep the connection open and 1653 * @param success #GNUNET_OK to keep the connection open and
1647 * continue to receive 1654 * continue to receive
1648 * GNUNET_NO to close the connection (normal behavior) 1655 * #GNUNET_NO to close the connection (normal behavior)
1649 * GNUNET_SYSERR to close the connection (signal 1656 * #GNUNET_SYSERR to close the connection (signal
1650 * serious error) 1657 * serious error)
1651 */ 1658 */
1652void 1659void
1653GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int success) 1660GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client,
1661 int success)
1654{ 1662{
1655 if (NULL == client) 1663 if (NULL == client)
1656 return; 1664 return;