*/
static void
try_core_send (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PendingMessage *pending;
pending = core_pending_head;
if (core_transmit_handle != NULL)
return; /* Message send already in progress */
- if (pending != NULL)
- core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, pending->importance, pending->timeout, &pending->recipient, pending->msg_size, &core_transmit_notify, NULL);
+ if ((pending != NULL) && (coreAPI != NULL))
+ core_transmit_handle = GNUNET_CORE_notify_transmit_ready (coreAPI,
+ GNUNET_YES,
+ pending->importance,
+ pending->timeout,
+ &pending->recipient,
+ pending->msg_size,
+ &core_transmit_notify, NULL);
}
+
/**
* Function called to notify a client about the socket
* being ready to queue more data. "buf" will be
GNUNET_SCHEDULER_add_now(&try_core_send, NULL);
/*if (reply != NULL)
- core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, reply->importance, reply->timeout, &reply->recipient, reply->msg_size, &core_transmit_notify, NULL);*/
+ core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, GNUNET_YES, reply->importance, reply->timeout, &reply->recipient, reply->msg_size, &core_transmit_notify, NULL);*/
return off;
}
* @param cls closure
* @param peer peer which sent the message (immediate sender)
* @param message the message
- * @param latency the latency of the connection we received the message from
- * @param distance the distance to the immediate peer
+ * @param atsi transport ATS information (latency, distance, etc.)
*/
static int
handle_dv_data_message (void *cls,
pos = pos->next;
}
#endif
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "%s: unknown sender (%u), Message uid %u from %s!\n", my_short_id, ntohl(incoming->sender), ntohl(incoming->uid), GNUNET_i2s(&dn->identity));
found_pos = -1;
for (i = 0; i< MAX_OUTSTANDING_MESSAGES; i++)
p2p_dv_MESSAGE_NeighborInfo *message;
struct PendingMessage *pending_message;
- if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
+ if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
{
#if DEBUG_DV_GOSSIP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_SCHEDULER_add_now(try_core_send, NULL);
/*if (core_transmit_handle == NULL)
- core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);*/
+ core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, GNUNET_YES, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);*/
}
GNUNET_CONTAINER_DLL_remove (referrer->referee_head,
referrer->referee_tail, referee);
}
- GNUNET_CONTAINER_heap_remove_node (neighbor_max_heap, referee->max_loc);
- GNUNET_CONTAINER_heap_remove_node (neighbor_min_heap, referee->min_loc);
+ GNUNET_CONTAINER_heap_remove_node (referee->max_loc);
+ GNUNET_CONTAINER_heap_remove_node (referee->min_loc);
GNUNET_CONTAINER_multihashmap_remove_all (extended_neighbors,
&referee->identity.hashPubKey);
GNUNET_free_non_null (referee->pkey);
GNUNET_SCHEDULER_add_now(try_core_send, NULL);
/*if (core_transmit_handle == NULL)
- core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), ¬ify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL);*/
+ core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, GNUNET_YES, default_dv_priority, GNUNET_TIME_relative_get_forever(), ¬ify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL);*/
return GNUNET_YES;
}
GNUNET_CONTAINER_heap_destroy(neighbor_min_heap);
GNUNET_CORE_disconnect (coreAPI);
+ coreAPI = NULL;
GNUNET_PEERINFO_disconnect(peerinfo_handle);
GNUNET_SERVER_mst_destroy(coreMST);
GNUNET_free_non_null(my_short_id);
&update_matching_neighbors,
neighbor_update) != GNUNET_SYSERR))
{
-
#if AT_MOST_ONE
if ((neighbor != NULL) && (cost < neighbor->cost)) /* New cost is less than old, remove old */
{
* @param cls closure
* @param peer id of the peer, NULL for last call
* @param hello hello message for the peer (can be NULL)
+ * @param err_msg NULL if successful, otherwise contains error message
*/
static void
process_peerinfo (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
{
struct PeerIteratorContext *peerinfo_iterator = cls;
struct DirectNeighbor *neighbor = peerinfo_iterator->neighbor;
char *neighbor_pid;
#endif
int sent;
-
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
if (peer == NULL)
{
if (distant->pkey == NULL)
struct DistantNeighbor *about;
struct PeerIteratorContext *peerinfo_iterator;
int sent;
-#if DEBUG_DV
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s: Receives core connect message for peer %s distance %d!\n", "dv", GNUNET_i2s(peer), distance);
-#endif
+
uint32_t distance;
+ /* Check for connect to self message */
+ if (0 == memcmp(&my_identity, peer, sizeof(struct GNUNET_PeerIdentity)))
+ return;
+
distance = get_atsi_distance (atsi);
if ((distance == DIRECT_NEIGHBOR_COST) &&
(GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey) == NULL))
{
sent = GNUNET_CONTAINER_multihashmap_iterate(direct_neighbors, &add_distant_all_direct_neighbors, about);
if (stats != NULL)
- {
- GNUNET_STATISTICS_update (stats, "# direct peers gossiped to new direct neighbors", sent, GNUNET_NO);
- }
+ GNUNET_STATISTICS_update (stats, "# direct peers gossiped to new direct neighbors", sent, GNUNET_NO);
}
#if DEBUG_DV
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
struct DistantNeighbor *referee;
struct FindDestinationContext fdc;
struct DisconnectContext disconnect_context;
+ struct PendingMessage *pending_pos;
#if DEBUG_DV
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s: Receives core peer disconnect message!\n", "dv");
#endif
+ /* Check for disconnect from self message */
+ if (0 == memcmp(&my_identity, peer, sizeof(struct GNUNET_PeerIdentity)))
+ return;
+
neighbor =
GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey);
+
if (neighbor == NULL)
{
return;
}
+
+ pending_pos = core_pending_head;
+ while (NULL != pending_pos)
+ {
+ if (0 == memcmp(&pending_pos->recipient, &neighbor->identity, sizeof(struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_CONTAINER_DLL_remove(core_pending_head, core_pending_tail, pending_pos);
+ pending_pos = core_pending_head;
+ }
+ else
+ pending_pos = pending_pos->next;
+ }
+
while (NULL != (referee = neighbor->referee_head))
distant_neighbor_free (referee);
GNUNET_assert (neighbor->referee_tail == NULL);
if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors,
- &peer->hashPubKey, neighbor))
+ &peer->hashPubKey, neighbor))
{
GNUNET_break(0);
}
- if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK))
+ if ((neighbor->send_context != NULL) &&
+ (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK))
GNUNET_SCHEDULER_cancel(neighbor->send_context->task);
GNUNET_free (neighbor);
}
coreMST = GNUNET_SERVER_mst_create (&tokenized_message_handler,
NULL);
- peerinfo_handle = GNUNET_PEERINFO_connect(cfg);
+ peerinfo_handle = GNUNET_PEERINFO_connect(cfg);
if (peerinfo_handle == NULL)
{
/* Scheduled the task to clean up when shutdown is called */
cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ &shutdown_task,
+ NULL);
}