diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-11 16:03:28 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-11 16:03:28 +0000 |
commit | b389970f4d7563721ada3861366d164fcb45031a (patch) | |
tree | 7f466cf34e806a9ea8c21135e9970af306677735 /src | |
parent | 2b3b24e80a709916fa58914256a3bcef1b623813 (diff) | |
download | gnunet-b389970f4d7563721ada3861366d164fcb45031a.tar.gz gnunet-b389970f4d7563721ada3861366d164fcb45031a.zip |
session pointers can rarely be identical due to timing issues
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/ats_api_scheduling.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index dd06916a1..663a7925a 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -297,21 +297,8 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, | |||
297 | * released by release_session (ATS) | 297 | * released by release_session (ATS) |
298 | * */ | 298 | * */ |
299 | if (sh->session_array[session_id].session == NULL) | 299 | if (sh->session_array[session_id].session == NULL) |
300 | { | ||
301 | GNUNET_break (0 == | ||
302 | memcmp (peer, &sh->session_array[session_id].peer, | ||
303 | sizeof (struct GNUNET_PeerIdentity))); | ||
304 | return NULL; | 300 | return NULL; |
305 | } | ||
306 | 301 | ||
307 | if (0 != | ||
308 | memcmp (peer, &sh->session_array[session_id].peer, | ||
309 | sizeof (struct GNUNET_PeerIdentity))) | ||
310 | { | ||
311 | GNUNET_break (0); | ||
312 | sh->reconnect = GNUNET_YES; | ||
313 | return NULL; | ||
314 | } | ||
315 | return sh->session_array[session_id].session; | 302 | return sh->session_array[session_id].session; |
316 | } | 303 | } |
317 | 304 | ||
@@ -339,10 +326,11 @@ get_session_id (struct GNUNET_ATS_SchedulingHandle *sh, struct Session *session, | |||
339 | { | 326 | { |
340 | if (session == sh->session_array[i].session) | 327 | if (session == sh->session_array[i].session) |
341 | { | 328 | { |
342 | GNUNET_assert (0 == | 329 | if (0 != memcmp (peer, &sh->session_array[i].peer, |
343 | memcmp (peer, &sh->session_array[i].peer, | 330 | sizeof (struct GNUNET_PeerIdentity))) |
344 | sizeof (struct GNUNET_PeerIdentity))); | 331 | continue; |
345 | return i; | 332 | else |
333 | return i; | ||
346 | } | 334 | } |
347 | if ((f == 0) && (sh->session_array[i].slot_used == GNUNET_NO)) | 335 | if ((f == 0) && (sh->session_array[i].slot_used == GNUNET_NO)) |
348 | f = i; | 336 | f = i; |
@@ -377,8 +365,7 @@ remove_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, | |||
377 | return; | 365 | return; |
378 | GNUNET_assert (session_id < sh->session_array_size); | 366 | GNUNET_assert (session_id < sh->session_array_size); |
379 | GNUNET_assert (GNUNET_YES == sh->session_array[session_id].slot_used); | 367 | GNUNET_assert (GNUNET_YES == sh->session_array[session_id].slot_used); |
380 | GNUNET_assert (0 == | 368 | GNUNET_assert (0 == memcmp (peer, &sh->session_array[session_id].peer, |
381 | memcmp (peer, &sh->session_array[session_id].peer, | ||
382 | sizeof (struct GNUNET_PeerIdentity))); | 369 | sizeof (struct GNUNET_PeerIdentity))); |
383 | sh->session_array[session_id].session = NULL; | 370 | sh->session_array[session_id].session = NULL; |
384 | } | 371 | } |
@@ -406,15 +393,13 @@ release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, | |||
406 | /* this slot should have been removed from remove_session before */ | 393 | /* this slot should have been removed from remove_session before */ |
407 | GNUNET_assert (sh->session_array[session_id].session == NULL); | 394 | GNUNET_assert (sh->session_array[session_id].session == NULL); |
408 | 395 | ||
409 | if (0 != | 396 | if (0 != memcmp (peer, &sh->session_array[session_id].peer, |
410 | memcmp (peer, &sh->session_array[session_id].peer, | ||
411 | sizeof (struct GNUNET_PeerIdentity))) | 397 | sizeof (struct GNUNET_PeerIdentity))) |
412 | { | 398 | { |
413 | GNUNET_break (0); | 399 | GNUNET_break (0); |
414 | sh->reconnect = GNUNET_YES; | 400 | sh->reconnect = GNUNET_YES; |
415 | return; | 401 | return; |
416 | } | 402 | } |
417 | |||
418 | sh->session_array[session_id].slot_used = GNUNET_NO; | 403 | sh->session_array[session_id].slot_used = GNUNET_NO; |
419 | memset (&sh->session_array[session_id].peer, 0, | 404 | memset (&sh->session_array[session_id].peer, 0, |
420 | sizeof (struct GNUNET_PeerIdentity)); | 405 | sizeof (struct GNUNET_PeerIdentity)); |
@@ -511,9 +496,6 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) | |||
511 | sh->suggest_cb (sh->suggest_cb_cls, &address, s, m->bandwidth_out, | 496 | sh->suggest_cb (sh->suggest_cb_cls, &address, s, m->bandwidth_out, |
512 | m->bandwidth_in, atsi, ats_count); | 497 | m->bandwidth_in, atsi, ats_count); |
513 | 498 | ||
514 | |||
515 | |||
516 | |||
517 | GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh, | 499 | GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh, |
518 | GNUNET_TIME_UNIT_FOREVER_REL); | 500 | GNUNET_TIME_UNIT_FOREVER_REL); |
519 | if (GNUNET_YES == sh->reconnect) | 501 | if (GNUNET_YES == sh->reconnect) |