off += msize;
peer->pending_count--;
increment_stats ("# pending messages sent");
- GNUNET_assert (peer->pending_count >= 0);
GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
GNUNET_free (pending);
pending = peer->head;
*
* @param peer the peer identity of the peer being added
* @param bucket the bucket that we want this peer to go in
- * @param latency transport latency of this peer
- * @param distance transport distance to this peer
+ * @param atsi transport ATS information
*
* @return NULL if the peer was not added,
* pointer to PeerInfo for new peer otherwise
* @param client the client to send the reply to
* @param message the encapsulated message to send
* @param uid the unique identifier of this request
+ * @param key key
*/
static void
send_reply_to_client (struct ClientList *client,
else
random_value =
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
- (unsigned int) -1);
+ UINT32_MAX);
- if (random_value < (target_value * (unsigned int) -1))
+ if (random_value < (target_value * UINT32_MAX))
forward_count += 1;
return forward_count;
*
* @param target the key we are selecting a peer to route to
* @param bloom a bloomfilter containing entries this request has seen already
+ * @param hops how many hops has this message traversed thus far
*
* @return Peer to route to, or NULL on error
*/
&sorted_closest[i]->id.
hashPubKey))
break; /* Ignore bloomfiltered peers */
- if ((temp_converge_distance <= ULLONG_MAX) && (total_distance + temp_converge_distance > total_distance)) /* Handle largest case and overflow */
+ if (total_distance + temp_converge_distance > total_distance) /* Handle largest case and overflow */
total_distance += temp_converge_distance;
else
break; /* overflow case */
continue; /* Ignore bloomfiltered peers */
}
temp_converge_distance = converge_distance (target, pos, hops);
- if ((temp_converge_distance <= ULLONG_MAX) && (total_distance + temp_converge_distance > total_distance)) /* Handle largest case and overflow */
+ if (total_distance + temp_converge_distance > total_distance) /* Handle largest case and overflow */
total_distance += temp_converge_distance;
else
break; /* overflow case */
continue; /* Ignore bloomfiltered peers */
}
temp_converge_distance = converge_distance (target, pos, hops);
- if ((temp_converge_distance <= ULLONG_MAX) && (total_distance + temp_converge_distance > total_distance)) /* Handle largest case and overflow */
+ if (total_distance + temp_converge_distance > total_distance) /* Handle largest case and overflow */
total_distance += temp_converge_distance;
else
break; /* overflow case */
break; /* Ignore bloomfiltered peers */
temp_converge_distance =
converge_distance (target, sorted_closest[i], hops);
- if ((temp_converge_distance <= ULLONG_MAX) && (stats_total_distance + temp_converge_distance > stats_total_distance)) /* Handle largest case and overflow */
+ if (stats_total_distance + temp_converge_distance > stats_total_distance) /* Handle largest case and overflow */
stats_total_distance += temp_converge_distance;
else
break; /* overflow case */
continue; /* Ignore bloomfiltered peers */
}
temp_converge_distance = converge_distance (target, pos, hops);
- if ((temp_converge_distance <= ULLONG_MAX) && (stats_total_distance + temp_converge_distance > stats_total_distance)) /* Handle largest case and overflow */
+ if (stats_total_distance + temp_converge_distance > stats_total_distance) /* Handle largest case and overflow */
stats_total_distance += temp_converge_distance;
else
break; /* overflow case */
continue; /* Ignore bloomfiltered peers */
}
temp_converge_distance = converge_distance (target, pos, hops);
- if ((temp_converge_distance <= ULLONG_MAX) && (stats_total_distance + temp_converge_distance > stats_total_distance)) /* Handle largest case and overflow */
+ if (stats_total_distance + temp_converge_distance > stats_total_distance) /* Handle largest case and overflow */
stats_total_distance += temp_converge_distance;
else
break; /* overflow case */
GNUNET_free (record);
}
if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel (source_info->delete_task);
+ {
+ GNUNET_SCHEDULER_cancel (source_info->delete_task);
+ source_info->delete_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (source_info->find_peers_responded != NULL)
GNUNET_CONTAINER_bloomfilter_free (source_info->find_peers_responded);
GNUNET_free (source_info);
memcpy (&put_msg[1], data, size);
new_msg_ctx->unique_id =
GNUNET_ntohll (GNUNET_CRYPTO_random_u64
- (GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t) - 1));
+ (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX));
new_msg_ctx->replication = ntohl (DEFAULT_PUT_REPLICATION);
new_msg_ctx->msg_options = ntohl (0);
new_msg_ctx->network_size = estimate_diameter ();
GNUNET_CONTAINER_DLL_remove (record->head, record->tail, pos);
GNUNET_CONTAINER_heap_remove_node (forward_list.minHeap, pos->hnode);
if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel (pos->delete_task);
-
+ {
+ GNUNET_SCHEDULER_cancel (pos->delete_task);
+ pos->delete_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (pos->find_peers_responded != NULL)
GNUNET_CONTAINER_bloomfilter_free (pos->find_peers_responded);
GNUNET_free (pos);
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever ());
memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext));
random_key =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t) - 1);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
GNUNET_CRYPTO_hash (&random_key, sizeof (uint32_t), &key);
memcpy (&msg_ctx.key, &key, sizeof (GNUNET_HashCode));
msg_ctx.unique_id =
GNUNET_ntohll (GNUNET_CRYPTO_random_u64
- (GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t) - 1));
+ (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX));
msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION);
msg_ctx.msg_options = ntohl (0);
msg_ctx.network_size = estimate_diameter ();
get_message.type = htonl (GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE);
memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext));
random_key =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t) - 1);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
GNUNET_CRYPTO_hash (&random_key, sizeof (uint32_t), &key);
memcpy (&msg_ctx.key, &key, sizeof (GNUNET_HashCode));
msg_ctx.unique_id =
GNUNET_ntohll (GNUNET_CRYPTO_random_u64
- (GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t) - 1));
+ (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX));
msg_ctx.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION);
msg_ctx.msg_options = ntohl (0);
msg_ctx.network_size = estimate_diameter ();
memcpy (&msg_ctx.key, &my_identity.hashPubKey, sizeof (GNUNET_HashCode));
msg_ctx.unique_id =
GNUNET_ntohll (GNUNET_CRYPTO_random_u64
- (GNUNET_CRYPTO_QUALITY_STRONG, (uint64_t) - 1));
+ (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX));
msg_ctx.replication = DHT_DEFAULT_FIND_PEER_REPLICATION;
msg_ctx.msg_options = DHT_DEFAULT_FIND_PEER_OPTIONS;
msg_ctx.network_size = estimate_diameter ();
/* If the client is non-null (local request) and the client matches the requesting client, remove the entry. */
if ((pos->client != NULL) && (pos->client->client_handle == client))
{
- GNUNET_SCHEDULER_cancel (pos->delete_task);
- pos->delete_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_SCHEDULER_add_continuation (&remove_forward_entry, pos,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (pos->delete_task);
+ pos->delete_task = GNUNET_SCHEDULER_add_now (&remove_forward_entry, pos);
}
pos = pos->next;
}
/**
* Core handler for p2p route requests.
+ *
+ * @param cls closure
+ * @param message message
+ * @param peer peer identity this notification is about
+ * @param atsi performance data
+ *
*/
static int
handle_dht_p2p_route_request (void *cls,
/**
* Core handler for p2p route results.
+ *
+ * @param cls closure
+ * @param message message
+ * @param peer peer identity this notification is about
+ * @param atsi performance data
+ *
*/
static int
handle_dht_p2p_route_result (void *cls,
{
struct PeerInfo *ret;
+ /* Check for connect to self message */
+ if (0 == memcmp(&my_identity, peer, sizeof(struct GNUNET_PeerIdentity)))
+ return;
+
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s:%s Receives core connect message for peer %s distance %d!\n",
struct PeerInfo *to_remove;
int current_bucket;
+ /* Check for disconnect from self message */
+ if (0 == memcmp(&my_identity, peer, sizeof(struct GNUNET_PeerIdentity)))
+ return;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s:%s: Received peer disconnect message for peer `%s' from %s\n",
my_short_id, "DHT", GNUNET_i2s (peer), "CORE");