aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-17 13:21:54 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-17 13:21:54 +0000
commitc1cbb52286662ac8da07805c5a76d34bf21dd0dd (patch)
tree4691b2ec8a1e81e3c8fcafcca9df0ce889781823 /src/core
parentd99a711150109fe46269e87e8d771c5478a170a3 (diff)
downloadgnunet-c1cbb52286662ac8da07805c5a76d34bf21dd0dd.tar.gz
gnunet-c1cbb52286662ac8da07805c5a76d34bf21dd0dd.zip
fixing 1908
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-service-core_clients.c49
-rw-r--r--src/core/gnunet-service-core_sessions.c8
2 files changed, 29 insertions, 28 deletions
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c
index 3201b71f0..98a55bef9 100644
--- a/src/core/gnunet-service-core_clients.c
+++ b/src/core/gnunet-service-core_clients.c
@@ -33,7 +33,6 @@
33#include "gnunet-service-core_typemap.h" 33#include "gnunet-service-core_typemap.h"
34#include "core.h" 34#include "core.h"
35 35
36#define DEBUG_CONNECTS GNUNET_YES
37 36
38/** 37/**
39 * How many messages do we queue up at most for optional 38 * How many messages do we queue up at most for optional
@@ -76,12 +75,10 @@ struct GSC_Client
76 */ 75 */
77 struct GNUNET_CONTAINER_MultiHashMap *requests; 76 struct GNUNET_CONTAINER_MultiHashMap *requests;
78 77
79#if DEBUG_CONNECTS
80 /** 78 /**
81 * Map containing all peers that this client knows we're connected to. 79 * Map containing all peers that this client knows we're connected to.
82 */ 80 */
83 struct GNUNET_CONTAINER_MultiHashMap *connectmap; 81 struct GNUNET_CONTAINER_MultiHashMap *connectmap;
84#endif
85 82
86 /** 83 /**
87 * Options for messages this client cares about, 84 * Options for messages this client cares about,
@@ -234,11 +231,9 @@ send_to_all_clients (const struct GNUNET_PeerIdentity *sender,
234 "Sending message to client interested in messages of type %u.\n", 231 "Sending message to client interested in messages of type %u.\n",
235 (unsigned int) type); 232 (unsigned int) type);
236#endif 233#endif
237#if DEBUG_CONNECTS
238 GNUNET_assert (GNUNET_YES == 234 GNUNET_assert (GNUNET_YES ==
239 GNUNET_CONTAINER_multihashmap_contains (c->connectmap, 235 GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
240 &sender->hashPubKey)); 236 &sender->hashPubKey));
241#endif
242 send_to_client (c, msg, can_drop); 237 send_to_client (c, msg, can_drop);
243 } 238 }
244} 239}
@@ -287,15 +282,12 @@ handle_client_init (void *cls, struct GNUNET_SERVER_Client *client,
287 c->tcnt = msize / sizeof (uint16_t); 282 c->tcnt = msize / sizeof (uint16_t);
288 c->options = ntohl (im->options); 283 c->options = ntohl (im->options);
289 c->types = (const uint16_t *) &c[1]; 284 c->types = (const uint16_t *) &c[1];
290#if DEBUG_CONNECTS
291 c->connectmap = GNUNET_CONTAINER_multihashmap_create (16); 285 c->connectmap = GNUNET_CONTAINER_multihashmap_create (16);
292 GNUNET_assert (GNUNET_YES == 286 GNUNET_assert (GNUNET_YES ==
293 GNUNET_CONTAINER_multihashmap_put (c->connectmap, 287 GNUNET_CONTAINER_multihashmap_put (c->connectmap,
294 &GSC_my_identity.hashPubKey, 288 &GSC_my_identity.hashPubKey,
295 NULL, 289 NULL,
296 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 290 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
297#endif
298
299 wtypes = (uint16_t *) & c[1]; 291 wtypes = (uint16_t *) & c[1];
300 for (i = 0; i < c->tcnt; i++) 292 for (i = 0; i < c->tcnt; i++)
301 wtypes[i] = ntohs (types[i]); 293 wtypes[i] = ntohs (types[i]);
@@ -331,6 +323,7 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
331 const struct SendMessageRequest *req; 323 const struct SendMessageRequest *req;
332 struct GSC_Client *c; 324 struct GSC_Client *c;
333 struct GSC_ClientActiveRequest *car; 325 struct GSC_ClientActiveRequest *car;
326 int is_loopback;
334 327
335 req = (const struct SendMessageRequest *) message; 328 req = (const struct SendMessageRequest *) message;
336 c = find_client (client); 329 c = find_client (client);
@@ -348,6 +341,25 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
348 "Client asked for transmission to `%s'\n", 341 "Client asked for transmission to `%s'\n",
349 GNUNET_i2s (&req->peer)); 342 GNUNET_i2s (&req->peer));
350#endif 343#endif
344 is_loopback = (0 ==
345 memcmp (&req->peer, &GSC_my_identity,
346 sizeof (struct GNUNET_PeerIdentity)));
347 if ( (! is_loopback) &&
348 (GNUNET_YES !=
349 GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
350 &req->peer.hashPubKey)) )
351 {
352 /* neighbour must have disconnected since request was issued,
353 * ignore (client will realize it once it processes the
354 * disconnect notification) */
355 GNUNET_STATISTICS_update (GSC_stats,
356 gettext_noop
357 ("# send requests dropped (disconnected)"), 1,
358 GNUNET_NO);
359 GNUNET_SERVER_receive_done (client, GNUNET_OK);
360 return;
361 }
362
351 car = GNUNET_CONTAINER_multihashmap_get (c->requests, &req->peer.hashPubKey); 363 car = GNUNET_CONTAINER_multihashmap_get (c->requests, &req->peer.hashPubKey);
352 if (car == NULL) 364 if (car == NULL)
353 { 365 {
@@ -370,12 +382,14 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
370 car->msize = ntohs (req->size); 382 car->msize = ntohs (req->size);
371 car->smr_id = req->smr_id; 383 car->smr_id = req->smr_id;
372 car->was_solicited = GNUNET_NO; 384 car->was_solicited = GNUNET_NO;
373 if (0 == 385 if (is_loopback)
374 memcmp (&req->peer, &GSC_my_identity, 386 {
375 sizeof (struct GNUNET_PeerIdentity))) 387 /* loopback, satisfy immediately */
376 GSC_CLIENTS_solicit_request (car); 388 GSC_CLIENTS_solicit_request (car);
377 else 389 GNUNET_SERVER_receive_done (client, GNUNET_OK);
378 GSC_SESSIONS_queue_request (car); 390 return;
391 }
392 GSC_SESSIONS_queue_request (car);
379 GNUNET_SERVER_receive_done (client, GNUNET_OK); 393 GNUNET_SERVER_receive_done (client, GNUNET_OK);
380} 394}
381 395
@@ -571,9 +585,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
571 NULL); 585 NULL);
572 GNUNET_CONTAINER_multihashmap_destroy (c->requests); 586 GNUNET_CONTAINER_multihashmap_destroy (c->requests);
573 } 587 }
574#if DEBUG_CONNECTS
575 GNUNET_CONTAINER_multihashmap_destroy (c->connectmap); 588 GNUNET_CONTAINER_multihashmap_destroy (c->connectmap);
576#endif 589 c->connectmap = NULL;
577 GSC_TYPEMAP_remove (c->types, c->tcnt); 590 GSC_TYPEMAP_remove (c->types, c->tcnt);
578 GNUNET_free (c); 591 GNUNET_free (c);
579} 592}
@@ -598,12 +611,10 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
598 smr.size = htons (car->msize); 611 smr.size = htons (car->msize);
599 smr.smr_id = car->smr_id; 612 smr.smr_id = car->smr_id;
600 smr.peer = car->target; 613 smr.peer = car->target;
601#if DEBUG_CONNECTS
602 GNUNET_assert (GNUNET_YES == 614 GNUNET_assert (GNUNET_YES ==
603 GNUNET_CONTAINER_multihashmap_contains (c->connectmap, 615 GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
604 &car-> 616 &car->
605 target.hashPubKey)); 617 target.hashPubKey));
606#endif
607 send_to_client (c, &smr.header, GNUNET_NO); 618 send_to_client (c, &smr.header, GNUNET_NO);
608} 619}
609 620
@@ -670,7 +681,6 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
670 if (old_match == GNUNET_NO) 681 if (old_match == GNUNET_NO)
671 { 682 {
672 /* send connect */ 683 /* send connect */
673#if DEBUG_CONNECTS
674 GNUNET_assert (GNUNET_NO == 684 GNUNET_assert (GNUNET_NO ==
675 GNUNET_CONTAINER_multihashmap_contains (client->connectmap, 685 GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
676 &neighbour->hashPubKey)); 686 &neighbour->hashPubKey));
@@ -679,7 +689,6 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
679 &neighbour->hashPubKey, 689 &neighbour->hashPubKey,
680 NULL, 690 NULL,
681 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 691 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
682#endif
683 size = 692 size =
684 sizeof (struct ConnectNotifyMessage) + 693 sizeof (struct ConnectNotifyMessage) +
685 (atsi_count) * sizeof (struct GNUNET_ATS_Information); 694 (atsi_count) * sizeof (struct GNUNET_ATS_Information);
@@ -706,7 +715,6 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
706 else 715 else
707 { 716 {
708 /* send disconnect */ 717 /* send disconnect */
709#if DEBUG_CONNECTS
710 GNUNET_assert (GNUNET_YES == 718 GNUNET_assert (GNUNET_YES ==
711 GNUNET_CONTAINER_multihashmap_contains (client->connectmap, 719 GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
712 &neighbour->hashPubKey)); 720 &neighbour->hashPubKey));
@@ -714,7 +722,6 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
714 GNUNET_CONTAINER_multihashmap_remove (client->connectmap, 722 GNUNET_CONTAINER_multihashmap_remove (client->connectmap,
715 &neighbour->hashPubKey, 723 &neighbour->hashPubKey,
716 NULL)); 724 NULL));
717#endif
718 dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage)); 725 dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage));
719 dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT); 726 dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
720 dcm.reserved = htonl (0); 727 dcm.reserved = htonl (0);
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index 108fd47cf..ab825e9b6 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -335,17 +335,11 @@ GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car)
335 session = find_session (&car->target); 335 session = find_session (&car->target);
336 if (session == NULL) 336 if (session == NULL)
337 { 337 {
338 /* neighbour must have disconnected since request was issued,
339 * ignore (client will realize it once it processes the
340 * disconnect notification) */
341#if DEBUG_CORE 338#if DEBUG_CORE
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
343 "Dropped client request for transmission (am disconnected)\n"); 340 "Dropped client request for transmission (am disconnected)\n");
344#endif 341#endif
345 GNUNET_STATISTICS_update (GSC_stats, 342 GNUNET_break (0); /* should have been rejected earlier */
346 gettext_noop
347 ("# send requests dropped (disconnected)"), 1,
348 GNUNET_NO);
349 GSC_CLIENTS_reject_request (car); 343 GSC_CLIENTS_reject_request (car);
350 return; 344 return;
351 } 345 }