/**
* Our connection to the service.
*/
- struct GNUNET_ATS_Handle *h;
-
- /**
- * Link to peer record.
- */
- struct AllocationRecord *ar;
+ struct GNUNET_ATS_SchedulingHandle *h;
int32_t amount;
GNUNET_ATS_PeerConfigurationInfoCallback info;
void *info_cls;
-
+
struct GNUNET_PeerIdentity peer;
-
+
GNUNET_SCHEDULER_TaskIdentifier task;
};
static void
-exec_pcp (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+exec_pcp (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_ATS_InformationRequestContext *irc = 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;
else if (want_reserv > 0)
{
rdelay =
- GNUNET_BANDWIDTH_tracker_get_delay (&irc->ar->available_recv_window,
- want_reserv);
+ GNUNET_BANDWIDTH_tracker_get_delay (&ar->available_recv_window,
+ want_reserv);
if (rdelay.rel_value == 0)
got_reserv = want_reserv;
else
- got_reserv = 0; /* all or nothing */
+ got_reserv = 0; /* all or nothing */
}
else
got_reserv = 0;
- GNUNET_BANDWIDTH_tracker_consume (&irc->ar->available_recv_window, got_reserv);
+ GNUNET_BANDWIDTH_tracker_consume (&ar->available_recv_window, got_reserv);
- irc->info (irc->info_cls,
- &irc->peer,
- got_reserv,
- rdelay);
+ irc->info (irc->info_cls, &irc->peer, got_reserv, rdelay);
GNUNET_free (irc);
}
* @return NULL on error
*/
struct GNUNET_ATS_InformationRequestContext *
-GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount, uint64_t preference,
- GNUNET_ATS_PeerConfigurationInfoCallback
- info, void *info_cls)
+GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount, uint64_t preference,
+ GNUNET_ATS_PeerConfigurationInfoCallback
+ 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;
*/
void
GNUNET_ATS_peer_change_preference_cancel (struct
- GNUNET_ATS_InformationRequestContext
- *irc)
+ GNUNET_ATS_InformationRequestContext
+ *irc)
{
GNUNET_SCHEDULER_cancel (irc->task);
GNUNET_free (irc);
/**
* Our connection to the service.
*/
- struct GNUNET_ATS_Handle *h;
+ struct GNUNET_ATS_SchedulingHandle *h;
/**
* Link to control message, NULL if CM was sent.
* @return NULL on error
*/
struct GNUNET_ATS_InformationRequestContext *
-GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount, uint64_t preference,
- GNUNET_ATS_PeerConfigurationInfoCallback
- info, void *info_cls)
+GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount, uint64_t preference,
+ GNUNET_ATS_PeerConfigurationInfoCallback
+ info, void *info_cls)
{
struct GNUNET_ATS_InformationRequestContext *irc;
struct PeerRecord *pr;
*/
void
GNUNET_ATS_peer_change_preference_cancel (struct
- GNUNET_ATS_InformationRequestContext
- *irc)
+ GNUNET_ATS_InformationRequestContext
+ *irc)
{
- struct GNUNET_ATS_Handle *h = irc->h;
+ struct GNUNET_ATS_SchedulingHandle *h = irc->h;
struct PeerRecord *pr = irc->pr;
GNUNET_assert (pr->pcic_ptr == irc);