aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api_performance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-26 09:17:31 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-26 09:17:31 +0000
commit788fba8f069182d095b23bc417cce2f8e423ebb2 (patch)
tree0394a252458b90fb5bcb4de48e1140e21150069d /src/ats/ats_api_performance.c
parentac923b9393651fa65c79ee1e4d3fc5cc870373f5 (diff)
downloadgnunet-788fba8f069182d095b23bc417cce2f8e423ebb2.tar.gz
gnunet-788fba8f069182d095b23bc417cce2f8e423ebb2.zip
race condition between APIs due to different locations for the client_receive call: performance and scheduling now work the same
Diffstat (limited to 'src/ats/ats_api_performance.c')
-rw-r--r--src/ats/ats_api_performance.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index 8d8df6474..aa5fff203 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -274,6 +274,16 @@ do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
274 274
275 275
276/** 276/**
277 * Type of a function to call when we receive a message
278 * from the service.
279 *
280 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
281 * @param msg message received, NULL on timeout or fatal error
282 */
283static void
284process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg);
285
286/**
277 * We can now transmit a message to ATS. Do it. 287 * We can now transmit a message to ATS. Do it.
278 * 288 *
279 * @param cls the 'struct GNUNET_ATS_SchedulingHandle' 289 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
@@ -298,6 +308,9 @@ transmit_message_to_ats (void *cls, size_t size, void *buf)
298 ret += p->size; 308 ret += p->size;
299 size -= p->size; 309 size -= p->size;
300 GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p); 310 GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
311 GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
312 GNUNET_TIME_UNIT_FOREVER_REL);
313
301 GNUNET_free (p); 314 GNUNET_free (p);
302 } 315 }
303 do_transmit (ph); 316 do_transmit (ph);
@@ -609,8 +622,6 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
609 GNUNET_assert (NULL == ph->client); 622 GNUNET_assert (NULL == ph->client);
610 ph->client = GNUNET_CLIENT_connect ("ats", ph->cfg); 623 ph->client = GNUNET_CLIENT_connect ("ats", ph->cfg);
611 GNUNET_assert (NULL != ph->client); 624 GNUNET_assert (NULL != ph->client);
612 GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
613 GNUNET_TIME_UNIT_FOREVER_REL);
614 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init)) 625 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
615 { 626 {
616 p = GNUNET_malloc (sizeof (struct PendingMessage) + 627 p = GNUNET_malloc (sizeof (struct PendingMessage) +