[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18181 - gnunet/src/core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18181 - gnunet/src/core |
Date: |
Thu, 17 Nov 2011 14:21:54 +0100 |
Author: grothoff
Date: 2011-11-17 14:21:54 +0100 (Thu, 17 Nov 2011)
New Revision: 18181
Modified:
gnunet/src/core/gnunet-service-core_clients.c
gnunet/src/core/gnunet-service-core_sessions.c
Log:
fixing 1908
Modified: gnunet/src/core/gnunet-service-core_clients.c
===================================================================
--- gnunet/src/core/gnunet-service-core_clients.c 2011-11-17 12:56:15 UTC
(rev 18180)
+++ gnunet/src/core/gnunet-service-core_clients.c 2011-11-17 13:21:54 UTC
(rev 18181)
@@ -33,7 +33,6 @@
#include "gnunet-service-core_typemap.h"
#include "core.h"
-#define DEBUG_CONNECTS GNUNET_YES
/**
* How many messages do we queue up at most for optional
@@ -76,12 +75,10 @@
*/
struct GNUNET_CONTAINER_MultiHashMap *requests;
-#if DEBUG_CONNECTS
/**
* Map containing all peers that this client knows we're connected to.
*/
struct GNUNET_CONTAINER_MultiHashMap *connectmap;
-#endif
/**
* Options for messages this client cares about,
@@ -234,11 +231,9 @@
"Sending message to client interested in messages of type
%u.\n",
(unsigned int) type);
#endif
-#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
&sender->hashPubKey));
-#endif
send_to_client (c, msg, can_drop);
}
}
@@ -287,15 +282,12 @@
c->tcnt = msize / sizeof (uint16_t);
c->options = ntohl (im->options);
c->types = (const uint16_t *) &c[1];
-#if DEBUG_CONNECTS
c->connectmap = GNUNET_CONTAINER_multihashmap_create (16);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (c->connectmap,
&GSC_my_identity.hashPubKey,
NULL,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-#endif
-
wtypes = (uint16_t *) & c[1];
for (i = 0; i < c->tcnt; i++)
wtypes[i] = ntohs (types[i]);
@@ -331,6 +323,7 @@
const struct SendMessageRequest *req;
struct GSC_Client *c;
struct GSC_ClientActiveRequest *car;
+ int is_loopback;
req = (const struct SendMessageRequest *) message;
c = find_client (client);
@@ -348,6 +341,25 @@
"Client asked for transmission to `%s'\n",
GNUNET_i2s (&req->peer));
#endif
+ is_loopback = (0 ==
+ memcmp (&req->peer, &GSC_my_identity,
+ sizeof (struct GNUNET_PeerIdentity)));
+ if ( (! is_loopback) &&
+ (GNUNET_YES !=
+ GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
+ &req->peer.hashPubKey)) )
+ {
+ /* neighbour must have disconnected since request was issued,
+ * ignore (client will realize it once it processes the
+ * disconnect notification) */
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop
+ ("# send requests dropped (disconnected)"), 1,
+ GNUNET_NO);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+
car = GNUNET_CONTAINER_multihashmap_get (c->requests, &req->peer.hashPubKey);
if (car == NULL)
{
@@ -370,12 +382,14 @@
car->msize = ntohs (req->size);
car->smr_id = req->smr_id;
car->was_solicited = GNUNET_NO;
- if (0 ==
- memcmp (&req->peer, &GSC_my_identity,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (is_loopback)
+ {
+ /* loopback, satisfy immediately */
GSC_CLIENTS_solicit_request (car);
- else
- GSC_SESSIONS_queue_request (car);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+ GSC_SESSIONS_queue_request (car);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -571,9 +585,8 @@
NULL);
GNUNET_CONTAINER_multihashmap_destroy (c->requests);
}
-#if DEBUG_CONNECTS
GNUNET_CONTAINER_multihashmap_destroy (c->connectmap);
-#endif
+ c->connectmap = NULL;
GSC_TYPEMAP_remove (c->types, c->tcnt);
GNUNET_free (c);
}
@@ -598,12 +611,10 @@
smr.size = htons (car->msize);
smr.smr_id = car->smr_id;
smr.peer = car->target;
-#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
&car->
target.hashPubKey));
-#endif
send_to_client (c, &smr.header, GNUNET_NO);
}
@@ -670,7 +681,6 @@
if (old_match == GNUNET_NO)
{
/* send connect */
-#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_NO ==
GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
&neighbour->hashPubKey));
@@ -679,7 +689,6 @@
&neighbour->hashPubKey,
NULL,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-#endif
size =
sizeof (struct ConnectNotifyMessage) +
(atsi_count) * sizeof (struct GNUNET_ATS_Information);
@@ -706,7 +715,6 @@
else
{
/* send disconnect */
-#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
&neighbour->hashPubKey));
@@ -714,7 +722,6 @@
GNUNET_CONTAINER_multihashmap_remove (client->connectmap,
&neighbour->hashPubKey,
NULL));
-#endif
dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage));
dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
dcm.reserved = htonl (0);
Modified: gnunet/src/core/gnunet-service-core_sessions.c
===================================================================
--- gnunet/src/core/gnunet-service-core_sessions.c 2011-11-17 12:56:15 UTC
(rev 18180)
+++ gnunet/src/core/gnunet-service-core_sessions.c 2011-11-17 13:21:54 UTC
(rev 18181)
@@ -335,17 +335,11 @@
session = find_session (&car->target);
if (session == NULL)
{
- /* neighbour must have disconnected since request was issued,
- * ignore (client will realize it once it processes the
- * disconnect notification) */
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Dropped client request for transmission (am disconnected)\n");
#endif
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# send requests dropped (disconnected)"), 1,
- GNUNET_NO);
+ GNUNET_break (0); /* should have been rejected earlier */
GSC_CLIENTS_reject_request (car);
return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18181 - gnunet/src/core,
gnunet <=