aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_api_preferences.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/test_core_api_preferences.c')
-rw-r--r--src/core/test_core_api_preferences.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/src/core/test_core_api_preferences.c b/src/core/test_core_api_preferences.c
index b0b23776f..c725543b0 100644
--- a/src/core/test_core_api_preferences.c
+++ b/src/core/test_core_api_preferences.c
@@ -66,6 +66,8 @@ static int ok;
66 66
67static struct GNUNET_CORE_InformationRequestContext *irc; 67static struct GNUNET_CORE_InformationRequestContext *irc;
68 68
69static struct GNUNET_CORE_TransmitHandle *th;
70
69static GNUNET_SCHEDULER_TaskIdentifier irc_task; 71static GNUNET_SCHEDULER_TaskIdentifier irc_task;
70 72
71static GNUNET_SCHEDULER_TaskIdentifier ask_task; 73static GNUNET_SCHEDULER_TaskIdentifier ask_task;
@@ -99,9 +101,15 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
99#endif 101#endif
100 GNUNET_break (0); 102 GNUNET_break (0);
101 if (NULL != irc) 103 if (NULL != irc)
102 GNUNET_CORE_peer_change_preference_cancel (irc); 104 {
105 GNUNET_CORE_peer_change_preference_cancel (irc);
106 irc = NULL;
107 }
103 if (GNUNET_SCHEDULER_NO_TASK != irc_task) 108 if (GNUNET_SCHEDULER_NO_TASK != irc_task)
104 GNUNET_SCHEDULER_cancel (irc_task); 109 {
110 GNUNET_SCHEDULER_cancel (irc_task);
111 irc_task = GNUNET_SCHEDULER_NO_TASK;
112 }
105 if (GNUNET_SCHEDULER_NO_TASK != ask_task) 113 if (GNUNET_SCHEDULER_NO_TASK != ask_task)
106 { 114 {
107 GNUNET_SCHEDULER_cancel (ask_task); 115 GNUNET_SCHEDULER_cancel (ask_task);
@@ -121,6 +129,7 @@ transmit_ready (void *cls, size_t size, void *buf)
121 struct PeerContext *p = cls; 129 struct PeerContext *p = cls;
122 struct GNUNET_MessageHeader *m; 130 struct GNUNET_MessageHeader *m;
123 131
132 th = NULL;
124 GNUNET_assert (ok == 4); 133 GNUNET_assert (ok == 4);
125 OKPP; 134 OKPP;
126 GNUNET_assert (p == &p1); 135 GNUNET_assert (p == &p1);
@@ -203,13 +212,13 @@ preference_cb (void *cls,
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
204 "Asking core (1) for transmission to peer `%4s'\n", 213 "Asking core (1) for transmission to peer `%4s'\n",
205 GNUNET_i2s (&p2.id)); 214 GNUNET_i2s (&p2.id));
206 if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch, 215 if (NULL == (th = GNUNET_CORE_notify_transmit_ready (p1.ch,
207 GNUNET_YES, 216 GNUNET_YES,
208 0, 217 0,
209 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45), 218 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
210 &p2.id, 219 &p2.id,
211 sizeof (struct GNUNET_MessageHeader), 220 sizeof (struct GNUNET_MessageHeader),
212 &transmit_ready, &p1)) 221 &transmit_ready, &p1)))
213 { 222 {
214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
215 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 224 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
@@ -261,8 +270,27 @@ disconnect_notify (void *cls,
261 sizeof (struct GNUNET_PeerIdentity))) 270 sizeof (struct GNUNET_PeerIdentity)))
262 return; 271 return;
263 pc->connect_status = 0; 272 pc->connect_status = 0;
273 if (GNUNET_SCHEDULER_NO_TASK != irc_task)
274 {
275 GNUNET_SCHEDULER_cancel (irc_task);
276 irc_task = GNUNET_SCHEDULER_NO_TASK;
277 }
278 if (0 == memcmp (peer, &p1.id, sizeof (struct GNUNET_PeerIdentity)))
279 {
280 if (irc != NULL)
281 {
282 GNUNET_CORE_peer_change_preference_cancel (irc);
283 irc = NULL;
284 }
285 if (th != NULL)
286 {
287 GNUNET_CORE_notify_transmit_ready_cancel (th);
288 th = NULL;
289 }
290 }
264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
265 "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); 292 "Encrypted connection to `%4s' cut\n",
293 GNUNET_i2s (peer));
266} 294}
267 295
268 296