aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-11-08 17:32:06 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-11-08 17:32:06 +0000
commit90014223bee3789cbb1baffe3dc169e18883fe02 (patch)
treeeba17ee9023d66a9b5d1fa88bf2367f143d69d1a /src
parent210b4b6433c966ac817bc69ef08bcf9981194da1 (diff)
downloadgnunet-90014223bee3789cbb1baffe3dc169e18883fe02.tar.gz
gnunet-90014223bee3789cbb1baffe3dc169e18883fe02.zip
ATS suggests sessions that we in between terminated from transport
This causes: 0001863 Assertion failed at ats_api_scheduling.c:289. 0001868 plugins given sometimes an emtpy address in combination with 'force address' -> session was an inbound session 0001890 Crash during mesh small unicast test (i think)
Diffstat (limited to 'src')
-rw-r--r--src/ats/ats_api_scheduling.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 2eeb99dad..c2e7c0ea9 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -290,8 +290,18 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
290 GNUNET_break (0); 290 GNUNET_break (0);
291 return NULL; 291 return NULL;
292 } 292 }
293 if (session_id == 0) 293 /* Check if this session was:
294 * removed by remove_session (transport service)
295 * released by release_session (ATS)
296 * */
297 if (sh->session_array[session_id].session == NULL)
298 {
299 GNUNET_assert (0 ==
300 memcmp (peer, &sh->session_array[session_id].peer,
301 sizeof (struct GNUNET_PeerIdentity)));
294 return NULL; 302 return NULL;
303 }
304
295 if (0 != 305 if (0 !=
296 memcmp (peer, &sh->session_array[session_id].peer, 306 memcmp (peer, &sh->session_array[session_id].peer,
297 sizeof (struct GNUNET_PeerIdentity))) 307 sizeof (struct GNUNET_PeerIdentity)))
@@ -390,6 +400,10 @@ release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
390 sh->reconnect = GNUNET_YES; 400 sh->reconnect = GNUNET_YES;
391 return; 401 return;
392 } 402 }
403
404 /* this slot should have been removed from remove_session before */
405 GNUNET_assert (sh->session_array[session_id].session == NULL);
406
393 if (0 != 407 if (0 !=
394 memcmp (peer, &sh->session_array[session_id].peer, 408 memcmp (peer, &sh->session_array[session_id].peer,
395 sizeof (struct GNUNET_PeerIdentity))) 409 sizeof (struct GNUNET_PeerIdentity)))
@@ -398,6 +412,7 @@ release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
398 sh->reconnect = GNUNET_YES; 412 sh->reconnect = GNUNET_YES;
399 return; 413 return;
400 } 414 }
415
401 sh->session_array[session_id].slot_used = GNUNET_NO; 416 sh->session_array[session_id].slot_used = GNUNET_NO;
402 memset (&sh->session_array[session_id].peer, 0, 417 memset (&sh->session_array[session_id].peer, 0,
403 sizeof (struct GNUNET_PeerIdentity)); 418 sizeof (struct GNUNET_PeerIdentity));
@@ -471,10 +486,28 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
471 force_reconnect (sh); 486 force_reconnect (sh);
472 return; 487 return;
473 } 488 }
489 uint32_t session_id = ntohl (m->session_id);
490
491 struct Session * s = NULL;
492 if (session_id == 0)
493 s = NULL;
494 else
495 {
496 s = find_session (sh, session_id, &m->peer);
497 if (s == NULL)
498 {
499 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ATS tries to use outdated session `%s'\n", GNUNET_i2s(&m->peer));
500 GNUNET_break (0);
501 }
502 }
503
474 sh->suggest_cb (sh->suggest_cb_cls, &m->peer, plugin_name, address, 504 sh->suggest_cb (sh->suggest_cb_cls, &m->peer, plugin_name, address,
475 address_length, find_session (sh, ntohl (m->session_id), 505 address_length, s, m->bandwidth_out,
476 &m->peer), m->bandwidth_out,
477 m->bandwidth_in, atsi, ats_count); 506 m->bandwidth_in, atsi, ats_count);
507
508
509
510
478 GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh, 511 GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
479 GNUNET_TIME_UNIT_FOREVER_REL); 512 GNUNET_TIME_UNIT_FOREVER_REL);
480 if (GNUNET_YES == sh->reconnect) 513 if (GNUNET_YES == sh->reconnect)
@@ -640,6 +673,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
640 GNUNET_break (0); 673 GNUNET_break (0);
641 return; 674 return;
642 } 675 }
676
643 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize); 677 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
644 p->size = msize; 678 p->size = msize;
645 p->is_init = GNUNET_NO; 679 p->is_init = GNUNET_NO;
@@ -695,6 +729,7 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
695 GNUNET_break (0); 729 GNUNET_break (0);
696 return; 730 return;
697 } 731 }
732
698 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize); 733 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
699 p->size = msize; 734 p->size = msize;
700 p->is_init = GNUNET_NO; 735 p->is_init = GNUNET_NO;
@@ -746,6 +781,8 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
746 GNUNET_break (0); 781 GNUNET_break (0);
747 return; 782 return;
748 } 783 }
784
785
749 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize); 786 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
750 p->size = msize; 787 p->size = msize;
751 p->is_init = GNUNET_NO; 788 p->is_init = GNUNET_NO;
@@ -756,7 +793,8 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
756 m->peer = *peer; 793 m->peer = *peer;
757 m->address_length = htons (plugin_addr_len); 794 m->address_length = htons (plugin_addr_len);
758 m->plugin_name_length = htons (namelen); 795 m->plugin_name_length = htons (namelen);
759 m->session_id = htonl (session_id = get_session_id (sh, session, peer)); 796 session_id = get_session_id (sh, session, peer);
797 m->session_id = htonl (session_id);
760 pm = (char *) &m[1]; 798 pm = (char *) &m[1];
761 memcpy (pm, plugin_addr, plugin_addr_len); 799 memcpy (pm, plugin_addr, plugin_addr_len);
762 memcpy (&pm[plugin_addr_len], plugin_name, namelen); 800 memcpy (&pm[plugin_addr_len], plugin_name, namelen);