From fa2a3f804567e2c8181a9fc303b9ebe4e7ac0173 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 10 Oct 2011 11:15:00 +0000 Subject: [PATCH] fakeit --- src/ats/ats_api_peer_change_preference.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/ats/ats_api_peer_change_preference.c b/src/ats/ats_api_peer_change_preference.c index 84fc2bf6c..ec8140c14 100644 --- a/src/ats/ats_api_peer_change_preference.c +++ b/src/ats/ats_api_peer_change_preference.c @@ -70,9 +70,23 @@ exec_pcp (void *cls, int32_t want_reserv; int32_t got_reserv; struct GNUNET_TIME_Relative rdelay; + struct AllocationRecord *ar; rdelay = GNUNET_TIME_UNIT_ZERO; want_reserv = irc->amount; + ar = GNUNET_CONTAINER_multihashmap_get (irc->h->peers, &irc->peer.hashPubKey); + if (NULL == ar) + { + /* attempt to change preference on peer that is not connected */ + /* FIXME: this can happen if the 'service' didn't yet tell us about + a new connection, fake it! */ + irc->info (irc->info_cls, + &irc->peer, + want_reserv, + rdelay); + GNUNET_free (irc); + return; + } if (want_reserv < 0) { got_reserv = want_reserv; @@ -122,19 +136,10 @@ GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h, info, void *info_cls) { struct GNUNET_ATS_InformationRequestContext *irc; - struct AllocationRecord *ar; - ar = GNUNET_CONTAINER_multihashmap_get (h->peers, &peer->hashPubKey); - if (NULL == ar) - { - /* attempt to change preference on peer that is not connected */ - GNUNET_assert (0); - return NULL; - } irc = GNUNET_malloc (sizeof (struct GNUNET_ATS_InformationRequestContext)); irc->h = h; irc->peer = *peer; - irc->ar = ar; irc->amount = amount; irc->preference = preference; irc->info = info; -- 2.25.1