aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-13 20:04:52 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-13 20:04:52 +0000
commit5575070ffea92be7b42b3f23f6918135d923270b (patch)
tree120d5cb038cb6bde82e1615e44944a8556b79419
parentd5af429bc7f36b6aec6088e88331111aa1b9c19e (diff)
downloadgnunet-5575070ffea92be7b42b3f23f6918135d923270b.tar.gz
gnunet-5575070ffea92be7b42b3f23f6918135d923270b.zip
fix stack overflow
-rw-r--r--src/ats/ats_api_scheduling.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 07d4d85d4..6c4441d81 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -105,6 +105,11 @@ struct GNUNET_ATS_SchedulingHandle
105 * Unused entries are also NULL. 105 * Unused entries are also NULL.
106 */ 106 */
107 struct Session **session_array; 107 struct Session **session_array;
108
109 /**
110 * Task to trigger reconnect.
111 */
112 GNUNET_SCHEDULER_TaskIdentifier task;
108 113
109 /** 114 /**
110 * Size of the session array. 115 * Size of the session array.
@@ -123,6 +128,24 @@ static void
123reconnect (struct GNUNET_ATS_SchedulingHandle *sh); 128reconnect (struct GNUNET_ATS_SchedulingHandle *sh);
124 129
125 130
131
132/**
133 * Re-establish the connection to the ATS service.
134 *
135 * @param cls handle to use to re-connect.
136 * @param tc scheduler context
137 */
138static void
139reconnect_task (void *cls,
140 const struct GNUNET_SCHEDULER_TaskContext *tc)
141{
142 struct GNUNET_ATS_SchedulingHandle *sh = cls;
143
144 sh->task = GNUNET_SCHEDULER_NO_TASK;
145 reconnect (sh);
146}
147
148
126/** 149/**
127 * Transmit messages from the message queue to the service 150 * Transmit messages from the message queue to the service
128 * (if there are any, and if we are not already trying). 151 * (if there are any, and if we are not already trying).
@@ -289,7 +312,8 @@ process_ats_message (void *cls,
289 { 312 {
290 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO); 313 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
291 sh->client = NULL; 314 sh->client = NULL;
292 reconnect (sh); 315 sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
316 &reconnect_task, sh);
293 return; 317 return;
294 } 318 }
295 if ( (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION) || 319 if ( (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION) ||
@@ -298,7 +322,8 @@ process_ats_message (void *cls,
298 GNUNET_break (0); 322 GNUNET_break (0);
299 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO); 323 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
300 sh->client = NULL; 324 sh->client = NULL;
301 reconnect (sh); 325 sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
326 &reconnect_task, sh);
302 return; 327 return;
303 } 328 }
304 m = (const struct AddressSuggestionMessage*) msg; 329 m = (const struct AddressSuggestionMessage*) msg;
@@ -318,7 +343,8 @@ process_ats_message (void *cls,
318 GNUNET_break (0); 343 GNUNET_break (0);
319 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO); 344 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
320 sh->client = NULL; 345 sh->client = NULL;
321 reconnect (sh); 346 sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
347 &reconnect_task, sh);
322 return; 348 return;
323 } 349 }
324 sh->suggest_cb (sh->suggest_cb_cls, 350 sh->suggest_cb (sh->suggest_cb_cls,
@@ -416,7 +442,16 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
416 p); 442 p);
417 GNUNET_free (p); 443 GNUNET_free (p);
418 } 444 }
419 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO); 445 if (NULL != sh->client)
446 {
447 GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
448 sh->client = NULL;
449 }
450 if (GNUNET_SCHEDULER_NO_TASK != sh->task)
451 {
452 GNUNET_SCHEDULER_cancel (sh->task);
453 sh->task = GNUNET_SCHEDULER_NO_TASK;
454 }
420 GNUNET_array_grow (sh->session_array, 455 GNUNET_array_grow (sh->session_array,
421 sh->session_array_size, 456 sh->session_array_size,
422 0); 457 0);