diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-05 13:26:22 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-05 13:26:22 +0000 |
commit | ab1bf63f1ed7637297c90b5b284f40a797f44805 (patch) | |
tree | 64bedd1cc5620f690d6ad099c2fb4b45a9a41f03 /src/core | |
parent | 446dcf7697ebdd7c78a48573a5c73fbf25448c74 (diff) | |
download | gnunet-ab1bf63f1ed7637297c90b5b284f40a797f44805.tar.gz gnunet-ab1bf63f1ed7637297c90b5b284f40a797f44805.zip |
use new transport API, minor core API change
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Makefile.am | 2 | ||||
-rw-r--r-- | src/core/core.h | 5 | ||||
-rw-r--r-- | src/core/core_api.c | 5 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 125 | ||||
-rw-r--r-- | src/core/test_core_api.c | 1 | ||||
-rw-r--r-- | src/core/test_core_api_preferences.c | 2 | ||||
-rw-r--r-- | src/core/test_core_api_reliability.c | 1 | ||||
-rw-r--r-- | src/core/test_core_quota_compliance.c | 1 |
8 files changed, 22 insertions, 120 deletions
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 = \ | |||
33 | $(top_builddir)/src/hello/libgnunethello.la \ | 33 | $(top_builddir)/src/hello/libgnunethello.la \ |
34 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 34 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
35 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 35 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
36 | $(top_builddir)/src/transport/libgnunettransport.la \ | 36 | $(top_builddir)/src/transport/libgnunettransportnew.la \ |
37 | $(top_builddir)/src/util/libgnunetutil.la \ | 37 | $(top_builddir)/src/util/libgnunetutil.la \ |
38 | $(GN_LIBINTL) | 38 | $(GN_LIBINTL) |
39 | 39 | ||
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 | |||
@@ -471,11 +471,6 @@ struct ConnectMessage | |||
471 | uint32_t reserved GNUNET_PACKED; | 471 | uint32_t reserved GNUNET_PACKED; |
472 | 472 | ||
473 | /** | 473 | /** |
474 | * When to time out. | ||
475 | */ | ||
476 | struct GNUNET_TIME_RelativeNBO timeout; | ||
477 | |||
478 | /** | ||
479 | * Identity of the other peer. | 474 | * Identity of the other peer. |
480 | */ | 475 | */ |
481 | struct GNUNET_PeerIdentity peer; | 476 | struct GNUNET_PeerIdentity 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, | |||
1783 | * be called with the TIMEOUT reason code. | 1783 | * be called with the TIMEOUT reason code. |
1784 | * | 1784 | * |
1785 | * @param h core handle | 1785 | * @param h core handle |
1786 | * @param timeout how long to try to talk to core | ||
1787 | * @param peer who should we connect to | 1786 | * @param peer who should we connect to |
1788 | * @param cont function to call once the request has been completed (or timed out) | 1787 | * @param cont function to call once the request has been completed (or timed out) |
1789 | * @param cont_cls closure for cont | 1788 | * @param cont_cls closure for cont |
@@ -1793,7 +1792,6 @@ peer_request_connect_cont (void *cls, | |||
1793 | */ | 1792 | */ |
1794 | struct GNUNET_CORE_PeerRequestHandle * | 1793 | struct GNUNET_CORE_PeerRequestHandle * |
1795 | GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, | 1794 | GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, |
1796 | struct GNUNET_TIME_Relative timeout, | ||
1797 | const struct GNUNET_PeerIdentity * peer, | 1795 | const struct GNUNET_PeerIdentity * peer, |
1798 | GNUNET_CORE_ControlContinuation cont, | 1796 | GNUNET_CORE_ControlContinuation cont, |
1799 | void *cont_cls) | 1797 | void *cont_cls) |
@@ -1803,7 +1801,7 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, | |||
1803 | struct ConnectMessage *msg; | 1801 | struct ConnectMessage *msg; |
1804 | 1802 | ||
1805 | if (NULL != GNUNET_CONTAINER_multihashmap_get (h->peers, | 1803 | if (NULL != GNUNET_CONTAINER_multihashmap_get (h->peers, |
1806 | &peer->hashPubKey)) | 1804 | &peer->hashPubKey)) |
1807 | { | 1805 | { |
1808 | #if DEBUG_CORE | 1806 | #if DEBUG_CORE |
1809 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1807 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
@@ -1818,7 +1816,6 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, | |||
1818 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT); | 1816 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT); |
1819 | msg->header.size = htons (sizeof (struct ConnectMessage)); | 1817 | msg->header.size = htons (sizeof (struct ConnectMessage)); |
1820 | msg->reserved = htonl (0); | 1818 | msg->reserved = htonl (0); |
1821 | msg->timeout = GNUNET_TIME_relative_hton (timeout); | ||
1822 | msg->peer = *peer; | 1819 | msg->peer = *peer; |
1823 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, | 1820 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, |
1824 | h->control_pending_tail, | 1821 | 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 | |||
@@ -2937,59 +2937,6 @@ handle_client_send (void *cls, | |||
2937 | 2937 | ||
2938 | 2938 | ||
2939 | /** | 2939 | /** |
2940 | * Function called when the transport service is ready to | ||
2941 | * receive a message. Only resets 'n->th' to NULL. | ||
2942 | * | ||
2943 | * @param cls neighbour to use message from | ||
2944 | * @param size number of bytes we can transmit | ||
2945 | * @param buf where to copy the message | ||
2946 | * @return number of bytes transmitted | ||
2947 | */ | ||
2948 | static size_t | ||
2949 | notify_transport_connect_done (void *cls, | ||
2950 | size_t size, | ||
2951 | void *buf) | ||
2952 | { | ||
2953 | struct Neighbour *n = cls; | ||
2954 | |||
2955 | n->th = NULL; | ||
2956 | if (GNUNET_YES != n->is_connected) | ||
2957 | { | ||
2958 | /* transport should only call us to transmit a message after | ||
2959 | * telling us about a successful connection to the respective peer */ | ||
2960 | #if DEBUG_CORE | ||
2961 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2962 | "Timeout on notify connect!\n"); | ||
2963 | #endif | ||
2964 | GNUNET_STATISTICS_update (stats, | ||
2965 | gettext_noop ("# connection requests timed out in transport"), | ||
2966 | 1, | ||
2967 | GNUNET_NO); | ||
2968 | return 0; | ||
2969 | } | ||
2970 | if (buf == NULL) | ||
2971 | { | ||
2972 | GNUNET_STATISTICS_update (stats, | ||
2973 | gettext_noop ("# connection requests timed out in transport"), | ||
2974 | 1, | ||
2975 | GNUNET_NO); | ||
2976 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
2977 | _("Failed to connect to `%4s': transport failed to connect\n"), | ||
2978 | GNUNET_i2s (&n->peer)); | ||
2979 | return 0; | ||
2980 | } | ||
2981 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
2982 | _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"), | ||
2983 | GNUNET_i2s (&n->peer)); | ||
2984 | if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) | ||
2985 | GNUNET_SCHEDULER_cancel (n->retry_set_key_task); | ||
2986 | n->retry_set_key_task = GNUNET_SCHEDULER_add_now (&set_key_retry_task, | ||
2987 | n); | ||
2988 | return 0; | ||
2989 | } | ||
2990 | |||
2991 | |||
2992 | /** | ||
2993 | * Handle CORE_REQUEST_CONNECT request. | 2940 | * Handle CORE_REQUEST_CONNECT request. |
2994 | * | 2941 | * |
2995 | * @param cls unused | 2942 | * @param cls unused |
@@ -3003,7 +2950,6 @@ handle_client_request_connect (void *cls, | |||
3003 | { | 2950 | { |
3004 | const struct ConnectMessage *cm = (const struct ConnectMessage*) message; | 2951 | const struct ConnectMessage *cm = (const struct ConnectMessage*) message; |
3005 | struct Neighbour *n; | 2952 | struct Neighbour *n; |
3006 | struct GNUNET_TIME_Relative timeout; | ||
3007 | 2953 | ||
3008 | if (0 == memcmp (&cm->peer, | 2954 | if (0 == memcmp (&cm->peer, |
3009 | &my_identity, | 2955 | &my_identity, |
@@ -3012,64 +2958,33 @@ handle_client_request_connect (void *cls, | |||
3012 | /* In this case a client has asked us to connect to ourselves, not really an error! */ | 2958 | /* In this case a client has asked us to connect to ourselves, not really an error! */ |
3013 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2959 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
3014 | return; | 2960 | return; |
3015 | } | 2961 | } |
3016 | timeout = GNUNET_TIME_relative_ntoh (cm->timeout); | ||
3017 | GNUNET_break (ntohl (cm->reserved) == 0); | 2962 | GNUNET_break (ntohl (cm->reserved) == 0); |
3018 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
3019 | n = find_neighbour (&cm->peer); | ||
3020 | if (n == NULL) | ||
3021 | n = create_neighbour (&cm->peer); | ||
3022 | if ( (GNUNET_YES == n->is_connected) || | ||
3023 | (n->th != NULL) ) | ||
3024 | { | ||
3025 | if (GNUNET_YES == n->is_connected) | ||
3026 | { | ||
3027 | GNUNET_STATISTICS_update (stats, | ||
3028 | gettext_noop ("# connection requests ignored (already connected)"), | ||
3029 | 1, | ||
3030 | GNUNET_NO); | ||
3031 | } | ||
3032 | else | ||
3033 | { | ||
3034 | if (NULL != n->th) | ||
3035 | { | ||
3036 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th); | ||
3037 | n->th = NULL; | ||
3038 | } | ||
3039 | n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport, | ||
3040 | &cm->peer, | ||
3041 | sizeof (struct GNUNET_MessageHeader), 0, | ||
3042 | timeout, | ||
3043 | ¬ify_transport_connect_done, | ||
3044 | n); | ||
3045 | GNUNET_break (NULL != n->th); | ||
3046 | GNUNET_STATISTICS_update (stats, | ||
3047 | gettext_noop ("# connection requests retried (due to repeat request connect)"), | ||
3048 | 1, | ||
3049 | GNUNET_NO); | ||
3050 | } | ||
3051 | return; /* already connected, or at least trying */ | ||
3052 | } | ||
3053 | GNUNET_STATISTICS_update (stats, | ||
3054 | gettext_noop ("# connection requests received"), | ||
3055 | 1, | ||
3056 | GNUNET_NO); | ||
3057 | |||
3058 | #if DEBUG_CORE | 2963 | #if DEBUG_CORE |
3059 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2964 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3060 | "Core received `%s' request for `%4s', will try to establish connection\n", | 2965 | "Core received `%s' request for `%4s', will try to establish connection\n", |
3061 | "REQUEST_CONNECT", | 2966 | "REQUEST_CONNECT", |
3062 | GNUNET_i2s (&cm->peer)); | 2967 | GNUNET_i2s (&cm->peer)); |
3063 | #endif | 2968 | #endif |
3064 | 2969 | GNUNET_STATISTICS_update (stats, | |
3065 | /* ask transport to connect to the peer */ | 2970 | gettext_noop ("# connection requests received"), |
3066 | n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport, | 2971 | 1, |
3067 | &cm->peer, | 2972 | GNUNET_NO); |
3068 | sizeof (struct GNUNET_MessageHeader), 0, | 2973 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
3069 | timeout, | 2974 | n = find_neighbour (&cm->peer); |
3070 | ¬ify_transport_connect_done, | 2975 | if ( (n == NULL) || |
3071 | n); | 2976 | (GNUNET_YES != n->is_connected) ) |
3072 | GNUNET_break (NULL != n->th); | 2977 | { |
2978 | GNUNET_TRANSPORT_try_connect (transport, | ||
2979 | &cm->peer); | ||
2980 | } | ||
2981 | else | ||
2982 | { | ||
2983 | GNUNET_STATISTICS_update (stats, | ||
2984 | gettext_noop ("# connection requests ignored (already connected)"), | ||
2985 | 1, | ||
2986 | GNUNET_NO); | ||
2987 | } | ||
3073 | } | 2988 | } |
3074 | 2989 | ||
3075 | 2990 | ||
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, | |||
255 | "Asking core (1) to connect to peer `%4s'\n", | 255 | "Asking core (1) to connect to peer `%4s'\n", |
256 | GNUNET_i2s (&p2.id)); | 256 | GNUNET_i2s (&p2.id)); |
257 | GNUNET_CORE_peer_request_connect (p1.ch, | 257 | GNUNET_CORE_peer_request_connect (p1.ch, |
258 | GNUNET_TIME_UNIT_SECONDS, | ||
259 | &p2.id, | 258 | &p2.id, |
260 | NULL, NULL); | 259 | NULL, NULL); |
261 | } | 260 | } |
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, | |||
321 | "Asking core (1) AGAIN to connect to peer `%4s'\n", | 321 | "Asking core (1) AGAIN to connect to peer `%4s'\n", |
322 | GNUNET_i2s (&p2.id)); | 322 | GNUNET_i2s (&p2.id)); |
323 | GNUNET_CORE_peer_request_connect (p1.ch, | 323 | GNUNET_CORE_peer_request_connect (p1.ch, |
324 | GNUNET_TIME_UNIT_SECONDS, | ||
325 | &p2.id, | 324 | &p2.id, |
326 | NULL, NULL); | 325 | NULL, NULL); |
327 | } | 326 | } |
@@ -371,7 +370,6 @@ init_notify (void *cls, | |||
371 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 370 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
372 | &ask_connect_task, NULL); | 371 | &ask_connect_task, NULL); |
373 | GNUNET_CORE_peer_request_connect (p1.ch, | 372 | GNUNET_CORE_peer_request_connect (p1.ch, |
374 | GNUNET_TIME_UNIT_SECONDS, | ||
375 | &p2.id, | 373 | &p2.id, |
376 | NULL, NULL); | 374 | NULL, NULL); |
377 | } | 375 | } |
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, | |||
414 | "Asking core (1) to connect to peer `%4s'\n", | 414 | "Asking core (1) to connect to peer `%4s'\n", |
415 | GNUNET_i2s (&p2.id)); | 415 | GNUNET_i2s (&p2.id)); |
416 | GNUNET_CORE_peer_request_connect (p1.ch, | 416 | GNUNET_CORE_peer_request_connect (p1.ch, |
417 | GNUNET_TIME_UNIT_SECONDS, | ||
418 | &p2.id, | 417 | &p2.id, |
419 | NULL, NULL); | 418 | NULL, NULL); |
420 | } | 419 | } |
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, | |||
562 | GNUNET_i2s (&p2.id)); | 562 | GNUNET_i2s (&p2.id)); |
563 | #endif | 563 | #endif |
564 | GNUNET_CORE_peer_request_connect (p1.ch, | 564 | GNUNET_CORE_peer_request_connect (p1.ch, |
565 | GNUNET_TIME_UNIT_SECONDS, | ||
566 | &p2.id, | 565 | &p2.id, |
567 | NULL, NULL); | 566 | NULL, NULL); |
568 | } | 567 | } |