diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-21 11:44:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-21 11:44:29 +0000 |
commit | 8919055de77f692ce3f0c1b9781fc9011de9cb6f (patch) | |
tree | 8cf4c40f65d700a23fc34f5cd9129aa4ceb7e40a /src/hostlist | |
parent | b626408c2f8eaac4453c106af6b79dd52f0b25f7 (diff) | |
download | gnunet-8919055de77f692ce3f0c1b9781fc9011de9cb6f.tar.gz gnunet-8919055de77f692ce3f0c1b9781fc9011de9cb6f.zip |
-fix testcase to manage with new shutdown semantics
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_reconnect.c | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c index 562eec55b..3dad137a2 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c | |||
@@ -51,32 +51,6 @@ static struct PeerContext p1; | |||
51 | static struct PeerContext p2; | 51 | static struct PeerContext p2; |
52 | 52 | ||
53 | 53 | ||
54 | static void | ||
55 | clean_up (void *cls) | ||
56 | { | ||
57 | if (NULL != p1.ghh) | ||
58 | { | ||
59 | GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); | ||
60 | p1.ghh = NULL; | ||
61 | } | ||
62 | if (p1.th != NULL) | ||
63 | { | ||
64 | GNUNET_TRANSPORT_disconnect (p1.th); | ||
65 | p1.th = NULL; | ||
66 | } | ||
67 | if (NULL != p2.ghh) | ||
68 | { | ||
69 | GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); | ||
70 | p2.ghh = NULL; | ||
71 | } | ||
72 | if (p2.th != NULL) | ||
73 | { | ||
74 | GNUNET_TRANSPORT_disconnect (p2.th); | ||
75 | p2.th = NULL; | ||
76 | } | ||
77 | GNUNET_SCHEDULER_shutdown (); | ||
78 | } | ||
79 | |||
80 | /** | 54 | /** |
81 | * Timeout, give up. | 55 | * Timeout, give up. |
82 | */ | 56 | */ |
@@ -86,7 +60,7 @@ timeout_error (void *cls) | |||
86 | timeout_task = NULL; | 60 | timeout_task = NULL; |
87 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 61 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
88 | "Timeout trying to connect peers, test failed.\n"); | 62 | "Timeout trying to connect peers, test failed.\n"); |
89 | clean_up (NULL); | 63 | GNUNET_SCHEDULER_shutdown (); |
90 | } | 64 | } |
91 | 65 | ||
92 | 66 | ||
@@ -108,12 +82,7 @@ notify_connect (void *cls, | |||
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
109 | "Peers connected, shutting down.\n"); | 83 | "Peers connected, shutting down.\n"); |
110 | ok = 0; | 84 | ok = 0; |
111 | if (timeout_task != NULL) | 85 | GNUNET_SCHEDULER_shutdown (); |
112 | { | ||
113 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
114 | timeout_task = NULL; | ||
115 | } | ||
116 | GNUNET_SCHEDULER_add_now (&clean_up, NULL); | ||
117 | } | 86 | } |
118 | 87 | ||
119 | 88 | ||
@@ -185,6 +154,31 @@ stop_arm (struct PeerContext *p) | |||
185 | static void | 154 | static void |
186 | shutdown_task (void *cls) | 155 | shutdown_task (void *cls) |
187 | { | 156 | { |
157 | if (NULL != timeout_task) | ||
158 | { | ||
159 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
160 | timeout_task = NULL; | ||
161 | } | ||
162 | if (NULL != p1.ghh) | ||
163 | { | ||
164 | GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); | ||
165 | p1.ghh = NULL; | ||
166 | } | ||
167 | if (p1.th != NULL) | ||
168 | { | ||
169 | GNUNET_TRANSPORT_disconnect (p1.th); | ||
170 | p1.th = NULL; | ||
171 | } | ||
172 | if (NULL != p2.ghh) | ||
173 | { | ||
174 | GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); | ||
175 | p2.ghh = NULL; | ||
176 | } | ||
177 | if (p2.th != NULL) | ||
178 | { | ||
179 | GNUNET_TRANSPORT_disconnect (p2.th); | ||
180 | p2.th = NULL; | ||
181 | } | ||
188 | stop_arm (&p1); | 182 | stop_arm (&p1); |
189 | stop_arm (&p2); | 183 | stop_arm (&p2); |
190 | } | 184 | } |
@@ -198,9 +192,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
198 | ok++; | 192 | ok++; |
199 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 193 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
200 | &timeout_error, NULL); | 194 | &timeout_error, NULL); |
201 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 195 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
202 | &shutdown_task, | 196 | NULL); |
203 | NULL); | ||
204 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); | 197 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); |
205 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); | 198 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); |
206 | } | 199 | } |