aboutsummaryrefslogtreecommitdiff
path: root/src/psyc
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-26 13:01:19 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-26 13:01:19 +0000
commit4dc513b0d1b1dceaf8c732b43226d4053aadf397 (patch)
treea13d3f585528baebb2fe070232e3530e38c4e458 /src/psyc
parent140c058ad6dc7a96783b701928b71afd0374ff71 (diff)
downloadgnunet-4dc513b0d1b1dceaf8c732b43226d4053aadf397.tar.gz
gnunet-4dc513b0d1b1dceaf8c732b43226d4053aadf397.zip
fix MAX_PAYLOAD definition, thereby fixing wrong type for GNUNET_log
Diffstat (limited to 'src/psyc')
-rw-r--r--src/psyc/gnunet-service-psyc.c116
1 files changed, 69 insertions, 47 deletions
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c
index 9106e8731..7739fe65b 100644
--- a/src/psyc/gnunet-service-psyc.c
+++ b/src/psyc/gnunet-service-psyc.c
@@ -542,7 +542,9 @@ cleanup_channel (struct Channel *chn)
542{ 542{
543 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 543 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
544 "%p Cleaning up channel %s. master? %u\n", 544 "%p Cleaning up channel %s. master? %u\n",
545 chn, GNUNET_h2s (&chn->pub_key_hash), chn->is_master); 545 chn,
546 GNUNET_h2s (&chn->pub_key_hash),
547 chn->is_master);
546 message_queue_drop (chn); 548 message_queue_drop (chn);
547 GNUNET_CONTAINER_multihashmap_destroy (chn->recv_frags); 549 GNUNET_CONTAINER_multihashmap_destroy (chn->recv_frags);
548 chn->recv_frags = NULL; 550 chn->recv_frags = NULL;
@@ -579,14 +581,16 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
579 if (NULL == chn) 581 if (NULL == chn)
580 { 582 {
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
582 "%p User context is NULL in client_disconnect()\n", chn); 584 "%p User context is NULL in client_disconnect()\n",
585 chn);
583 GNUNET_break (0); 586 GNUNET_break (0);
584 return; 587 return;
585 } 588 }
586 589
587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
588 "%p Client (%s) disconnected from channel %s\n", 591 "%p Client (%s) disconnected from channel %s\n",
589 chn, (GNUNET_YES == chn->is_master) ? "master" : "slave", 592 chn,
593 (GNUNET_YES == chn->is_master) ? "master" : "slave",
590 GNUNET_h2s (&chn->pub_key_hash)); 594 GNUNET_h2s (&chn->pub_key_hash));
591 595
592 struct Client *cli = chn->clients_head; 596 struct Client *cli = chn->clients_head;
@@ -616,7 +620,8 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
616 { /* Last client disconnected. */ 620 { /* Last client disconnected. */
617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 621 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
618 "%p Last client (%s) disconnected from channel %s\n", 622 "%p Last client (%s) disconnected from channel %s\n",
619 chn, (GNUNET_YES == chn->is_master) ? "master" : "slave", 623 chn,
624 (GNUNET_YES == chn->is_master) ? "master" : "slave",
620 GNUNET_h2s (&chn->pub_key_hash)); 625 GNUNET_h2s (&chn->pub_key_hash));
621 chn->is_disconnected = GNUNET_YES; 626 chn->is_disconnected = GNUNET_YES;
622 if (NULL != chn->tmit_head) 627 if (NULL != chn->tmit_head)
@@ -639,7 +644,8 @@ client_send_msg (const struct Channel *chn,
639 const struct GNUNET_MessageHeader *msg) 644 const struct GNUNET_MessageHeader *msg)
640{ 645{
641 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
642 "%p Sending message to clients.\n", chn); 647 "%p Sending message to clients.\n",
648 chn);
643 649
644 struct Client *cli = chn->clients_head; 650 struct Client *cli = chn->clients_head;
645 while (NULL != cli) 651 while (NULL != cli)
@@ -680,9 +686,11 @@ client_send_result (struct GNUNET_SERVER_Client *client, uint64_t op_id,
680 GNUNET_memcpy (&res[1], data, data_size); 686 GNUNET_memcpy (&res[1], data, data_size);
681 687
682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
683 "%p Sending result to client for operation #%" PRIu64 ": " 689 "%p Sending result to client for operation #%" PRIu64 ": %" PRId64 " (size: %u)\n",
684 "%" PRId64 " (size: %u)\n", 690 client,
685 client, GNUNET_ntohll (op_id), result_code, data_size); 691 GNUNET_ntohll (op_id),
692 result_code,
693 data_size);
686 694
687 GNUNET_SERVER_notification_context_add (nc, client); 695 GNUNET_SERVER_notification_context_add (nc, client);
688 GNUNET_SERVER_notification_context_unicast (nc, client, &res->header, 696 GNUNET_SERVER_notification_context_unicast (nc, client, &res->header,
@@ -748,9 +756,11 @@ mcast_recv_join_request (void *cls,
748 struct GNUNET_MULTICAST_JoinHandle *jh) 756 struct GNUNET_MULTICAST_JoinHandle *jh)
749{ 757{
750 struct Channel *chn = cls; 758 struct Channel *chn = cls;
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Got join request.\n", chn);
752
753 uint16_t join_msg_size = 0; 759 uint16_t join_msg_size = 0;
760
761 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
762 "%p Got join request.\n",
763 chn);
754 if (NULL != join_msg) 764 if (NULL != join_msg)
755 { 765 {
756 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE == ntohs (join_msg->type)) 766 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE == ntohs (join_msg->type))
@@ -761,7 +771,8 @@ mcast_recv_join_request (void *cls,
761 { 771 {
762 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 772 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
763 "%p Got join message with invalid type %u.\n", 773 "%p Got join message with invalid type %u.\n",
764 chn, ntohs (join_msg->type)); 774 chn,
775 ntohs (join_msg->type));
765 } 776 }
766 } 777 }
767 778
@@ -798,7 +809,9 @@ mcast_recv_join_decision (void *cls, int is_admitted,
798 struct Slave *slv = cls; 809 struct Slave *slv = cls;
799 struct Channel *chn = &slv->chn; 810 struct Channel *chn = &slv->chn;
800 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
801 "%p Got join decision: %d\n", slv, is_admitted); 812 "%p Got join decision: %d\n",
813 slv,
814 is_admitted);
802 if (GNUNET_YES == chn->is_ready) 815 if (GNUNET_YES == chn->is_ready)
803 { 816 {
804 /* Already admitted */ 817 /* Already admitted */
@@ -840,14 +853,19 @@ store_recv_fragment_replay (void *cls,
840 * Received result of GNUNET_PSYCSTORE_fragment_get() for multicast replay. 853 * Received result of GNUNET_PSYCSTORE_fragment_get() for multicast replay.
841 */ 854 */
842static void 855static void
843store_recv_fragment_replay_result (void *cls, int64_t result, 856store_recv_fragment_replay_result (void *cls,
844 const char *err_msg, uint16_t err_msg_size) 857 int64_t result,
858 const char *err_msg,
859 uint16_t err_msg_size)
845{ 860{
846 struct GNUNET_MULTICAST_ReplayHandle *rh = cls; 861 struct GNUNET_MULTICAST_ReplayHandle *rh = cls;
862
847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
848 "%p Fragment replay: PSYCSTORE returned %" PRId64 " (%.*s)\n", 864 "%p Fragment replay: PSYCSTORE returned %" PRId64 " (%.*s)\n",
849 rh, result, err_msg_size, err_msg); 865 rh,
850 866 result,
867 err_msg_size,
868 err_msg);
851 switch (result) 869 switch (result)
852 { 870 {
853 case GNUNET_YES: 871 case GNUNET_YES:
@@ -996,9 +1014,9 @@ client_send_mcast_msg (struct Channel *chn,
996 uint32_t flags) 1014 uint32_t flags)
997{ 1015{
998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
999 "%p Sending multicast message to client. " 1017 "%p Sending multicast message to client. fragment_id: %" PRIu64 ", message_id: %" PRIu64 "\n",
1000 "fragment_id: %" PRIu64 ", message_id: %" PRIu64 "\n", 1018 chn,
1001 chn, GNUNET_ntohll (mmsg->fragment_id), 1019 GNUNET_ntohll (mmsg->fragment_id),
1002 GNUNET_ntohll (mmsg->message_id)); 1020 GNUNET_ntohll (mmsg->message_id));
1003 1021
1004 struct GNUNET_PSYC_MessageHeader * 1022 struct GNUNET_PSYC_MessageHeader *
@@ -1022,9 +1040,9 @@ client_send_mcast_req (struct Master *mst,
1022 uint16_t psize = sizeof (*pmsg) + size - sizeof (*req); 1040 uint16_t psize = sizeof (*pmsg) + size - sizeof (*req);
1023 1041
1024 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1025 "%p Sending multicast request to client. " 1043 "%p Sending multicast request to client. fragment_id: %" PRIu64 ", message_id: %" PRIu64 "\n",
1026 "fragment_id: %" PRIu64 ", message_id: %" PRIu64 "\n", 1044 chn,
1027 chn, GNUNET_ntohll (req->fragment_id), 1045 GNUNET_ntohll (req->fragment_id),
1028 GNUNET_ntohll (req->request_id)); 1046 GNUNET_ntohll (req->request_id));
1029 1047
1030 pmsg = GNUNET_malloc (psize); 1048 pmsg = GNUNET_malloc (psize);
@@ -1095,13 +1113,15 @@ fragment_queue_insert (struct Channel *chn,
1095 if (NULL == cache_entry) 1113 if (NULL == cache_entry)
1096 { 1114 {
1097 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1098 "%p Adding message fragment to cache. " 1116 "%p Adding message fragment to cache. message_id: %" PRIu64 ", fragment_id: %" PRIu64 "\n",
1099 "message_id: %" PRIu64 ", fragment_id: %" PRIu64 "\n", 1117 chn,
1100 chn, GNUNET_ntohll (mmsg->message_id), 1118 GNUNET_ntohll (mmsg->message_id),
1101 GNUNET_ntohll (mmsg->fragment_id)); 1119 GNUNET_ntohll (mmsg->fragment_id));
1102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1103 "%p header_size: %" PRIu64 " + %u\n", 1121 "%p header_size: %" PRIu64 " + %u\n",
1104 chn, fragq->header_size, size); 1122 chn,
1123 fragq->header_size,
1124 size);
1105 cache_entry = GNUNET_new (struct RecvCacheEntry); 1125 cache_entry = GNUNET_new (struct RecvCacheEntry);
1106 cache_entry->ref_count = 1; 1126 cache_entry->ref_count = 1;
1107 cache_entry->mmsg = GNUNET_malloc (size); 1127 cache_entry->mmsg = GNUNET_malloc (size);
@@ -1113,11 +1133,11 @@ fragment_queue_insert (struct Channel *chn,
1113 { 1133 {
1114 cache_entry->ref_count++; 1134 cache_entry->ref_count++;
1115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1116 "%p Message fragment is already in cache. " 1136 "%p Message fragment is already in cache. message_id: %" PRIu64 ", fragment_id: %" PRIu64 ", ref_count: %u\n",
1117 "message_id: %" PRIu64 ", fragment_id: %" PRIu64 1137 chn,
1118 ", ref_count: %u\n", 1138 GNUNET_ntohll (mmsg->message_id),
1119 chn, GNUNET_ntohll (mmsg->message_id), 1139 GNUNET_ntohll (mmsg->fragment_id),
1120 GNUNET_ntohll (mmsg->fragment_id), cache_entry->ref_count); 1140 cache_entry->ref_count);
1121 } 1141 }
1122 1142
1123 if (MSG_FRAG_STATE_HEADER == fragq->state) 1143 if (MSG_FRAG_STATE_HEADER == fragq->state)
@@ -1139,20 +1159,23 @@ fragment_queue_insert (struct Channel *chn,
1139 { /* header is now complete */ 1159 { /* header is now complete */
1140 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1160 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1141 "%p Header of message %" PRIu64 " is complete.\n", 1161 "%p Header of message %" PRIu64 " is complete.\n",
1142 chn, GNUNET_ntohll (mmsg->message_id)); 1162 chn,
1163 GNUNET_ntohll (mmsg->message_id));
1143 1164
1144 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1165 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1145 "%p Adding message %" PRIu64 " to queue.\n", 1166 "%p Adding message %" PRIu64 " to queue.\n",
1146 chn, GNUNET_ntohll (mmsg->message_id)); 1167 chn,
1168 GNUNET_ntohll (mmsg->message_id));
1147 fragq->state = MSG_FRAG_STATE_DATA; 1169 fragq->state = MSG_FRAG_STATE_DATA;
1148 } 1170 }
1149 else 1171 else
1150 { 1172 {
1151 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1173 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1152 "%p Header of message %" PRIu64 " is NOT complete yet: " 1174 "%p Header of message %" PRIu64 " is NOT complete yet: %" PRIu64 " != %" PRIu64 "\n",
1153 "%" PRIu64 " != %" PRIu64 "\n", 1175 chn,
1154 chn, GNUNET_ntohll (mmsg->message_id), 1176 GNUNET_ntohll (mmsg->message_id),
1155 frag_offset, fragq->header_size); 1177 frag_offset,
1178 fragq->header_size);
1156 } 1179 }
1157 } 1180 }
1158 1181
@@ -1163,10 +1186,11 @@ fragment_queue_insert (struct Channel *chn,
1163 fragq->state = MSG_FRAG_STATE_END; 1186 fragq->state = MSG_FRAG_STATE_END;
1164 else 1187 else
1165 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1188 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1166 "%p Message %" PRIu64 " is NOT complete yet: " 1189 "%p Message %" PRIu64 " is NOT complete yet: %" PRIu64 " != %" PRIu64 "\n",
1167 "%" PRIu64 " != %" PRIu64 "\n", 1190 chn,
1168 chn, GNUNET_ntohll (mmsg->message_id), 1191 GNUNET_ntohll (mmsg->message_id),
1169 frag_offset, fragq->size); 1192 frag_offset,
1193 fragq->size);
1170 break; 1194 break;
1171 1195
1172 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL: 1196 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
@@ -1217,9 +1241,10 @@ fragment_queue_run (struct Channel *chn, uint64_t msg_id,
1217 struct FragmentQueue *fragq, uint8_t drop) 1241 struct FragmentQueue *fragq, uint8_t drop)
1218{ 1242{
1219 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1243 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1220 "%p Running message fragment queue for message %" PRIu64 1244 "%p Running message fragment queue for message %" PRIu64 " (state: %u).\n",
1221 " (state: %u).\n", 1245 chn,
1222 chn, msg_id, fragq->state); 1246 msg_id,
1247 fragq->state);
1223 1248
1224 struct GNUNET_CONTAINER_MultiHashMap 1249 struct GNUNET_CONTAINER_MultiHashMap
1225 *chan_msgs = GNUNET_CONTAINER_multihashmap_get (recv_cache, 1250 *chan_msgs = GNUNET_CONTAINER_multihashmap_get (recv_cache,
@@ -2274,9 +2299,6 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client,
2274 uint16_t size = ntohs (msg->size); 2299 uint16_t size = ntohs (msg->size);
2275 if (GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD < size - sizeof (*msg)) 2300 if (GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD < size - sizeof (*msg))
2276 { 2301 {
2277 /* Coverity says this printf has incompatible args
2278 * but I don't see anything wrong with it.. FIXME
2279 */
2280 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2281 "%p Message payload too large: %u < %u.\n", 2303 "%p Message payload too large: %u < %u.\n",
2282 chn, 2304 chn,