diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-22 13:46:57 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-22 13:46:57 +0100 |
commit | 0d2ff615ee0b84852e80d96d5373ebead4c3e423 (patch) | |
tree | 5854cbdcec7c8857b9ba1a7a6ded83c80ce24a9e /src/dht | |
parent | 4ba0fa6ba9f9be044c8c96ddd4d909e7d84403b5 (diff) | |
download | gnunet-0d2ff615ee0b84852e80d96d5373ebead4c3e423.tar.gz gnunet-0d2ff615ee0b84852e80d96d5373ebead4c3e423.zip |
fix test_dht_montior abortion, fix crash on NULL HELLO
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 3 | ||||
-rw-r--r-- | src/dht/test_dht_monitor.c | 37 |
2 files changed, 31 insertions, 9 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 9e1cecfcd..810e6196a 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -1915,7 +1915,6 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1915 | if (NULL == peer) | 1915 | if (NULL == peer) |
1916 | peer = bucket->head; | 1916 | peer = bucket->head; |
1917 | hello = GDS_HELLO_get (peer->id); | 1917 | hello = GDS_HELLO_get (peer->id); |
1918 | hello_size = GNUNET_HELLO_size (hello); | ||
1919 | } while ( (NULL == hello) || | 1918 | } while ( (NULL == hello) || |
1920 | (GNUNET_BLOCK_EVALUATION_OK_MORE != | 1919 | (GNUNET_BLOCK_EVALUATION_OK_MORE != |
1921 | GNUNET_BLOCK_evaluate (GDS_block_context, | 1920 | GNUNET_BLOCK_evaluate (GDS_block_context, |
@@ -1925,7 +1924,7 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender, | |||
1925 | &peer->phash, | 1924 | &peer->phash, |
1926 | NULL, 0, | 1925 | NULL, 0, |
1927 | hello, | 1926 | hello, |
1928 | hello_size)) ); | 1927 | (hello_size = GNUNET_HELLO_size (hello)))) ); |
1929 | GDS_NEIGHBOURS_handle_reply (sender, | 1928 | GDS_NEIGHBOURS_handle_reply (sender, |
1930 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 1929 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
1931 | GNUNET_TIME_relative_to_absolute | 1930 | GNUNET_TIME_relative_to_absolute |
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 5e6fc074a..223488b0f 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c | |||
@@ -133,6 +133,26 @@ shutdown_task (void *cls) | |||
133 | GNUNET_free (monitors); | 133 | GNUNET_free (monitors); |
134 | GNUNET_SCHEDULER_cancel (put_task); | 134 | GNUNET_SCHEDULER_cancel (put_task); |
135 | GNUNET_DHT_TEST_cleanup (ctx); | 135 | GNUNET_DHT_TEST_cleanup (ctx); |
136 | if (NULL != timeout_task) | ||
137 | { | ||
138 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
139 | timeout_task = NULL; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Task run on success or timeout to clean up. | ||
146 | * Terminates active get operations and shuts down | ||
147 | * the testbed. | ||
148 | * | ||
149 | * @param cls the 'struct GNUNET_DHT_TestContext' | ||
150 | */ | ||
151 | static void | ||
152 | timeout_task (void *cls) | ||
153 | { | ||
154 | timeout_task = NULL; | ||
155 | GNUNET_SCHEDULER_shutdown (); | ||
136 | } | 156 | } |
137 | 157 | ||
138 | 158 | ||
@@ -157,7 +177,8 @@ dht_get_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
157 | const struct GNUNET_PeerIdentity *get_path, | 177 | const struct GNUNET_PeerIdentity *get_path, |
158 | unsigned int get_path_length, | 178 | unsigned int get_path_length, |
159 | const struct GNUNET_PeerIdentity *put_path, | 179 | const struct GNUNET_PeerIdentity *put_path, |
160 | unsigned int put_path_length, enum GNUNET_BLOCK_Type type, | 180 | unsigned int put_path_length, |
181 | enum GNUNET_BLOCK_Type type, | ||
161 | size_t size, const void *data) | 182 | size_t size, const void *data) |
162 | { | 183 | { |
163 | struct GetOperation *get_op = cls; | 184 | struct GetOperation *get_op = cls; |
@@ -186,8 +207,7 @@ dht_get_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
186 | return; | 207 | return; |
187 | /* all DHT GET operations successful; terminate! */ | 208 | /* all DHT GET operations successful; terminate! */ |
188 | ok = 0; | 209 | ok = 0; |
189 | ctx = GNUNET_SCHEDULER_cancel (timeout_task); | 210 | GNUNET_SCHEDULER_shutdown (); |
190 | timeout_task = GNUNET_SCHEDULER_add_now (&shutdown_task, ctx); | ||
191 | } | 211 | } |
192 | 212 | ||
193 | 213 | ||
@@ -202,11 +222,10 @@ do_puts (void *cls) | |||
202 | struct GNUNET_DHT_Handle **hs = cls; | 222 | struct GNUNET_DHT_Handle **hs = cls; |
203 | struct GNUNET_HashCode key; | 223 | struct GNUNET_HashCode key; |
204 | struct GNUNET_HashCode value; | 224 | struct GNUNET_HashCode value; |
205 | unsigned int i; | ||
206 | 225 | ||
207 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
208 | "Putting values into DHT\n"); | 227 | "Putting values into DHT\n"); |
209 | for (i = 0; i < NUM_PEERS; i++) | 228 | for (unsigned int i = 0; i < NUM_PEERS; i++) |
210 | { | 229 | { |
211 | GNUNET_CRYPTO_hash (&i, sizeof (i), &key); | 230 | GNUNET_CRYPTO_hash (&i, sizeof (i), &key); |
212 | GNUNET_CRYPTO_hash (&key, sizeof (key), &value); | 231 | GNUNET_CRYPTO_hash (&key, sizeof (key), &value); |
@@ -360,7 +379,8 @@ run (void *cls, | |||
360 | 379 | ||
361 | GNUNET_assert (NUM_PEERS == num_peers); | 380 | GNUNET_assert (NUM_PEERS == num_peers); |
362 | my_peers = peers; | 381 | my_peers = peers; |
363 | monitors = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_MonitorHandle *)); | 382 | monitors = GNUNET_new_array (num_peers, |
383 | struct GNUNET_DHT_MonitorHandle *); | ||
364 | for (i = 0; i < num_peers; i++) | 384 | for (i = 0; i < num_peers; i++) |
365 | monitors[i] = GNUNET_DHT_monitor_start (dhts[i], | 385 | monitors[i] = GNUNET_DHT_monitor_start (dhts[i], |
366 | GNUNET_BLOCK_TYPE_ANY, | 386 | GNUNET_BLOCK_TYPE_ANY, |
@@ -392,7 +412,10 @@ run (void *cls, | |||
392 | } | 412 | } |
393 | } | 413 | } |
394 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 414 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
395 | &shutdown_task, ctx); | 415 | &timeout_task, |
416 | ctx); | ||
417 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | ||
418 | ctx); | ||
396 | } | 419 | } |
397 | 420 | ||
398 | 421 | ||