*/
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, pending->importance, pending->timeout, &pending->recipient, pending->msg_size, &core_transmit_notify, NULL);
}
/**
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++)
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);
struct DistantNeighbor *referee;
struct FindDestinationContext fdc;
struct DisconnectContext disconnect_context;
+ struct PendingMessage *pending_pos;
#if DEBUG_DV
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
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);
}
/* 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);
}
#include "gnunet_testing_lib.h"
#include "gnunet_core_service.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
#define TEST_ALL GNUNET_NO
{NULL, 0, 0}
};
+/**
+ * Notify of all peer1's peers, once peer 2 is found, schedule connect
+ * to peer two for message send.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ * @param atsi performance data for the connection
+ */
+static void connect_notify_peer2 (void *cls,
+ const struct
+ GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+ struct TestMessageContext *pos = cls;
+
+ if (0 == memcmp(&pos->peer1->id, peer, sizeof(struct GNUNET_PeerIdentity)))
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Core connection from `%s' to `%4s' verfied, sending message!\n",
+ GNUNET_i2s(&pos->peer2->id), GNUNET_h2s (&peer->hashPubKey));
+#endif
+ if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
+ 0,
+ TIMEOUT,
+ &pos->peer2->id,
+ sizeof (struct GNUNET_TestMessage),
+ &transmit_ready, pos))
+ {
+ /* This probably shouldn't happen, but it does (timing issue?) */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
+ GNUNET_i2s (&pos->peer2->id));
+ transmit_ready_failed++;
+ total_other_expected_messages--;
+ }
+ else
+ {
+ transmit_ready_scheduled++;
+ }
+ }
+}
+
static void
init_notify_peer2 (void *cls,
struct GNUNET_CORE_Handle *server,
const struct GNUNET_PeerIdentity *my_identity,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
{
- struct TestMessageContext *pos = cls;
-
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core connection to `%4s' established, scheduling message send\n",
+ "Core connection to `%4s' established, awaiting connections.\n",
GNUNET_i2s (my_identity));
#endif
total_server_connections++;
+}
- if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
- 0,
- TIMEOUT,
- &pos->peer2->id,
- sizeof (struct GNUNET_TestMessage),
- &transmit_ready, pos))
+/**
+ * Notify of all peer1's peers, once peer 2 is found, schedule connect
+ * to peer two for message send.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ * @param atsi performance data for the connection
+ */
+static void connect_notify_peer1 (void *cls,
+ const struct
+ GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+ struct TestMessageContext *pos = cls;
+
+ if (0 == memcmp(&pos->peer2->id, peer, sizeof(struct GNUNET_PeerIdentity)))
{
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
- GNUNET_i2s (&pos->peer2->id));
- transmit_ready_failed++;
- }
- else
- {
- transmit_ready_scheduled++;
+ "Core connection from `%s' to `%4s' verified.\n",
+ GNUNET_i2s(&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey));
+#endif
+ /*
+ * Connect to the receiving peer
+ */
+ pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
+ 1,
+ pos,
+ &init_notify_peer2,
+ &connect_notify_peer2,
+ NULL,
+ NULL, NULL,
+ GNUNET_YES, NULL, GNUNET_YES, handlers);
}
}
-
static void
init_notify_peer1 (void *cls,
struct GNUNET_CORE_Handle *server,
const struct GNUNET_PeerIdentity *my_identity,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
{
- struct TestMessageContext *pos = cls;
total_server_connections++;
-
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core connection to `%4s' established, setting up handles\n",
+ "Core connection to `%4s' established, awaiting connections...\n",
GNUNET_i2s (my_identity));
#endif
-
- /*
- * Connect to the receiving peer
- */
- pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
- 1,
- pos,
- &init_notify_peer2,
- NULL,
- NULL,
- NULL, NULL,
- GNUNET_YES, NULL, GNUNET_YES, handlers);
}
1,
pos,
&init_notify_peer1,
- NULL, NULL,
+ &connect_notify_peer1,
+ NULL,
NULL,
NULL,
GNUNET_NO, NULL, GNUNET_NO, no_handlers);
temp_context->uid = total_connections;
temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
test_messages = temp_context;
-
expected_messages++;
-
}
#if VERBOSE
else
}
#endif
-
if (dotOutFile != NULL)
{
if (distance == 1)