/**
* What is the maximum number of peers in a given bucket.
*/
-#define DEFAULT_BUCKET_SIZE 4
+#define DEFAULT_BUCKET_SIZE 8
/**
* Desired replication level for FIND PEER requests
GNUNET_HashCode mh;
GNUNET_BLOCK_mingle_hash (key, ctx->bf_mutator, &mh);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n",
+ GNUNET_h2s (key),
+ ctx->bf_mutator);
GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
return GNUNET_YES;
}
/* Check for connect to self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connected %s to %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (&peer->hashPubKey));
struct PeerInfo *to_remove;
int current_bucket;
struct P2PPendingMessage *pos;
+ unsigned int discarded;
/* Check for disconnect from self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnected %s from %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (&peer->hashPubKey));
GNUNET_CORE_notify_transmit_ready_cancel (to_remove->th);
to_remove->th = NULL;
}
+ discarded = 0;
while (NULL != (pos = to_remove->head))
{
GNUNET_CONTAINER_DLL_remove (to_remove->head,
to_remove->tail,
pos);
+ discarded++;
GNUNET_free (pos);
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Queued messages discarded (peer disconnected)"), discarded,
+ GNUNET_NO);
+ GNUNET_free (to_remove);
}
size_t msize;
peer->th = NULL;
- if (buf == NULL)
+ while ( (NULL != (pending = peer->head)) &&
+ (GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value == 0) )
{
- /* client disconnected */
- return 0;
+ peer->pending_count--;
+ GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
+ GNUNET_free (pending);
}
- if (peer->head == NULL)
+ if (pending == NULL)
{
/* no messages pending */
return 0;
}
+ if (buf == NULL)
+ {
+ peer->th
+ = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining (pending->timeout),
+ &peer->id, ntohs (pending->msg->size),
+ &core_transmit_notify, peer);
+ GNUNET_break (NULL != peer->th);
+ return 0;
+ }
off = 0;
while ( (NULL != (pending = peer->head)) &&
(size - off >= (msize = ntohs (pending->msg->size))) )
GNUNET_free (pending);
}
if (peer->head != NULL)
- {
- peer->th
- = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
- pending->importance,
- GNUNET_TIME_absolute_get_remaining (pending->timeout),
- &peer->id, msize,
- &core_transmit_notify, peer);
- }
+ {
+ peer->th
+ = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining (pending->timeout),
+ &peer->id, msize,
+ &core_transmit_notify, peer);
+ GNUNET_break (NULL != peer->th);
+ }
return off;
}
&peer->id,
ntohs (pending->msg->size),
&core_transmit_notify, peer);
+ GNUNET_break (NULL != peer->th);
}
uint32_t forward_count;
float target_value;
- if (hop_count > GDS_NSE_get () * 4.0)
+ if (hop_count > GDS_NSE_get () * 6.0)
{
/* forcefully terminate */
return 0;
}
- if (hop_count > GDS_NSE_get () * 2.0)
+ if (hop_count > GDS_NSE_get () * 4.0)
{
/* Once we have reached our ideal number of hops, only forward to 1 peer */
return 1;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Excluded peer `%s' due to BF match in greedy routing for %s\n",
GNUNET_i2s (&pos->id),
GNUNET_h2s (key));
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Excluded peer `%s' due to BF match in random routing for %s\n",
GNUNET_i2s (&pos->id),
GNUNET_h2s (key));
rtargets[off] = nxt;
GNUNET_break (GNUNET_NO ==
GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey));
+ GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[off]->id.hashPubKey);
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Selected %u/%u peers at hop %u for %s (target was %u)\n",
off,
GNUNET_CONTAINER_multihashmap_size (all_known_peers),
(unsigned int) hop_count,
GNUNET_h2s (key),
ret);
-
if (0 == off)
{
GNUNET_free (rtargets);
return 0;
}
*targets = rtargets;
- for (ret = 0; ret < off; ret++)
- GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[ret]->id.hashPubKey);
return off;
}
struct GNUNET_PeerIdentity *pp;
GNUNET_assert (NULL != bf);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding myself (%s) to PUT bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (key));
GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity.hashPubKey);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# PUT requests routed"), 1,
&targets);
if (0 == target_count)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing PUT for %s terminates after %u hops at %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers selected as targets for PUT requests"), target_count,
+ gettext_noop ("# PUT messages queued for transmission"), target_count,
GNUNET_NO);
for (i=0;i<target_count;i++)
{
target = targets[i];
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing PUT for %s after %u hops to %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
target_count = get_target_peers (key, peer_bf, hop_count,
desired_replication_level,
&targets);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding myself (%s) to GET bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (key));
GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
if (0 == target_count)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing GET for %s terminates after %u hops at %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers selected as targets for GET requests"), target_count,
+ gettext_noop ("# GET messages queued for transmission"), target_count,
GNUNET_NO);
/* forward request */
for (i=0;i<target_count;i++)
{
target = targets[i];
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing GET for %s after %u hops to %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# REPLIES routed"), 1,
+ gettext_noop ("# RESULT messages queued for transmission"), 1,
GNUNET_NO);
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
/* cannot verify, good luck */
break;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PUT for %s at %s\n",
GNUNET_h2s (&put->key),
GNUNET_i2s (&my_identity));
&get->key,
xquery, xquery_size,
reply_bf, get->bf_mutator);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GET for %s at %s after %u hops\n",
GNUNET_h2s (&get->key),
GNUNET_i2s (&my_identity),