diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-04-12 12:55:56 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-04-12 12:55:56 +0000 |
commit | 39dd64ab580c30d2ba121aec9294a1dcca8b7fe5 (patch) | |
tree | 37440a34c171cf0e38214a0612819926760eafdc /src/gns/test_gns_pseu_shorten.c | |
parent | 22e9fab68aa127ff23446ae7d0c2b0d51554e47f (diff) | |
download | gnunet-39dd64ab580c30d2ba121aec9294a1dcca8b7fe5.tar.gz gnunet-39dd64ab580c30d2ba121aec9294a1dcca8b7fe5.zip |
-fixes
Diffstat (limited to 'src/gns/test_gns_pseu_shorten.c')
-rw-r--r-- | src/gns/test_gns_pseu_shorten.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c index 7a73884d1..5caf2396e 100644 --- a/src/gns/test_gns_pseu_shorten.c +++ b/src/gns/test_gns_pseu_shorten.c | |||
@@ -67,7 +67,9 @@ static char *test_directory; | |||
67 | static struct GNUNET_TESTING_PeerGroup *pg; | 67 | static struct GNUNET_TESTING_PeerGroup *pg; |
68 | 68 | ||
69 | /* Task handle to use to schedule test failure */ | 69 | /* Task handle to use to schedule test failure */ |
70 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 70 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
71 | |||
72 | static GNUNET_SCHEDULER_TaskIdentifier disco_task; | ||
71 | 73 | ||
72 | /* Global return value (0 for success, anything else for failure) */ | 74 | /* Global return value (0 for success, anything else for failure) */ |
73 | static int ok; | 75 | static int ok; |
@@ -95,6 +97,14 @@ struct GNUNET_CRYPTO_ShortHashCode bob_hash; | |||
95 | void | 97 | void |
96 | shutdown_callback (void *cls, const char *emsg) | 98 | shutdown_callback (void *cls, const char *emsg) |
97 | { | 99 | { |
100 | if (disco_task != GNUNET_SCHEDULER_NO_TASK) | ||
101 | { | ||
102 | disco_task = GNUNET_SCHEDULER_NO_TASK; | ||
103 | GNUNET_SCHEDULER_cancel(disco_task); | ||
104 | GNUNET_DHT_disconnect(dht_handle); | ||
105 | dht_handle = NULL; | ||
106 | } | ||
107 | |||
98 | if (emsg != NULL) | 108 | if (emsg != NULL) |
99 | { | 109 | { |
100 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error on shutdown! ret=%d\n", ok); | 110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error on shutdown! ret=%d\n", ok); |
@@ -108,6 +118,7 @@ shutdown_callback (void *cls, const char *emsg) | |||
108 | static void | 118 | static void |
109 | disco_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 119 | disco_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
110 | { | 120 | { |
121 | disco_task = GNUNET_SCHEDULER_NO_TASK; | ||
111 | GNUNET_DHT_disconnect(dht_handle); | 122 | GNUNET_DHT_disconnect(dht_handle); |
112 | dht_handle = NULL; | 123 | dht_handle = NULL; |
113 | } | 124 | } |
@@ -229,26 +240,22 @@ commence_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
229 | * down the peers without freeing memory associated with GET request. | 240 | * down the peers without freeing memory associated with GET request. |
230 | */ | 241 | */ |
231 | static void | 242 | static void |
232 | end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
233 | { | ||
234 | |||
235 | if (pg != NULL) | ||
236 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | ||
237 | GNUNET_SCHEDULER_cancel (die_task); | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * Check if the get_handle is being used, if so stop the request. Either | ||
242 | * way, schedule the end_badly_cont function which actually shuts down the | ||
243 | * test. | ||
244 | */ | ||
245 | static void | ||
246 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 243 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
247 | { | 244 | { |
248 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test with error: `%s'!\n", | 245 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test with error: `%s'!\n", |
249 | (char *) cls); | 246 | (char *) cls); |
250 | GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL); | ||
251 | ok = 1; | 247 | ok = 1; |
248 | |||
249 | if (disco_task != GNUNET_SCHEDULER_NO_TASK) | ||
250 | { | ||
251 | disco_task = GNUNET_SCHEDULER_NO_TASK; | ||
252 | GNUNET_SCHEDULER_cancel(disco_task); | ||
253 | GNUNET_DHT_disconnect(dht_handle); | ||
254 | dht_handle = NULL; | ||
255 | } | ||
256 | if (pg != NULL) | ||
257 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | ||
258 | GNUNET_SCHEDULER_cancel (die_task); | ||
252 | } | 259 | } |
253 | 260 | ||
254 | static void | 261 | static void |