diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-02-16 16:24:32 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-02-16 16:24:32 +0000 |
commit | 27a6cee72d7c479853acbeed0047534fd4566deb (patch) | |
tree | d932da0e35e14abb83480b508874fcc9d0efdab2 /src/core/gnunet-service-core.c | |
parent | e054285d845aad88df678b60ee532d71d5115f4b (diff) | |
download | gnunet-27a6cee72d7c479853acbeed0047534fd4566deb.tar.gz gnunet-27a6cee72d7c479853acbeed0047534fd4566deb.zip |
remove double connect notify, add is connected optimization for peer iterate call
Diffstat (limited to 'src/core/gnunet-service-core.c')
-rw-r--r-- | src/core/gnunet-service-core.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 4519991b3..81d851265 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -1498,10 +1498,22 @@ handle_client_iterate_peers (void *cls, | |||
1498 | { | 1498 | { |
1499 | struct GNUNET_MessageHeader done_msg; | 1499 | struct GNUNET_MessageHeader done_msg; |
1500 | struct GNUNET_SERVER_TransmitContext *tc; | 1500 | struct GNUNET_SERVER_TransmitContext *tc; |
1501 | 1501 | struct GNUNET_PeerIdentity *peer; | |
1502 | int msize; | ||
1502 | /* notify new client about existing neighbours */ | 1503 | /* notify new client about existing neighbours */ |
1504 | |||
1505 | msize = ntohs(message->size); | ||
1503 | tc = GNUNET_SERVER_transmit_context_create (client); | 1506 | tc = GNUNET_SERVER_transmit_context_create (client); |
1504 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &queue_connect_message, tc); | 1507 | if (msize == sizeof(struct GNUNET_MessageHeader)) |
1508 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &queue_connect_message, tc); | ||
1509 | else if (msize == sizeof(struct GNUNET_MessageHeader) + sizeof(struct GNUNET_PeerIdentity)) | ||
1510 | { | ||
1511 | peer = (struct GNUNET_PeerIdentity *)&message[1]; | ||
1512 | GNUNET_CONTAINER_multihashmap_get_multiple(neighbours, &peer->hashPubKey, &queue_connect_message, tc); | ||
1513 | } | ||
1514 | else | ||
1515 | GNUNET_break(0); | ||
1516 | |||
1505 | done_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); | 1517 | done_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); |
1506 | done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END); | 1518 | done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END); |
1507 | GNUNET_SERVER_transmit_context_append_message (tc, &done_msg); | 1519 | GNUNET_SERVER_transmit_context_append_message (tc, &done_msg); |
@@ -2908,6 +2920,10 @@ notify_transport_connect_done (void *cls, | |||
2908 | } | 2920 | } |
2909 | if (buf == NULL) | 2921 | if (buf == NULL) |
2910 | { | 2922 | { |
2923 | GNUNET_STATISTICS_update (stats, | ||
2924 | gettext_noop ("# connection requests timed out in transport"), | ||
2925 | 1, | ||
2926 | GNUNET_NO); | ||
2911 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2927 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2912 | _("Failed to connect to `%4s': transport failed to connect\n"), | 2928 | _("Failed to connect to `%4s': transport failed to connect\n"), |
2913 | GNUNET_i2s (&n->peer)); | 2929 | GNUNET_i2s (&n->peer)); |
@@ -2966,10 +2982,20 @@ handle_client_request_connect (void *cls, | |||
2966 | 1, | 2982 | 1, |
2967 | GNUNET_NO); | 2983 | GNUNET_NO); |
2968 | else | 2984 | else |
2969 | GNUNET_STATISTICS_update (stats, | 2985 | { |
2970 | gettext_noop ("# connection requests ignored (already trying)"), | 2986 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(n->th); |
2971 | 1, | 2987 | n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport, |
2972 | GNUNET_NO); | 2988 | &cm->peer, |
2989 | sizeof (struct GNUNET_MessageHeader), 0, | ||
2990 | timeout, | ||
2991 | ¬ify_transport_connect_done, | ||
2992 | n); | ||
2993 | GNUNET_break (NULL != n->th); | ||
2994 | GNUNET_STATISTICS_update (stats, | ||
2995 | gettext_noop ("# connection requests retried (due to repeat request connect)"), | ||
2996 | 1, | ||
2997 | GNUNET_NO); | ||
2998 | } | ||
2973 | return; /* already connected, or at least trying */ | 2999 | return; /* already connected, or at least trying */ |
2974 | } | 3000 | } |
2975 | GNUNET_STATISTICS_update (stats, | 3001 | GNUNET_STATISTICS_update (stats, |