aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-01-25 23:15:16 +0100
committerChristian Grothoff <christian@grothoff.org>2019-01-25 23:15:16 +0100
commitd1a4a8f64bba3399d16b2717c67f00957963983b (patch)
tree8bf2a98bba1b4b222d6dce999f76288d37ec832c
parent0144fed3c81fc5cb741db9f11fc71e07d340c6d7 (diff)
downloadgnunet-d1a4a8f64bba3399d16b2717c67f00957963983b.tar.gz
gnunet-d1a4a8f64bba3399d16b2717c67f00957963983b.zip
fixing misc ats simple issues
-rw-r--r--src/ats/gnunet-service-ats-new.c5
-rw-r--r--src/ats/plugin_ats2_simple.c11
-rw-r--r--src/ats/test_ats2_lib.c7
3 files changed, 18 insertions, 5 deletions
diff --git a/src/ats/gnunet-service-ats-new.c b/src/ats/gnunet-service-ats-new.c
index 30e265b44..dd65d54a2 100644
--- a/src/ats/gnunet-service-ats-new.c
+++ b/src/ats/gnunet-service-ats-new.c
@@ -463,6 +463,7 @@ handle_session_add (void *cls,
463 session->sh = plugin->session_add (plugin->cls, 463 session->sh = plugin->session_add (plugin->cls,
464 &session->data, 464 &session->data,
465 address); 465 address);
466 GNUNET_assert (NULL != session->sh);
466 GNUNET_SERVICE_client_continue (c->client); 467 GNUNET_SERVICE_client_continue (c->client);
467} 468}
468 469
@@ -530,9 +531,11 @@ handle_session_del (void *cls,
530 GNUNET_SERVICE_client_drop (c->client); 531 GNUNET_SERVICE_client_drop (c->client);
531 return; 532 return;
532 } 533 }
534 GNUNET_assert (NULL != session->sh);
533 plugin->session_del (plugin->cls, 535 plugin->session_del (plugin->cls,
534 session->sh, 536 session->sh,
535 &session->data); 537 &session->data);
538 session->sh = NULL;
536 GNUNET_assert (GNUNET_YES == 539 GNUNET_assert (GNUNET_YES ==
537 GNUNET_CONTAINER_multihashmap32_remove (c->details.transport.sessions, 540 GNUNET_CONTAINER_multihashmap32_remove (c->details.transport.sessions,
538 session->session_id, 541 session->session_id,
@@ -582,9 +585,11 @@ free_session (void *cls,
582 585
583 (void) key; 586 (void) key;
584 GNUNET_assert (c == session->client); 587 GNUNET_assert (c == session->client);
588 GNUNET_assert (NULL != session->sh);
585 plugin->session_del (plugin->cls, 589 plugin->session_del (plugin->cls,
586 session->sh, 590 session->sh,
587 &session->data); 591 &session->data);
592 session->sh = NULL;
588 GNUNET_free (session); 593 GNUNET_free (session);
589 return GNUNET_OK; 594 return GNUNET_OK;
590} 595}
diff --git a/src/ats/plugin_ats2_simple.c b/src/ats/plugin_ats2_simple.c
index 1551420c5..dacd2e122 100644
--- a/src/ats/plugin_ats2_simple.c
+++ b/src/ats/plugin_ats2_simple.c
@@ -825,12 +825,15 @@ update_counters (void *cls,
825 } 825 }
826 /* for first round, assign target bandwidth simply to sum of 826 /* for first round, assign target bandwidth simply to sum of
827 requested bandwidth */ 827 requested bandwidth */
828 for (enum GNUNET_MQ_PreferenceKind pk = 0; 828 for (enum GNUNET_MQ_PreferenceKind pk = 1 /* skip GNUNET_MQ_PREFERENCE_NONE */;
829 pk < GNUNET_MQ_PREFERENCE_COUNT; 829 pk < GNUNET_MQ_PREFERENCE_COUNT;
830 pk++) 830 pk++)
831 { 831 {
832 enum GNUNET_NetworkType nt = best[pk]->data->prop.nt; 832 const struct GNUNET_ATS_SessionData *data = best[pk]->data;
833 enum GNUNET_NetworkType nt;
833 834
835 GNUNET_assert (NULL != data);
836 nt = data->prop.nt;
834 best[pk]->target_out = GNUNET_MIN (peer->bw_by_pk[pk], 837 best[pk]->target_out = GNUNET_MIN (peer->bw_by_pk[pk],
835 MIN_BANDWIDTH_PER_SESSION); 838 MIN_BANDWIDTH_PER_SESSION);
836 c->bw_out_by_nt[nt] += (uint64_t) (best[pk]->target_out - MIN_BANDWIDTH_PER_SESSION); 839 c->bw_out_by_nt[nt] += (uint64_t) (best[pk]->target_out - MIN_BANDWIDTH_PER_SESSION);
@@ -974,6 +977,7 @@ simple_session_add (void *cls,
974 struct GNUNET_ATS_SessionHandle *sh; 977 struct GNUNET_ATS_SessionHandle *sh;
975 978
976 /* setup session handle */ 979 /* setup session handle */
980 GNUNET_assert (NULL != data);
977 if (NULL == address) 981 if (NULL == address)
978 alen = 0; 982 alen = 0;
979 else 983 else
@@ -1009,7 +1013,7 @@ simple_session_add (void *cls,
1009 sh->hello = hello; 1013 sh->hello = hello;
1010 } 1014 }
1011 update (h); 1015 update (h);
1012 return NULL; 1016 return sh;
1013} 1017}
1014 1018
1015 1019
@@ -1028,6 +1032,7 @@ simple_session_update (void *cls,
1028{ 1032{
1029 struct SimpleHandle *h = cls; 1033 struct SimpleHandle *h = cls;
1030 1034
1035 GNUNET_assert (NULL != data);
1031 sh->data = data; /* this statement should not really do anything... */ 1036 sh->data = data; /* this statement should not really do anything... */
1032 update (h); 1037 update (h);
1033} 1038}
diff --git a/src/ats/test_ats2_lib.c b/src/ats/test_ats2_lib.c
index 437e8baf2..31a88e710 100644
--- a/src/ats/test_ats2_lib.c
+++ b/src/ats/test_ats2_lib.c
@@ -215,7 +215,9 @@ run (void *cls,
215 init_both (cfg); 215 init_both (cfg);
216 provide_info_start (); 216 provide_info_start ();
217 get_suggestion (); 217 get_suggestion ();
218 (void) GNUNET_SCHEDULER_add_delayed (timeout, &on_shutdown, NULL); 218 (void) GNUNET_SCHEDULER_add_delayed (timeout,
219 &on_shutdown,
220 NULL);
219} 221}
220 222
221 223
@@ -233,7 +235,8 @@ main (int argc,
233{ 235{
234 ret = 1; 236 ret = 1;
235 memset (&other_peer, 0, sizeof (struct GNUNET_PeerIdentity)); 237 memset (&other_peer, 0, sizeof (struct GNUNET_PeerIdentity));
236 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500); 238 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
239 2);
237 if (0 != GNUNET_TESTING_peer_run ("test-ats2-lib", 240 if (0 != GNUNET_TESTING_peer_run ("test-ats2-lib",
238 "test_ats2_lib.conf", 241 "test_ats2_lib.conf",
239 &run, NULL)) 242 &run, NULL))