diff options
Diffstat (limited to 'src/dv/gnunet-service-dv.c')
-rw-r--r-- | src/dv/gnunet-service-dv.c | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 2d91bce41..cfc1cd2d1 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -565,10 +565,6 @@ static struct GNUNET_PeerIdentity my_identity; | |||
565 | */ | 565 | */ |
566 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 566 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
567 | 567 | ||
568 | /** | ||
569 | * The scheduler for this service. | ||
570 | */ | ||
571 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
572 | 568 | ||
573 | /** | 569 | /** |
574 | * The client, the DV plugin connected to us. Hopefully | 570 | * The client, the DV plugin connected to us. Hopefully |
@@ -944,7 +940,7 @@ size_t core_transmit_notify (void *cls, | |||
944 | } | 940 | } |
945 | /*reply = core_pending_head;*/ | 941 | /*reply = core_pending_head;*/ |
946 | 942 | ||
947 | GNUNET_SCHEDULER_add_now(sched, &try_core_send, NULL); | 943 | GNUNET_SCHEDULER_add_now(&try_core_send, NULL); |
948 | /*if (reply != NULL) | 944 | /*if (reply != NULL) |
949 | core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, reply->importance, reply->timeout, &reply->recipient, reply->msg_size, &core_transmit_notify, NULL);*/ | 945 | core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, reply->importance, reply->timeout, &reply->recipient, reply->msg_size, &core_transmit_notify, NULL);*/ |
950 | 946 | ||
@@ -1043,7 +1039,7 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, | |||
1043 | core_pending_tail, | 1039 | core_pending_tail, |
1044 | pending_message); | 1040 | pending_message); |
1045 | 1041 | ||
1046 | GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); | 1042 | GNUNET_SCHEDULER_add_now(try_core_send, NULL); |
1047 | 1043 | ||
1048 | return GNUNET_YES; | 1044 | return GNUNET_YES; |
1049 | } | 1045 | } |
@@ -1199,7 +1195,7 @@ send_message (const struct GNUNET_PeerIdentity * recipient, | |||
1199 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send size %d to destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient)); | 1195 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send size %d to destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient)); |
1200 | #endif | 1196 | #endif |
1201 | 1197 | ||
1202 | GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); | 1198 | GNUNET_SCHEDULER_add_now(try_core_send, NULL); |
1203 | return (int) cost; | 1199 | return (int) cost; |
1204 | } | 1200 | } |
1205 | 1201 | ||
@@ -1514,7 +1510,7 @@ static int handle_dv_data_message (void *cls, | |||
1514 | memcpy(delayed_context->message, packed_message, packed_message_size); | 1510 | memcpy(delayed_context->message, packed_message, packed_message_size); |
1515 | delayed_context->message_size = packed_message_size; | 1511 | delayed_context->message_size = packed_message_size; |
1516 | delayed_context->uid = ntohl(incoming->uid); | 1512 | delayed_context->uid = ntohl(incoming->uid); |
1517 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 2500), &send_message_delayed, delayed_context); | 1513 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 2500), &send_message_delayed, delayed_context); |
1518 | return GNUNET_OK; | 1514 | return GNUNET_OK; |
1519 | } | 1515 | } |
1520 | else | 1516 | else |
@@ -1669,7 +1665,7 @@ neighbor_send_task (void *cls, | |||
1669 | core_pending_tail, | 1665 | core_pending_tail, |
1670 | pending_message); | 1666 | pending_message); |
1671 | 1667 | ||
1672 | GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); | 1668 | GNUNET_SCHEDULER_add_now(try_core_send, NULL); |
1673 | /*if (core_transmit_handle == NULL) | 1669 | /*if (core_transmit_handle == NULL) |
1674 | core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);*/ | 1670 | core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);*/ |
1675 | 1671 | ||
@@ -1680,14 +1676,14 @@ neighbor_send_task (void *cls, | |||
1680 | #if DEBUG_DV_PEER_NUMBERS | 1676 | #if DEBUG_DV_PEER_NUMBERS |
1681 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: still in fast send mode\n"); | 1677 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: still in fast send mode\n"); |
1682 | #endif | 1678 | #endif |
1683 | send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); | 1679 | send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context); |
1684 | } | 1680 | } |
1685 | else | 1681 | else |
1686 | { | 1682 | { |
1687 | #if DEBUG_DV_PEER_NUMBERS | 1683 | #if DEBUG_DV_PEER_NUMBERS |
1688 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: entering slow send mode\n"); | 1684 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "DV SERVICE: entering slow send mode\n"); |
1689 | #endif | 1685 | #endif |
1690 | send_context->task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_DV_DEFAULT_SEND_INTERVAL, &neighbor_send_task, send_context); | 1686 | send_context->task = GNUNET_SCHEDULER_add_delayed(GNUNET_DV_DEFAULT_SEND_INTERVAL, &neighbor_send_task, send_context); |
1691 | } | 1687 | } |
1692 | 1688 | ||
1693 | return; | 1689 | return; |
@@ -1994,7 +1990,7 @@ direct_neighbor_free (struct DirectNeighbor *direct) | |||
1994 | send_context = direct->send_context; | 1990 | send_context = direct->send_context; |
1995 | 1991 | ||
1996 | if (send_context->task != GNUNET_SCHEDULER_NO_TASK) | 1992 | if (send_context->task != GNUNET_SCHEDULER_NO_TASK) |
1997 | GNUNET_SCHEDULER_cancel(sched, send_context->task); | 1993 | GNUNET_SCHEDULER_cancel(send_context->task); |
1998 | 1994 | ||
1999 | about_list = send_context->fast_gossip_list_head; | 1995 | about_list = send_context->fast_gossip_list_head; |
2000 | while (about_list != NULL) | 1996 | while (about_list != NULL) |
@@ -2047,7 +2043,7 @@ static int schedule_disconnect_messages (void *cls, | |||
2047 | core_pending_tail, | 2043 | core_pending_tail, |
2048 | pending_message); | 2044 | pending_message); |
2049 | 2045 | ||
2050 | GNUNET_SCHEDULER_add_now(sched, try_core_send, NULL); | 2046 | GNUNET_SCHEDULER_add_now(try_core_send, NULL); |
2051 | /*if (core_transmit_handle == NULL) | 2047 | /*if (core_transmit_handle == NULL) |
2052 | core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), ¬ify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL);*/ | 2048 | core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, default_dv_priority, GNUNET_TIME_relative_get_forever(), ¬ify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL);*/ |
2053 | 2049 | ||
@@ -2133,8 +2129,8 @@ void core_init (void *cls, | |||
2133 | 2129 | ||
2134 | if (server == NULL) | 2130 | if (server == NULL) |
2135 | { | 2131 | { |
2136 | GNUNET_SCHEDULER_cancel(sched, cleanup_task); | 2132 | GNUNET_SCHEDULER_cancel(cleanup_task); |
2137 | GNUNET_SCHEDULER_add_now(sched, &shutdown_task, NULL); | 2133 | GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); |
2138 | return; | 2134 | return; |
2139 | } | 2135 | } |
2140 | #if DEBUG_DV | 2136 | #if DEBUG_DV |
@@ -2265,9 +2261,9 @@ static int add_distant_all_direct_neighbors (void *cls, | |||
2265 | GNUNET_free(encPeerTo); | 2261 | GNUNET_free(encPeerTo); |
2266 | #endif | 2262 | #endif |
2267 | /*if (send_context->task != GNUNET_SCHEDULER_NO_TASK) | 2263 | /*if (send_context->task != GNUNET_SCHEDULER_NO_TASK) |
2268 | GNUNET_SCHEDULER_cancel(sched, send_context->task);*/ | 2264 | GNUNET_SCHEDULER_cancel(send_context->task);*/ |
2269 | 2265 | ||
2270 | send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); | 2266 | send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context); |
2271 | return GNUNET_YES; | 2267 | return GNUNET_YES; |
2272 | } | 2268 | } |
2273 | 2269 | ||
@@ -2673,9 +2669,9 @@ static int gossip_all_to_all_iterator (void *cls, | |||
2673 | GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, direct->send_context); | 2669 | GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, direct->send_context); |
2674 | 2670 | ||
2675 | if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK) | 2671 | if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK) |
2676 | GNUNET_SCHEDULER_cancel(sched, direct->send_context->task); | 2672 | GNUNET_SCHEDULER_cancel(direct->send_context->task); |
2677 | 2673 | ||
2678 | direct->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, direct->send_context); | 2674 | direct->send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, direct->send_context); |
2679 | return GNUNET_YES; | 2675 | return GNUNET_YES; |
2680 | } | 2676 | } |
2681 | 2677 | ||
@@ -2691,8 +2687,7 @@ gossip_all_to_all (void *cls, | |||
2691 | { | 2687 | { |
2692 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &gossip_all_to_all_iterator, NULL); | 2688 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &gossip_all_to_all_iterator, NULL); |
2693 | 2689 | ||
2694 | GNUNET_SCHEDULER_add_delayed (sched, | 2690 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), |
2695 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | ||
2696 | &gossip_all_to_all, | 2691 | &gossip_all_to_all, |
2697 | NULL); | 2692 | NULL); |
2698 | 2693 | ||
@@ -2749,9 +2744,9 @@ static int add_all_direct_neighbors (void *cls, | |||
2749 | send_context->fast_gossip_list_tail, | 2744 | send_context->fast_gossip_list_tail, |
2750 | gossip_entry); | 2745 | gossip_entry); |
2751 | if (send_context->task != GNUNET_SCHEDULER_NO_TASK) | 2746 | if (send_context->task != GNUNET_SCHEDULER_NO_TASK) |
2752 | GNUNET_SCHEDULER_cancel(sched, send_context->task); | 2747 | GNUNET_SCHEDULER_cancel(send_context->task); |
2753 | 2748 | ||
2754 | send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, send_context); | 2749 | send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, send_context); |
2755 | //tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT; | 2750 | //tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT; |
2756 | //neighbor_send_task(send_context, &tc); | 2751 | //neighbor_send_task(send_context, &tc); |
2757 | return GNUNET_YES; | 2752 | return GNUNET_YES; |
@@ -2827,7 +2822,7 @@ process_peerinfo (void *cls, | |||
2827 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent); | 2822 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent); |
2828 | GNUNET_free(neighbor_pid); | 2823 | GNUNET_free(neighbor_pid); |
2829 | #endif | 2824 | #endif |
2830 | neighbor->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, neighbor->send_context); | 2825 | neighbor->send_context->task = GNUNET_SCHEDULER_add_now(&neighbor_send_task, neighbor->send_context); |
2831 | } | 2826 | } |
2832 | } | 2827 | } |
2833 | 2828 | ||
@@ -2951,7 +2946,7 @@ void handle_core_disconnect (void *cls, | |||
2951 | GNUNET_break(0); | 2946 | GNUNET_break(0); |
2952 | } | 2947 | } |
2953 | if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK)) | 2948 | if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK)) |
2954 | GNUNET_SCHEDULER_cancel(sched, neighbor->send_context->task); | 2949 | GNUNET_SCHEDULER_cancel(neighbor->send_context->task); |
2955 | GNUNET_free (neighbor); | 2950 | GNUNET_free (neighbor); |
2956 | } | 2951 | } |
2957 | 2952 | ||
@@ -2960,18 +2955,15 @@ void handle_core_disconnect (void *cls, | |||
2960 | * Process dv requests. | 2955 | * Process dv requests. |
2961 | * | 2956 | * |
2962 | * @param cls closure | 2957 | * @param cls closure |
2963 | * @param scheduler scheduler to use | ||
2964 | * @param server the initialized server | 2958 | * @param server the initialized server |
2965 | * @param c configuration to use | 2959 | * @param c configuration to use |
2966 | */ | 2960 | */ |
2967 | static void | 2961 | static void |
2968 | run (void *cls, | 2962 | run (void *cls, |
2969 | struct GNUNET_SCHEDULER_Handle *scheduler, | ||
2970 | struct GNUNET_SERVER_Handle *server, | 2963 | struct GNUNET_SERVER_Handle *server, |
2971 | const struct GNUNET_CONFIGURATION_Handle *c) | 2964 | const struct GNUNET_CONFIGURATION_Handle *c) |
2972 | { | 2965 | { |
2973 | unsigned long long max_hosts; | 2966 | unsigned long long max_hosts; |
2974 | sched = scheduler; | ||
2975 | cfg = c; | 2967 | cfg = c; |
2976 | 2968 | ||
2977 | /* FIXME: Read from config, or calculate, or something other than this! */ | 2969 | /* FIXME: Read from config, or calculate, or something other than this! */ |
@@ -3000,8 +2992,7 @@ run (void *cls, | |||
3000 | 2992 | ||
3001 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 2993 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
3002 | coreAPI = | 2994 | coreAPI = |
3003 | GNUNET_CORE_connect (sched, | 2995 | GNUNET_CORE_connect (cfg, |
3004 | cfg, | ||
3005 | GNUNET_TIME_relative_get_forever(), | 2996 | GNUNET_TIME_relative_get_forever(), |
3006 | NULL, /* FIXME: anything we want to pass around? */ | 2997 | NULL, /* FIXME: anything we want to pass around? */ |
3007 | &core_init, | 2998 | &core_init, |
@@ -3020,7 +3011,7 @@ run (void *cls, | |||
3020 | coreMST = GNUNET_SERVER_mst_create (&tokenized_message_handler, | 3011 | coreMST = GNUNET_SERVER_mst_create (&tokenized_message_handler, |
3021 | NULL); | 3012 | NULL); |
3022 | 3013 | ||
3023 | peerinfo_handle = GNUNET_PEERINFO_connect(sched, cfg); | 3014 | peerinfo_handle = GNUNET_PEERINFO_connect(cfg); |
3024 | 3015 | ||
3025 | if (peerinfo_handle == NULL) | 3016 | if (peerinfo_handle == NULL) |
3026 | { | 3017 | { |
@@ -3029,8 +3020,7 @@ run (void *cls, | |||
3029 | } | 3020 | } |
3030 | 3021 | ||
3031 | /* Scheduled the task to clean up when shutdown is called */ | 3022 | /* Scheduled the task to clean up when shutdown is called */ |
3032 | cleanup_task = GNUNET_SCHEDULER_add_delayed (sched, | 3023 | cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
3033 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
3034 | &shutdown_task, | 3024 | &shutdown_task, |
3035 | NULL); | 3025 | NULL); |
3036 | } | 3026 | } |