aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/statistics_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-19 19:06:30 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-19 19:06:30 +0000
commit9ac941283d419e21937e63629f3e6610abab233b (patch)
treeb9db97d2b00085e47a66a5e8e8a01c97f5528213 /src/statistics/statistics_api.c
parent4715a1778070d339252b24f16d3cca9823d31781 (diff)
downloadgnunet-9ac941283d419e21937e63629f3e6610abab233b.tar.gz
gnunet-9ac941283d419e21937e63629f3e6610abab233b.zip
-doxygen, fixing #3223
Diffstat (limited to 'src/statistics/statistics_api.c')
-rw-r--r--src/statistics/statistics_api.c134
1 files changed, 82 insertions, 52 deletions
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c
index 04e85a07e..f1adcae4c 100644
--- a/src/statistics/statistics_api.c
+++ b/src/statistics/statistics_api.c
@@ -326,15 +326,11 @@ static void
326schedule_watch_request (struct GNUNET_STATISTICS_Handle *h, 326schedule_watch_request (struct GNUNET_STATISTICS_Handle *h,
327 struct GNUNET_STATISTICS_WatchEntry *watch) 327 struct GNUNET_STATISTICS_WatchEntry *watch)
328{ 328{
329
330 struct GNUNET_STATISTICS_GetHandle *ai; 329 struct GNUNET_STATISTICS_GetHandle *ai;
331 size_t slen; 330 size_t slen;
332 size_t nlen; 331 size_t nlen;
333 size_t nsize; 332 size_t nsize;
334 333
335 GNUNET_assert (NULL != h);
336 GNUNET_assert (NULL != watch);
337
338 slen = strlen (watch->subsystem) + 1; 334 slen = strlen (watch->subsystem) + 1;
339 nlen = strlen (watch->name) + 1; 335 nlen = strlen (watch->name) + 1;
340 nsize = sizeof (struct GNUNET_MessageHeader) + slen + nlen; 336 nsize = sizeof (struct GNUNET_MessageHeader) + slen + nlen;
@@ -452,11 +448,12 @@ try_connect (struct GNUNET_STATISTICS_Handle *h)
452/** 448/**
453 * We've waited long enough, reconnect now. 449 * We've waited long enough, reconnect now.
454 * 450 *
455 * @param cls the 'struct GNUNET_STATISTICS_Handle' to reconnect 451 * @param cls the `struct GNUNET_STATISTICS_Handle` to reconnect
456 * @param tc scheduler context (unused) 452 * @param tc scheduler context (unused)
457 */ 453 */
458static void 454static void
459reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 455reconnect_task (void *cls,
456 const struct GNUNET_SCHEDULER_TaskContext *tc)
460{ 457{
461 struct GNUNET_STATISTICS_Handle *h = cls; 458 struct GNUNET_STATISTICS_Handle *h = cls;
462 459
@@ -473,7 +470,7 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
473 */ 470 */
474static void 471static void
475do_destroy (void *cls, 472do_destroy (void *cls,
476 const struct GNUNET_SCHEDULER_TaskContext *tc) 473 const struct GNUNET_SCHEDULER_TaskContext *tc)
477{ 474{
478 struct GNUNET_STATISTICS_Handle *h = cls; 475 struct GNUNET_STATISTICS_Handle *h = cls;
479 476
@@ -519,11 +516,11 @@ reconnect_later (struct GNUNET_STATISTICS_Handle *h)
519 516
520 517
521/** 518/**
522 * Process a 'GNUNET_MESSAGE_TYPE_STATISTICS_VALUE' message. 519 * Process a #GNUNET_MESSAGE_TYPE_STATISTICS_VALUE message.
523 * 520 *
524 * @param h statistics handle 521 * @param h statistics handle
525 * @param msg message received from the service, never NULL 522 * @param msg message received from the service, never NULL
526 * @return GNUNET_OK if the message was well-formed 523 * @return #GNUNET_OK if the message was well-formed
527 */ 524 */
528static int 525static int
529process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, 526process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h,
@@ -536,7 +533,8 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h,
536 533
537 if (h->current->aborted) 534 if (h->current->aborted)
538 { 535 {
539 LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration was aborted, ignoring VALUE\n"); 536 LOG (GNUNET_ERROR_TYPE_DEBUG,
537 "Iteration was aborted, ignoring VALUE\n");
540 return GNUNET_OK; /* don't bother */ 538 return GNUNET_OK; /* don't bother */
541 } 539 }
542 size = ntohs (msg->size); 540 size = ntohs (msg->size);
@@ -554,8 +552,10 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h,
554 GNUNET_break (0); 552 GNUNET_break (0);
555 return GNUNET_SYSERR; 553 return GNUNET_SYSERR;
556 } 554 }
557 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received valid statistic on `%s:%s': %llu\n", 555 LOG (GNUNET_ERROR_TYPE_DEBUG,
558 service, name, GNUNET_ntohll (smsg->value)); 556 "Received valid statistic on `%s:%s': %llu\n",
557 service, name,
558 GNUNET_ntohll (smsg->value));
559 if (GNUNET_OK != 559 if (GNUNET_OK !=
560 h->current->proc (h->current->cls, service, name, 560 h->current->proc (h->current->cls, service, name,
561 GNUNET_ntohll (smsg->value), 561 GNUNET_ntohll (smsg->value),
@@ -566,7 +566,8 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h,
566 "Processing of remaining statistics aborted by client.\n"); 566 "Processing of remaining statistics aborted by client.\n");
567 h->current->aborted = GNUNET_YES; 567 h->current->aborted = GNUNET_YES;
568 } 568 }
569 LOG (GNUNET_ERROR_TYPE_DEBUG, "VALUE processed successfully\n"); 569 LOG (GNUNET_ERROR_TYPE_DEBUG,
570 "VALUE processed successfully\n");
570 return GNUNET_OK; 571 return GNUNET_OK;
571} 572}
572 573
@@ -576,8 +577,8 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h,
576 * 577 *
577 * @param h statistics handle 578 * @param h statistics handle
578 * @param msg the watch value message 579 * @param msg the watch value message
579 * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not, 580 * @return #GNUNET_OK if the message was well-formed, #GNUNET_SYSERR if not,
580 * GNUNET_NO if this watch has been cancelled 581 * #GNUNET_NO if this watch has been cancelled
581 */ 582 */
582static int 583static int
583process_watch_value (struct GNUNET_STATISTICS_Handle *h, 584process_watch_value (struct GNUNET_STATISTICS_Handle *h,
@@ -610,6 +611,12 @@ process_watch_value (struct GNUNET_STATISTICS_Handle *h,
610} 611}
611 612
612 613
614/**
615 * Task used to destroy the statistics handle.
616 *
617 * @param cls the `struct GNUNET_STATISTICS_Handle`
618 * @param tc the scheduler context
619 */
613static void 620static void
614destroy_task (void *cls, 621destroy_task (void *cls,
615 const struct GNUNET_SCHEDULER_TaskContext *tc) 622 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -627,7 +634,8 @@ destroy_task (void *cls,
627 * @param msg message received, NULL on timeout or fatal error 634 * @param msg message received, NULL on timeout or fatal error
628 */ 635 */
629static void 636static void
630receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) 637receive_stats (void *cls,
638 const struct GNUNET_MessageHeader *msg)
631{ 639{
632 struct GNUNET_STATISTICS_Handle *h = cls; 640 struct GNUNET_STATISTICS_Handle *h = cls;
633 struct GNUNET_STATISTICS_GetHandle *c; 641 struct GNUNET_STATISTICS_GetHandle *c;
@@ -657,7 +665,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg)
657 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 665 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
658 break; 666 break;
659 case GNUNET_MESSAGE_TYPE_STATISTICS_END: 667 case GNUNET_MESSAGE_TYPE_STATISTICS_END:
660 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received end of statistics marker\n"); 668 LOG (GNUNET_ERROR_TYPE_DEBUG,
669 "Received end of statistics marker\n");
661 if (NULL == (c = h->current)) 670 if (NULL == (c = h->current))
662 { 671 {
663 GNUNET_break (0); 672 GNUNET_break (0);
@@ -725,12 +734,14 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg)
725 * the response). 734 * the response).
726 * 735 *
727 * @param handle statistics handle 736 * @param handle statistics handle
728 * @param size how many bytes can we write to buf 737 * @param size how many bytes can we write to @a buf
729 * @param buf where to write requests to the service 738 * @param buf where to write requests to the service
730 * @return number of bytes written to buf 739 * @return number of bytes written to @a buf
731 */ 740 */
732static size_t 741static size_t
733transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) 742transmit_get (struct GNUNET_STATISTICS_Handle *handle,
743 size_t size,
744 void *buf)
734{ 745{
735 struct GNUNET_STATISTICS_GetHandle *c; 746 struct GNUNET_STATISTICS_GetHandle *c;
736 struct GNUNET_MessageHeader *hdr; 747 struct GNUNET_MessageHeader *hdr;
@@ -776,12 +787,14 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
776 * the response). 787 * the response).
777 * 788 *
778 * @param handle statistics handle 789 * @param handle statistics handle
779 * @param size how many bytes can we write to buf 790 * @param size how many bytes can we write to @a buf
780 * @param buf where to write requests to the service 791 * @param buf where to write requests to the service
781 * @return number of bytes written to buf 792 * @return number of bytes written to @a buf
782 */ 793 */
783static size_t 794static size_t
784transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) 795transmit_watch (struct GNUNET_STATISTICS_Handle *handle,
796 size_t size,
797 void *buf)
785{ 798{
786 struct GNUNET_MessageHeader *hdr; 799 struct GNUNET_MessageHeader *hdr;
787 size_t slen1; 800 size_t slen1;
@@ -797,7 +810,8 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
797 reconnect_later (handle); 810 reconnect_later (handle);
798 return 0; 811 return 0;
799 } 812 }
800 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting watch request for `%s'\n", 813 LOG (GNUNET_ERROR_TYPE_DEBUG,
814 "Transmitting watch request for `%s'\n",
801 handle->current->name); 815 handle->current->name);
802 slen1 = strlen (handle->current->subsystem) + 1; 816 slen1 = strlen (handle->current->subsystem) + 1;
803 slen2 = strlen (handle->current->name) + 1; 817 slen2 = strlen (handle->current->name) + 1;
@@ -827,12 +841,14 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
827 * Transmit a SET/UPDATE request. 841 * Transmit a SET/UPDATE request.
828 * 842 *
829 * @param handle statistics handle 843 * @param handle statistics handle
830 * @param size how many bytes can we write to buf 844 * @param size how many bytes can we write to @a buf
831 * @param buf where to write requests to the service 845 * @param buf where to write requests to the service
832 * @return number of bytes written to buf 846 * @return number of bytes written to @a buf
833 */ 847 */
834static size_t 848static size_t
835transmit_set (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) 849transmit_set (struct GNUNET_STATISTICS_Handle *handle,
850 size_t size,
851 void *buf)
836{ 852{
837 struct GNUNET_STATISTICS_SetMessage *r; 853 struct GNUNET_STATISTICS_SetMessage *r;
838 size_t slen; 854 size_t slen;
@@ -879,10 +895,10 @@ transmit_set (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
879/** 895/**
880 * Function called when we are ready to transmit a request to the service. 896 * Function called when we are ready to transmit a request to the service.
881 * 897 *
882 * @param cls the 'struct GNUNET_STATISTICS_Handle' 898 * @param cls the `struct GNUNET_STATISTICS_Handle`
883 * @param size how many bytes can we write to buf 899 * @param size how many bytes can we write to @a buf
884 * @param buf where to write requests to the service 900 * @param buf where to write requests to the service
885 * @return number of bytes written to buf 901 * @return number of bytes written to @a buf
886 */ 902 */
887static size_t 903static size_t
888transmit_action (void *cls, size_t size, void *buf) 904transmit_action (void *cls, size_t size, void *buf)
@@ -945,11 +961,12 @@ GNUNET_STATISTICS_create (const char *subsystem,
945 * it). 961 * it).
946 * 962 *
947 * @param h statistics handle to destroy 963 * @param h statistics handle to destroy
948 * @param sync_first set to GNUNET_YES if pending SET requests should 964 * @param sync_first set to #GNUNET_YES if pending SET requests should
949 * be completed 965 * be completed
950 */ 966 */
951void 967void
952GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) 968GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h,
969 int sync_first)
953{ 970{
954 struct GNUNET_STATISTICS_GetHandle *pos; 971 struct GNUNET_STATISTICS_GetHandle *pos;
955 struct GNUNET_STATISTICS_GetHandle *next; 972 struct GNUNET_STATISTICS_GetHandle *next;
@@ -970,8 +987,11 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first)
970 { 987 {
971 if (ACTION_GET == h->current->type) 988 if (ACTION_GET == h->current->type)
972 { 989 {
973 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); 990 if (NULL != h->th)
974 h->th = NULL; 991 {
992 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
993 h->th = NULL;
994 }
975 free_action_item (h->current); 995 free_action_item (h->current);
976 h->current = NULL; 996 h->current = NULL;
977 } 997 }
@@ -1034,10 +1054,10 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first)
1034 * confirm that the service has received all of our 'SET' 1054 * confirm that the service has received all of our 'SET'
1035 * messages (during statistics disconnect/shutdown). 1055 * messages (during statistics disconnect/shutdown).
1036 * 1056 *
1037 * @param cls the 'struct GNUNET_STATISTICS_Handle' 1057 * @param cls the `struct GNUNET_STATISTICS_Handle`
1038 * @param size how many bytes can we write to buf 1058 * @param size how many bytes can we write to @a buf
1039 * @param buf where to write requests to the service 1059 * @param buf where to write requests to the service
1040 * @return number of bytes written to buf 1060 * @return number of bytes written to @a buf
1041 */ 1061 */
1042static size_t 1062static size_t
1043transmit_test_on_shutdown (void *cls, 1063transmit_test_on_shutdown (void *cls,
@@ -1132,7 +1152,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h)
1132 * @param cont continuation to call when done (can be NULL) 1152 * @param cont continuation to call when done (can be NULL)
1133 * This callback CANNOT destroy the statistics handle in the same call. 1153 * This callback CANNOT destroy the statistics handle in the same call.
1134 * @param proc function to call on each value 1154 * @param proc function to call on each value
1135 * @param cls closure for cont and proc 1155 * @param cls closure for @a cont and @a proc
1136 * @return NULL on error 1156 * @return NULL on error
1137 */ 1157 */
1138struct GNUNET_STATISTICS_GetHandle * 1158struct GNUNET_STATISTICS_GetHandle *
@@ -1208,8 +1228,8 @@ GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh)
1208 * @param subsystem limit to the specified subsystem, never NULL 1228 * @param subsystem limit to the specified subsystem, never NULL
1209 * @param name name of the statistic value, never NULL 1229 * @param name name of the statistic value, never NULL
1210 * @param proc function to call on each value 1230 * @param proc function to call on each value
1211 * @param proc_cls closure for proc 1231 * @param proc_cls closure for @a proc
1212 * @return GNUNET_OK on success, GNUNET_SYSERR on error 1232 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1213 */ 1233 */
1214int 1234int
1215GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, 1235GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle,
@@ -1238,13 +1258,15 @@ GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle,
1238 * @param subsystem limit to the specified subsystem, never NULL 1258 * @param subsystem limit to the specified subsystem, never NULL
1239 * @param name name of the statistic value, never NULL 1259 * @param name name of the statistic value, never NULL
1240 * @param proc function to call on each value 1260 * @param proc function to call on each value
1241 * @param proc_cls closure for proc 1261 * @param proc_cls closure for @a proc
1242 * @return GNUNET_OK on success, GNUNET_SYSERR on error (no such watch) 1262 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (no such watch)
1243 */ 1263 */
1244int 1264int
1245GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, 1265GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle,
1246 const char *subsystem, const char *name, 1266 const char *subsystem,
1247 GNUNET_STATISTICS_Iterator proc, void *proc_cls) 1267 const char *name,
1268 GNUNET_STATISTICS_Iterator proc,
1269 void *proc_cls)
1248{ 1270{
1249 struct GNUNET_STATISTICS_WatchEntry *w; 1271 struct GNUNET_STATISTICS_WatchEntry *w;
1250 unsigned int i; 1272 unsigned int i;
@@ -1280,11 +1302,14 @@ GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle,
1280 * @param name name of the value 1302 * @param name name of the value
1281 * @param make_persistent should the value be kept across restarts? 1303 * @param make_persistent should the value be kept across restarts?
1282 * @param value new value or change 1304 * @param value new value or change
1283 * @param type type of the action (ACTION_SET or ACTION_UPDATE) 1305 * @param type type of the action (#ACTION_SET or #ACTION_UPDATE)
1284 */ 1306 */
1285static void 1307static void
1286add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name, 1308add_setter_action (struct GNUNET_STATISTICS_Handle *h,
1287 int make_persistent, uint64_t value, enum ActionType type) 1309 const char *name,
1310 int make_persistent,
1311 uint64_t value,
1312 enum ActionType type)
1288{ 1313{
1289 struct GNUNET_STATISTICS_GetHandle *ai; 1314 struct GNUNET_STATISTICS_GetHandle *ai;
1290 size_t slen; 1315 size_t slen;
@@ -1292,8 +1317,6 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name,
1292 size_t nsize; 1317 size_t nsize;
1293 int64_t delta; 1318 int64_t delta;
1294 1319
1295 GNUNET_assert (NULL != h);
1296 GNUNET_assert (NULL != name);
1297 slen = strlen (h->subsystem) + 1; 1320 slen = strlen (h->subsystem) + 1;
1298 nlen = strlen (name) + 1; 1321 nlen = strlen (name) + 1;
1299 nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen; 1322 nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen;
@@ -1380,7 +1403,9 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name,
1380 */ 1403 */
1381void 1404void
1382GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, 1405GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
1383 const char *name, uint64_t value, int make_persistent) 1406 const char *name,
1407 uint64_t value,
1408 int make_persistent)
1384{ 1409{
1385 if (NULL == handle) 1410 if (NULL == handle)
1386 return; 1411 return;
@@ -1400,14 +1425,19 @@ GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
1400 */ 1425 */
1401void 1426void
1402GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, 1427GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
1403 const char *name, int64_t delta, int make_persistent) 1428 const char *name,
1429 int64_t delta,
1430 int make_persistent)
1404{ 1431{
1405 if (NULL == handle) 1432 if (NULL == handle)
1406 return; 1433 return;
1407 if (0 == delta) 1434 if (0 == delta)
1408 return; 1435 return;
1409 GNUNET_assert (GNUNET_NO == handle->do_destroy); 1436 GNUNET_assert (GNUNET_NO == handle->do_destroy);
1410 add_setter_action (handle, name, make_persistent, (uint64_t) delta, 1437 add_setter_action (handle,
1438 name,
1439 make_persistent,
1440 (uint64_t) delta,
1411 ACTION_UPDATE); 1441 ACTION_UPDATE);
1412} 1442}
1413 1443