aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-dht-get.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-dht-get.c')
-rw-r--r--src/dht/gnunet-dht-get.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index 6846b3af7..8a1b836f6 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -82,9 +82,14 @@ static unsigned int result_count;
82 */ 82 */
83static int ret; 83static int ret;
84 84
85/**
86 * Task scheduled to handle timeout.
87 */
88static struct GNUNET_SCHEDULER_Task *tt;
89
85 90
86/** 91/**
87 * Task run to clean up on timeout. 92 * Task run to clean up on shutdown.
88 * 93 *
89 * @param cls unused 94 * @param cls unused
90 */ 95 */
@@ -101,6 +106,24 @@ cleanup_task (void *cls)
101 GNUNET_DHT_disconnect (dht_handle); 106 GNUNET_DHT_disconnect (dht_handle);
102 dht_handle = NULL; 107 dht_handle = NULL;
103 } 108 }
109 if (NULL != tt)
110 {
111 GNUNET_SCHEDULER_cancel (tt);
112 tt = NULL;
113 }
114}
115
116
117/**
118 * Task run on timeout. Triggers shutdown.
119 *
120 * @param cls unused
121 */
122static void
123timeout_task (void *cls)
124{
125 tt = NULL;
126 GNUNET_SCHEDULER_shutdown ();
104} 127}
105 128
106 129
@@ -170,8 +193,9 @@ run (void *cls, char *const *args, const char *cfgfile,
170 GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); 193 GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);
171 if (verbose) 194 if (verbose)
172 FPRINTF (stderr, "%s `%s' \n", _("Issueing DHT GET with key"), GNUNET_h2s_full (&key)); 195 FPRINTF (stderr, "%s `%s' \n", _("Issueing DHT GET with key"), GNUNET_h2s_full (&key));
173 GNUNET_SCHEDULER_add_delayed (timeout_request, 196 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
174 &cleanup_task, NULL); 197 tt = GNUNET_SCHEDULER_add_delayed (timeout_request,
198 &timeout_task, NULL);
175 get_handle = 199 get_handle =
176 GNUNET_DHT_get_start (dht_handle, query_type, &key, replication, 200 GNUNET_DHT_get_start (dht_handle, query_type, &key, replication,
177 (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE, 201 (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE,