From: Christian Grothoff Date: Sun, 5 Jun 2011 13:26:22 +0000 (+0000) Subject: use new transport API, minor core API change X-Git-Tag: initial-import-from-subversion-38251~18327 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ab1bf63f1ed7637297c90b5b284f40a797f44805;p=oweals%2Fgnunet.git use new transport API, minor core API change --- diff --git a/src/core/Makefile.am b/src/core/Makefile.am index fe86040dc..1ab88033f 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -33,7 +33,7 @@ gnunet_service_core_LDADD = \ $(top_builddir)/src/hello/libgnunethello.la \ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ - $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/transport/libgnunettransportnew.la \ $(top_builddir)/src/util/libgnunetutil.la \ $(GN_LIBINTL) diff --git a/src/core/core.h b/src/core/core.h index 8a8962124..53d1a1b6d 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -470,11 +470,6 @@ struct ConnectMessage */ uint32_t reserved GNUNET_PACKED; - /** - * When to time out. - */ - struct GNUNET_TIME_RelativeNBO timeout; - /** * Identity of the other peer. */ diff --git a/src/core/core_api.c b/src/core/core_api.c index f66eb6d2f..55b693cd1 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -1783,7 +1783,6 @@ peer_request_connect_cont (void *cls, * be called with the TIMEOUT reason code. * * @param h core handle - * @param timeout how long to try to talk to core * @param peer who should we connect to * @param cont function to call once the request has been completed (or timed out) * @param cont_cls closure for cont @@ -1793,7 +1792,6 @@ peer_request_connect_cont (void *cls, */ struct GNUNET_CORE_PeerRequestHandle * GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, - struct GNUNET_TIME_Relative timeout, const struct GNUNET_PeerIdentity * peer, GNUNET_CORE_ControlContinuation cont, void *cont_cls) @@ -1803,7 +1801,7 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, struct ConnectMessage *msg; if (NULL != GNUNET_CONTAINER_multihashmap_get (h->peers, - &peer->hashPubKey)) + &peer->hashPubKey)) { #if DEBUG_CORE GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, @@ -1818,7 +1816,6 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, msg->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT); msg->header.size = htons (sizeof (struct ConnectMessage)); msg->reserved = htonl (0); - msg->timeout = GNUNET_TIME_relative_hton (timeout); msg->peer = *peer; GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, h->control_pending_tail, diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 7053cc603..37960f76a 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -2936,59 +2936,6 @@ handle_client_send (void *cls, } -/** - * Function called when the transport service is ready to - * receive a message. Only resets 'n->th' to NULL. - * - * @param cls neighbour to use message from - * @param size number of bytes we can transmit - * @param buf where to copy the message - * @return number of bytes transmitted - */ -static size_t -notify_transport_connect_done (void *cls, - size_t size, - void *buf) -{ - struct Neighbour *n = cls; - - n->th = NULL; - if (GNUNET_YES != n->is_connected) - { - /* transport should only call us to transmit a message after - * telling us about a successful connection to the respective peer */ -#if DEBUG_CORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Timeout on notify connect!\n"); -#endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connection requests timed out in transport"), - 1, - GNUNET_NO); - return 0; - } - if (buf == NULL) - { - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connection requests timed out in transport"), - 1, - GNUNET_NO); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Failed to connect to `%4s': transport failed to connect\n"), - GNUNET_i2s (&n->peer)); - return 0; - } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"), - GNUNET_i2s (&n->peer)); - if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_SCHEDULER_cancel (n->retry_set_key_task); - n->retry_set_key_task = GNUNET_SCHEDULER_add_now (&set_key_retry_task, - n); - return 0; -} - - /** * Handle CORE_REQUEST_CONNECT request. * @@ -3003,7 +2950,6 @@ handle_client_request_connect (void *cls, { const struct ConnectMessage *cm = (const struct ConnectMessage*) message; struct Neighbour *n; - struct GNUNET_TIME_Relative timeout; if (0 == memcmp (&cm->peer, &my_identity, @@ -3012,64 +2958,33 @@ handle_client_request_connect (void *cls, /* In this case a client has asked us to connect to ourselves, not really an error! */ GNUNET_SERVER_receive_done (client, GNUNET_OK); return; - } - timeout = GNUNET_TIME_relative_ntoh (cm->timeout); + } GNUNET_break (ntohl (cm->reserved) == 0); - GNUNET_SERVER_receive_done (client, GNUNET_OK); - n = find_neighbour (&cm->peer); - if (n == NULL) - n = create_neighbour (&cm->peer); - if ( (GNUNET_YES == n->is_connected) || - (n->th != NULL) ) - { - if (GNUNET_YES == n->is_connected) - { - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connection requests ignored (already connected)"), - 1, - GNUNET_NO); - } - else - { - if (NULL != n->th) - { - GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th); - n->th = NULL; - } - n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport, - &cm->peer, - sizeof (struct GNUNET_MessageHeader), 0, - timeout, - ¬ify_transport_connect_done, - n); - GNUNET_break (NULL != n->th); - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connection requests retried (due to repeat request connect)"), - 1, - GNUNET_NO); - } - return; /* already connected, or at least trying */ - } - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connection requests received"), - 1, - GNUNET_NO); - #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core received `%s' request for `%4s', will try to establish connection\n", "REQUEST_CONNECT", GNUNET_i2s (&cm->peer)); #endif - - /* ask transport to connect to the peer */ - n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport, - &cm->peer, - sizeof (struct GNUNET_MessageHeader), 0, - timeout, - ¬ify_transport_connect_done, - n); - GNUNET_break (NULL != n->th); + GNUNET_STATISTICS_update (stats, + gettext_noop ("# connection requests received"), + 1, + GNUNET_NO); + GNUNET_SERVER_receive_done (client, GNUNET_OK); + n = find_neighbour (&cm->peer); + if ( (n == NULL) || + (GNUNET_YES != n->is_connected) ) + { + GNUNET_TRANSPORT_try_connect (transport, + &cm->peer); + } + else + { + GNUNET_STATISTICS_update (stats, + gettext_noop ("# connection requests ignored (already connected)"), + 1, + GNUNET_NO); + } } diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 38aaf63b1..212dd9d5f 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -255,7 +255,6 @@ init_notify (void *cls, "Asking core (1) to connect to peer `%4s'\n", GNUNET_i2s (&p2.id)); GNUNET_CORE_peer_request_connect (p1.ch, - GNUNET_TIME_UNIT_SECONDS, &p2.id, NULL, NULL); } diff --git a/src/core/test_core_api_preferences.c b/src/core/test_core_api_preferences.c index f4a0713c2..eb56a91fb 100644 --- a/src/core/test_core_api_preferences.c +++ b/src/core/test_core_api_preferences.c @@ -321,7 +321,6 @@ ask_connect_task (void *cls, "Asking core (1) AGAIN to connect to peer `%4s'\n", GNUNET_i2s (&p2.id)); GNUNET_CORE_peer_request_connect (p1.ch, - GNUNET_TIME_UNIT_SECONDS, &p2.id, NULL, NULL); } @@ -371,7 +370,6 @@ init_notify (void *cls, GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &ask_connect_task, NULL); GNUNET_CORE_peer_request_connect (p1.ch, - GNUNET_TIME_UNIT_SECONDS, &p2.id, NULL, NULL); } diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index f21691691..dde274e8d 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -414,7 +414,6 @@ init_notify (void *cls, "Asking core (1) to connect to peer `%4s'\n", GNUNET_i2s (&p2.id)); GNUNET_CORE_peer_request_connect (p1.ch, - GNUNET_TIME_UNIT_SECONDS, &p2.id, NULL, NULL); } diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index d3b49d880..816e7f10a 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -562,7 +562,6 @@ init_notify (void *cls, GNUNET_i2s (&p2.id)); #endif GNUNET_CORE_peer_request_connect (p1.ch, - GNUNET_TIME_UNIT_SECONDS, &p2.id, NULL, NULL); } diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 0bd5dd9f6..44b39c90e 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -2188,8 +2188,6 @@ route_result_message (struct GNUNET_MessageHeader *msg, increment_stats (STAT_HELLOS_PROVIDED); GNUNET_TRANSPORT_offer_hello (transport_handle, hello_msg, NULL, NULL); GNUNET_CORE_peer_request_connect (coreAPI, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 5), &new_peer, NULL, NULL); } } @@ -2712,8 +2710,6 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, increment_stats (STAT_HELLOS_PROVIDED); GNUNET_TRANSPORT_offer_hello (transport_handle, other_hello, NULL, NULL); GNUNET_CORE_peer_request_connect (coreAPI, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 5), &peer_id, NULL, NULL); route_message (find_msg, msg_ctx); GNUNET_free (other_hello); diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index fd4375355..447711867 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h @@ -266,7 +266,6 @@ typedef void (*GNUNET_CORE_ControlContinuation)(void *cls, int success); * be called with the TIMEOUT reason code. * * @param h core handle - * @param timeout how long to try to talk to core * @param peer who should we connect to * @param cont function to call once the request has been completed (or timed out) * @param cont_cls closure for cont @@ -274,7 +273,6 @@ typedef void (*GNUNET_CORE_ControlContinuation)(void *cls, int success); */ struct GNUNET_CORE_PeerRequestHandle * GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, - struct GNUNET_TIME_Relative timeout, const struct GNUNET_PeerIdentity * peer, GNUNET_CORE_ControlContinuation cont, void *cont_cls); diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 8b1655dde..72428790e 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -543,7 +543,6 @@ GNUNET_MESH_peer_request_connect_all (struct GNUNET_MESH_Handle *handle, handle->pending_tunnels.tail, tunnel); (void) GNUNET_CORE_peer_request_connect (handle->core, - timeout, peers, NULL, NULL); } diff --git a/src/testing/testing.c b/src/testing/testing.c index dafe0efbe..78bc99ae4 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -1788,7 +1788,6 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (ctx->d1core != NULL); ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (ctx->d1core, - ctx->relative_timeout, &ctx->d2->id, &core_connect_request_cont, ctx); @@ -1831,7 +1830,6 @@ core_init_notify (void *cls, { connect_ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (connect_ctx->d1core, - connect_ctx->relative_timeout, &connect_ctx->d2->id, &core_connect_request_cont, connect_ctx); GNUNET_assert(connect_ctx->connect_request_handle != NULL); @@ -1931,7 +1929,6 @@ reattempt_daemons_connect (void *cls, { ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (ctx->d1core, - ctx->relative_timeout, &ctx->d2->id, &core_connect_request_cont, ctx); } diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index b42ce8cc5..6c5dbd12b 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -3249,7 +3249,6 @@ send_core_connect_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContext while (conn != NULL) { GNUNET_CORE_peer_request_connect(send_hello_context->peer->daemon->server, - GNUNET_TIME_relative_get_forever(), &send_hello_context->pg->peers[conn->index].daemon->id, NULL, NULL); diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 2fa336754..03699c174 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -268,7 +268,7 @@ whitelist_peers () /** - * Function called by core when our attempt to connect succeeded. + * Function called by core when our request to connect was transmitted. * * @param cls the 'struct Peer' for which we issued the connect request * @param success was the request transmitted @@ -414,7 +414,6 @@ attempt_connect (struct Peer *pos) 1, GNUNET_NO); pos->connect_req = GNUNET_CORE_peer_request_connect (handle, - GNUNET_TIME_UNIT_MINUTES, &pos->pid, &connect_completed_callback, pos); @@ -932,7 +931,7 @@ static void process_peer (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, - const char *err_msg) + const char *err_msg) { struct Peer *pos;