aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-dht-monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-dht-monitor.c')
-rw-r--r--src/dht/gnunet-dht-monitor.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c
index 0502496d7..7f14255d3 100644
--- a/src/dht/gnunet-dht-monitor.c
+++ b/src/dht/gnunet-dht-monitor.c
@@ -71,6 +71,11 @@ static unsigned int result_count;
71 */ 71 */
72static int ret; 72static int ret;
73 73
74/**
75 * Task scheduled to handle timeout.
76 */
77static struct GNUNET_SCHEDULER_Task *tt;
78
74 79
75/** 80/**
76 * Stop monitoring request and start shutdown 81 * Stop monitoring request and start shutdown
@@ -92,9 +97,28 @@ cleanup_task (void *cls)
92 GNUNET_DHT_disconnect (dht_handle); 97 GNUNET_DHT_disconnect (dht_handle);
93 dht_handle = NULL; 98 dht_handle = NULL;
94 } 99 }
100 if (NULL != tt)
101 {
102 GNUNET_SCHEDULER_cancel (tt);
103 tt = NULL;
104 }
105}
106
107
108/**
109 * We hit a timeout. Stop monitoring request and start shutdown
110 *
111 * @param cls closure (unused)
112 */
113static void
114timeout_task (void *cls)
115{
116 tt = NULL;
117 GNUNET_SCHEDULER_shutdown ();
95} 118}
96 119
97 120
121
98/** 122/**
99 * Callback called on each GET request going through the DHT. 123 * Callback called on each GET request going through the DHT.
100 * 124 *
@@ -107,7 +131,7 @@ cleanup_task (void *cls)
107 * @param desired_replication_level Desired replication level. 131 * @param desired_replication_level Desired replication level.
108 * @param key Key of the requested data. 132 * @param key Key of the requested data.
109 */ 133 */
110void 134static void
111get_callback (void *cls, 135get_callback (void *cls,
112 enum GNUNET_DHT_RouteOption options, 136 enum GNUNET_DHT_RouteOption options,
113 enum GNUNET_BLOCK_Type type, 137 enum GNUNET_BLOCK_Type type,
@@ -139,7 +163,7 @@ get_callback (void *cls,
139 * @param data Pointer to the result data. 163 * @param data Pointer to the result data.
140 * @param size Number of bytes in data. 164 * @param size Number of bytes in data.
141 */ 165 */
142void 166static void
143get_resp_callback (void *cls, 167get_resp_callback (void *cls,
144 enum GNUNET_BLOCK_Type type, 168 enum GNUNET_BLOCK_Type type,
145 const struct GNUNET_PeerIdentity *get_path, 169 const struct GNUNET_PeerIdentity *get_path,
@@ -177,7 +201,7 @@ get_resp_callback (void *cls,
177 * @param data Pointer to the data carried. 201 * @param data Pointer to the data carried.
178 * @param size Number of bytes in data. 202 * @param size Number of bytes in data.
179 */ 203 */
180void 204static void
181put_callback (void *cls, 205put_callback (void *cls,
182 enum GNUNET_DHT_RouteOption options, 206 enum GNUNET_DHT_RouteOption options,
183 enum GNUNET_BLOCK_Type type, 207 enum GNUNET_BLOCK_Type type,
@@ -242,7 +266,11 @@ run (void *cls, char *const *args, const char *cfgfile,
242 FPRINTF (stderr, 266 FPRINTF (stderr,
243 "Monitoring for %s\n", 267 "Monitoring for %s\n",
244 GNUNET_STRINGS_relative_time_to_string (timeout_request, GNUNET_NO)); 268 GNUNET_STRINGS_relative_time_to_string (timeout_request, GNUNET_NO));
245 GNUNET_SCHEDULER_add_delayed (timeout_request, &cleanup_task, NULL); 269 tt = GNUNET_SCHEDULER_add_delayed (timeout_request,
270 &timeout_task,
271 NULL);
272 GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
273 NULL);
246 monitor_handle = GNUNET_DHT_monitor_start (dht_handle, 274 monitor_handle = GNUNET_DHT_monitor_start (dht_handle,
247 block_type, 275 block_type,
248 key, 276 key,