X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fcore%2Fgnunet-service-core_neighbours.c;h=65b4ba41a218e1e6efe8b2c04d59e4c7c3bdffbe;hb=6c471eeb15e27f8226492b4860a3c2acb94c5f25;hp=5014298bfb4dfdb8b450d6623cee32db4b259712;hpb=83b19539f4d322b43683f5838b72e9ec2c8e6073;p=oweals%2Fgnunet.git diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c index 5014298bf..65b4ba41a 100644 --- a/src/core/gnunet-service-core_neighbours.c +++ b/src/core/gnunet-service-core_neighbours.c @@ -129,6 +129,8 @@ static struct GNUNET_TRANSPORT_Handle *transport; static struct Neighbour * find_neighbour (const struct GNUNET_PeerIdentity *peer) { + if (NULL == neighbours) + return NULL; return GNUNET_CONTAINER_multihashmap_get (neighbours, &peer->hashPubKey); } @@ -143,11 +145,9 @@ free_neighbour (struct Neighbour *n) { struct NeighbourMessageEntry *m; -#if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying neighbour entry for peer `%4s'\n", GNUNET_i2s (&n->peer)); -#endif while (NULL != (m = n->message_head)) { GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m); @@ -222,29 +222,24 @@ transmit_ready (void *cls, size_t size, void *buf) GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m); if (buf == NULL) { -#if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission of message of type %u and size %u failed\n", (unsigned int) ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), (unsigned int) m->size); -#endif GNUNET_free (m); process_queue (n); return 0; } - ret = 0; cbuf = buf; GNUNET_assert (size >= m->size); memcpy (cbuf, &m[1], m->size); ret = m->size; -#if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copied message of type %u and size %u into transport buffer for `%4s'\n", (unsigned int) ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), (unsigned int) ret, GNUNET_i2s (&n->peer)); -#endif GNUNET_free (m); process_queue (n); GNUNET_STATISTICS_update (GSC_stats, @@ -276,13 +271,11 @@ process_queue (struct Neighbour *n) GSC_SESSIONS_solicit (&n->peer); return; } -#if DEBUG_CORE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n", (unsigned int) m->size, GNUNET_i2s (&n->peer), (unsigned long long) GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value); -#endif n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, 0, GNUNET_TIME_absolute_get_remaining @@ -329,10 +322,8 @@ handle_transport_notify_connect (void *cls, GNUNET_break (0); return; } -#if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n", GNUNET_i2s (peer)); -#endif n = GNUNET_malloc (sizeof (struct Neighbour)); n->peer = *peer; GNUNET_assert (GNUNET_OK == @@ -360,11 +351,9 @@ handle_transport_notify_disconnect (void *cls, { struct Neighbour *n; -#if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected from us; received notification from transport.\n", GNUNET_i2s (peer)); -#endif n = find_neighbour (peer); if (n == NULL) { @@ -393,11 +382,9 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, struct Neighbour *n; uint16_t type; -#if DEBUG_CORE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u from `%4s', demultiplexing.\n", (unsigned int) ntohs (message->type), GNUNET_i2s (peer)); -#endif if (0 == memcmp (peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity))) { GNUNET_break (0); @@ -427,8 +414,10 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Unsupported message of type %u received.\n"), - (unsigned int) type); + _ + ("Unsupported message of type %u (%u bytes) received from peer `%s'\n"), + (unsigned int) type, (unsigned int) ntohs (message->size), + GNUNET_i2s (peer)); return; } } @@ -497,7 +486,7 @@ GSC_NEIGHBOURS_init () * @return GNUNET_OK (continue to iterate) */ static int -free_neighbour_helper (void *cls, const GNUNET_HashCode * key, void *value) +free_neighbour_helper (void *cls, const struct GNUNET_HashCode * key, void *value) { struct Neighbour *n = value;