diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-04-18 11:49:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-04-18 11:49:58 +0000 |
commit | 8dc9e1a5048dd74b1ded7551c9e6120e4c0476a5 (patch) | |
tree | d52f753bb9c9f4623859ea2404018482382c5df8 /src/core | |
parent | 2a6c19e8b67a36fa07cde86adde1cf9eeed77dd8 (diff) | |
download | gnunet-8dc9e1a5048dd74b1ded7551c9e6120e4c0476a5.tar.gz gnunet-8dc9e1a5048dd74b1ded7551c9e6120e4c0476a5.zip |
-fixing core traffic monitoring assertion, code cleanup
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core_api.c | 43 | ||||
-rw-r--r-- | src/core/gnunet-service-core_clients.c | 14 |
2 files changed, 27 insertions, 30 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index d2eaa260d..69dcfecf8 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -767,7 +767,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
767 | uint16_t et; | 767 | uint16_t et; |
768 | uint32_t ats_count; | 768 | uint32_t ats_count; |
769 | 769 | ||
770 | if (msg == NULL) | 770 | if (NULL == msg) |
771 | { | 771 | { |
772 | LOG (GNUNET_ERROR_TYPE_INFO, | 772 | LOG (GNUNET_ERROR_TYPE_INFO, |
773 | _ | 773 | _ |
@@ -813,7 +813,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
813 | } | 813 | } |
814 | /* fake 'connect to self' */ | 814 | /* fake 'connect to self' */ |
815 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &h->me.hashPubKey); | 815 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &h->me.hashPubKey); |
816 | GNUNET_assert (pr == NULL); | 816 | GNUNET_assert (NULL == pr); |
817 | pr = GNUNET_malloc (sizeof (struct PeerRecord)); | 817 | pr = GNUNET_malloc (sizeof (struct PeerRecord)); |
818 | pr->peer = h->me; | 818 | pr->peer = h->me; |
819 | pr->ch = h; | 819 | pr->ch = h; |
@@ -851,7 +851,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
851 | return; | 851 | return; |
852 | } | 852 | } |
853 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &cnm->peer.hashPubKey); | 853 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &cnm->peer.hashPubKey); |
854 | if (pr != NULL) | 854 | if (NULL != pr) |
855 | { | 855 | { |
856 | GNUNET_break (0); | 856 | GNUNET_break (0); |
857 | reconnect_later (h); | 857 | reconnect_later (h); |
@@ -887,7 +887,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
887 | "Received notification about disconnect from `%s'.\n", | 887 | "Received notification about disconnect from `%s'.\n", |
888 | GNUNET_i2s (&dnm->peer)); | 888 | GNUNET_i2s (&dnm->peer)); |
889 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &dnm->peer.hashPubKey); | 889 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &dnm->peer.hashPubKey); |
890 | if (pr == NULL) | 890 | if (NULL == pr) |
891 | { | 891 | { |
892 | GNUNET_break (0); | 892 | GNUNET_break (0); |
893 | reconnect_later (h); | 893 | reconnect_later (h); |
@@ -923,13 +923,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
923 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 923 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
924 | "Received message of type %u and size %u from peer `%4s'\n", | 924 | "Received message of type %u and size %u from peer `%4s'\n", |
925 | ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer)); | 925 | ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer)); |
926 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey); | ||
927 | if (pr == NULL) | ||
928 | { | ||
929 | GNUNET_break (0); | ||
930 | reconnect_later (h); | ||
931 | return; | ||
932 | } | ||
933 | if ((GNUNET_NO == h->inbound_hdr_only) && | 926 | if ((GNUNET_NO == h->inbound_hdr_only) && |
934 | (msize != | 927 | (msize != |
935 | ntohs (em->size) + sizeof (struct NotifyTrafficMessage) + | 928 | ntohs (em->size) + sizeof (struct NotifyTrafficMessage) + |
@@ -953,6 +946,13 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
953 | GNUNET_break_op (0); | 946 | GNUNET_break_op (0); |
954 | continue; | 947 | continue; |
955 | } | 948 | } |
949 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey); | ||
950 | if (NULL == pr) | ||
951 | { | ||
952 | GNUNET_break (0); | ||
953 | reconnect_later (h); | ||
954 | return; | ||
955 | } | ||
956 | if (GNUNET_OK != | 956 | if (GNUNET_OK != |
957 | h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats, | 957 | h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats, |
958 | ats_count)) | 958 | ats_count)) |
@@ -990,13 +990,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
990 | return; | 990 | return; |
991 | } | 991 | } |
992 | em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1]; | 992 | em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1]; |
993 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey); | ||
994 | if (pr == NULL) | ||
995 | { | ||
996 | GNUNET_break (0); | ||
997 | reconnect_later (h); | ||
998 | return; | ||
999 | } | ||
1000 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 993 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1001 | "Received notification about transmission to `%s'.\n", | 994 | "Received notification about transmission to `%s'.\n", |
1002 | GNUNET_i2s (&ntm->peer)); | 995 | GNUNET_i2s (&ntm->peer)); |
@@ -1025,7 +1018,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1025 | } | 1018 | } |
1026 | smr = (const struct SendMessageReady *) msg; | 1019 | smr = (const struct SendMessageReady *) msg; |
1027 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &smr->peer.hashPubKey); | 1020 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &smr->peer.hashPubKey); |
1028 | if (pr == NULL) | 1021 | if (NULL == pr) |
1029 | { | 1022 | { |
1030 | GNUNET_break (0); | 1023 | GNUNET_break (0); |
1031 | reconnect_later (h); | 1024 | reconnect_later (h); |
@@ -1034,7 +1027,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1034 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1027 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1035 | "Received notification about transmission readiness to `%s'.\n", | 1028 | "Received notification about transmission readiness to `%s'.\n", |
1036 | GNUNET_i2s (&smr->peer)); | 1029 | GNUNET_i2s (&smr->peer)); |
1037 | if (pr->pending_head == NULL) | 1030 | if (NULL == pr->pending_head) |
1038 | { | 1031 | { |
1039 | /* request must have been cancelled between the original request | 1032 | /* request must have been cancelled between the original request |
1040 | * and the response from core, ignore core's readiness */ | 1033 | * and the response from core, ignore core's readiness */ |
@@ -1048,7 +1041,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1048 | * ignore! (we should have already sent another request) */ | 1041 | * ignore! (we should have already sent another request) */ |
1049 | break; | 1042 | break; |
1050 | } | 1043 | } |
1051 | if ((pr->prev != NULL) || (pr->next != NULL) || (h->ready_peer_head == pr)) | 1044 | if ((NULL != pr->prev) || (NULL != pr->next) || (h->ready_peer_head == pr)) |
1052 | { | 1045 | { |
1053 | /* we should not already be on the ready list... */ | 1046 | /* we should not already be on the ready list... */ |
1054 | GNUNET_break (0); | 1047 | GNUNET_break (0); |
@@ -1079,9 +1072,9 @@ init_done_task (void *cls, int success) | |||
1079 | { | 1072 | { |
1080 | struct GNUNET_CORE_Handle *h = cls; | 1073 | struct GNUNET_CORE_Handle *h = cls; |
1081 | 1074 | ||
1082 | if (success == GNUNET_SYSERR) | 1075 | if (GNUNET_SYSERR == success) |
1083 | return; /* shutdown */ | 1076 | return; /* shutdown */ |
1084 | if (success == GNUNET_NO) | 1077 | if (GNUNET_NO == success) |
1085 | { | 1078 | { |
1086 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1079 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1087 | "Failed to exchange INIT with core, retrying\n"); | 1080 | "Failed to exchange INIT with core, retrying\n"); |
@@ -1110,10 +1103,10 @@ reconnect (struct GNUNET_CORE_Handle *h) | |||
1110 | uint16_t *ts; | 1103 | uint16_t *ts; |
1111 | unsigned int hpos; | 1104 | unsigned int hpos; |
1112 | 1105 | ||
1113 | GNUNET_assert (h->client == NULL); | 1106 | GNUNET_assert (NULL == h->client); |
1114 | GNUNET_assert (h->currently_down == GNUNET_YES); | 1107 | GNUNET_assert (h->currently_down == GNUNET_YES); |
1115 | h->client = GNUNET_CLIENT_connect ("core", h->cfg); | 1108 | h->client = GNUNET_CLIENT_connect ("core", h->cfg); |
1116 | if (h->client == NULL) | 1109 | if (NULL == h->client) |
1117 | { | 1110 | { |
1118 | reconnect_later (h); | 1111 | reconnect_later (h); |
1119 | return; | 1112 | return; |
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c index b57936baa..200f15c8e 100644 --- a/src/core/gnunet-service-core_clients.c +++ b/src/core/gnunet-service-core_clients.c | |||
@@ -223,16 +223,18 @@ send_to_all_clients (const struct GNUNET_PeerIdentity *partner, | |||
223 | uint32_t options, uint16_t type) | 223 | uint32_t options, uint16_t type) |
224 | { | 224 | { |
225 | struct GSC_Client *c; | 225 | struct GSC_Client *c; |
226 | int tm; | ||
226 | 227 | ||
227 | for (c = client_head; c != NULL; c = c->next) | 228 | for (c = client_head; c != NULL; c = c->next) |
228 | { | 229 | { |
230 | tm = type_match (type, c); | ||
229 | if (! ( (0 != (c->options & options)) || | 231 | if (! ( (0 != (c->options & options)) || |
230 | ( (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) && | 232 | ( (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) && |
231 | (GNUNET_YES == type_match (type, c)) ) ) ) | 233 | (GNUNET_YES == tm) ) ) ) |
232 | continue; /* neither options nor type match permit the message */ | 234 | continue; /* neither options nor type match permit the message */ |
233 | if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_INBOUND)) && | 235 | if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_INBOUND)) && |
234 | ( (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) || | 236 | ( (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) || |
235 | (GNUNET_YES == type_match (type, c)) ) ) | 237 | (GNUNET_YES == tm) ) ) |
236 | continue; | 238 | continue; |
237 | if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND)) && | 239 | if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND)) && |
238 | (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND)) ) | 240 | (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND)) ) |
@@ -242,9 +244,11 @@ send_to_all_clients (const struct GNUNET_PeerIdentity *partner, | |||
242 | options, | 244 | options, |
243 | ntohs (msg->size), | 245 | ntohs (msg->size), |
244 | (unsigned int) type); | 246 | (unsigned int) type); |
245 | GNUNET_assert (GNUNET_YES == | 247 | GNUNET_assert ( (0 == (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) || |
246 | GNUNET_CONTAINER_multihashmap_contains (c->connectmap, | 248 | (GNUNET_YES != tm) || |
247 | &partner->hashPubKey)); | 249 | (GNUNET_YES == |
250 | GNUNET_CONTAINER_multihashmap_contains (c->connectmap, | ||
251 | &partner->hashPubKey)) ); | ||
248 | send_to_client (c, msg, can_drop); | 252 | send_to_client (c, msg, can_drop); |
249 | } | 253 | } |
250 | } | 254 | } |