aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_cp.c
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2023-06-19 15:39:36 +0200
committert3sserakt <t3ss@posteo.de>2023-06-19 15:39:36 +0200
commitb78f99388e82b61cd6fde7e2f153c50b96dca3dc (patch)
treef367da4faee0cdc8ba4279469a2b0fc79b90b9ed /src/fs/gnunet-service-fs_cp.c
parent823fbe0ecac89397d8a3ab15cf7ef9b3f84a883f (diff)
downloadgnunet-b78f99388e82b61cd6fde7e2f153c50b96dca3dc.tar.gz
gnunet-b78f99388e82b61cd6fde7e2f153c50b96dca3dc.zip
NEWS: Removed all usage of old transport api, beside peerinfo tool, gnunet-transport cli and usage in transport layer itself.
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.c')
-rw-r--r--src/fs/gnunet-service-fs_cp.c138
1 files changed, 1 insertions, 137 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 29e4c5910..74dd42daf 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -94,11 +94,6 @@ struct GSF_PeerTransmitHandle
94 int is_query; 94 int is_query;
95 95
96 /** 96 /**
97 * Did we get a reservation already?
98 */
99 int was_reserved;
100
101 /**
102 * Priority of this request. 97 * Priority of this request.
103 */ 98 */
104 uint32_t priority; 99 uint32_t priority;
@@ -210,11 +205,6 @@ struct GSF_ConnectedPeer
210 struct GSF_DelayedHandle *delayed_tail; 205 struct GSF_DelayedHandle *delayed_tail;
211 206
212 /** 207 /**
213 * Context of our GNUNET_ATS_reserve_bandwidth call (or NULL).
214 */
215 struct GNUNET_ATS_ReservationContext *rc;
216
217 /**
218 * Task scheduled if we need to retry bandwidth reservation later. 208 * Task scheduled if we need to retry bandwidth reservation later.
219 */ 209 */
220 struct GNUNET_SCHEDULER_Task *rc_delay_task; 210 struct GNUNET_SCHEDULER_Task *rc_delay_task;
@@ -264,12 +254,6 @@ struct GSF_ConnectedPeer
264 unsigned int last_request_times_off; 254 unsigned int last_request_times_off;
265 255
266 /** 256 /**
267 * #GNUNET_YES if we did successfully reserve 32k bandwidth,
268 * #GNUNET_NO if not.
269 */
270 int did_reserve;
271
272 /**
273 * Handle to the PEERSTORE iterate request for peer respect value 257 * Handle to the PEERSTORE iterate request for peer respect value
274 */ 258 */
275 struct GNUNET_PEERSTORE_IterateContext *respect_iterate_req; 259 struct GNUNET_PEERSTORE_IterateContext *respect_iterate_req;
@@ -335,23 +319,6 @@ peer_transmit (struct GSF_ConnectedPeer *cp);
335 319
336 320
337/** 321/**
338 * Function called by core upon success or failure of our bandwidth reservation request.
339 *
340 * @param cls the `struct GSF_ConnectedPeer` of the peer for which we made the request
341 * @param peer identifies the peer
342 * @param amount set to the amount that was actually reserved or unreserved;
343 * either the full requested amount or zero (no partial reservations)
344 * @param res_delay if the reservation could not be satisfied (amount was 0), how
345 * long should the client wait until re-trying?
346 */
347static void
348ats_reserve_callback (void *cls,
349 const struct GNUNET_PeerIdentity *peer,
350 int32_t amount,
351 struct GNUNET_TIME_Relative res_delay);
352
353
354/**
355 * If ready (bandwidth reserved), try to schedule transmission via 322 * If ready (bandwidth reserved), try to schedule transmission via
356 * core for the given handle. 323 * core for the given handle.
357 * 324 *
@@ -367,32 +334,6 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth)
367 GNUNET_assert (0 != cp->ppd.pid); 334 GNUNET_assert (0 != cp->ppd.pid);
368 GNUNET_PEER_resolve (cp->ppd.pid, &target); 335 GNUNET_PEER_resolve (cp->ppd.pid, &target);
369 336
370 if (0 != cp->inc_preference)
371 {
372 GNUNET_ATS_performance_change_preference (GSF_ats,
373 &target,
374 GNUNET_ATS_PREFERENCE_BANDWIDTH,
375 (double) cp->inc_preference,
376 GNUNET_ATS_PREFERENCE_END);
377 cp->inc_preference = 0;
378 }
379
380 if ((GNUNET_YES == pth->is_query) &&
381 (GNUNET_YES != pth->was_reserved))
382 {
383 /* query, need reservation */
384 if (GNUNET_YES != cp->did_reserve)
385 return; /* not ready */
386 cp->did_reserve = GNUNET_NO;
387 /* reservation already done! */
388 pth->was_reserved = GNUNET_YES;
389 cp->rc = GNUNET_ATS_reserve_bandwidth (GSF_ats,
390 &target,
391 DBLOCK_SIZE,
392 &ats_reserve_callback,
393 cp);
394 return;
395 }
396 peer_transmit (cp); 337 peer_transmit (cp);
397} 338}
398 339
@@ -439,69 +380,6 @@ peer_transmit (struct GSF_ConnectedPeer *cp)
439 380
440 381
441/** 382/**
442 * (re)try to reserve bandwidth from the given peer.
443 *
444 * @param cls the `struct GSF_ConnectedPeer` to reserve from
445 */
446static void
447retry_reservation (void *cls)
448{
449 struct GSF_ConnectedPeer *cp = cls;
450 struct GNUNET_PeerIdentity target;
451
452 GNUNET_PEER_resolve (cp->ppd.pid, &target);
453 cp->rc_delay_task = NULL;
454 cp->rc =
455 GNUNET_ATS_reserve_bandwidth (GSF_ats,
456 &target,
457 DBLOCK_SIZE,
458 &ats_reserve_callback, cp);
459}
460
461
462/**
463 * Function called by core upon success or failure of our bandwidth reservation request.
464 *
465 * @param cls the `struct GSF_ConnectedPeer` of the peer for which we made the request
466 * @param peer identifies the peer
467 * @param amount set to the amount that was actually reserved or unreserved;
468 * either the full requested amount or zero (no partial reservations)
469 * @param res_delay if the reservation could not be satisfied (amount was 0), how
470 * long should the client wait until re-trying?
471 */
472static void
473ats_reserve_callback (void *cls,
474 const struct GNUNET_PeerIdentity *peer,
475 int32_t amount,
476 struct GNUNET_TIME_Relative res_delay)
477{
478 struct GSF_ConnectedPeer *cp = cls;
479 struct GSF_PeerTransmitHandle *pth;
480
481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
482 "Reserved %d bytes / need to wait %s for reservation\n",
483 (int) amount,
484 GNUNET_STRINGS_relative_time_to_string (res_delay, GNUNET_YES));
485 cp->rc = NULL;
486 if (0 == amount)
487 {
488 cp->rc_delay_task =
489 GNUNET_SCHEDULER_add_delayed (res_delay,
490 &retry_reservation,
491 cp);
492 return;
493 }
494 cp->did_reserve = GNUNET_YES;
495 pth = cp->pth_head;
496 if (NULL != pth)
497 {
498 /* reservation success, try transmission now! */
499 peer_transmit (cp);
500 }
501}
502
503
504/**
505 * Function called by PEERSTORE with peer respect record 383 * Function called by PEERSTORE with peer respect record
506 * 384 *
507 * @param cls handle to connected peer entry 385 * @param cls handle to connected peer entry
@@ -584,11 +462,7 @@ GSF_peer_connect_handler (void *cls,
584 cp->ppd.peer = peer; 462 cp->ppd.peer = peer;
585 cp->mq = mq; 463 cp->mq = mq;
586 cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); 464 cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO);
587 cp->rc = 465
588 GNUNET_ATS_reserve_bandwidth (GSF_ats,
589 peer,
590 DBLOCK_SIZE,
591 &ats_reserve_callback, cp);
592 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, 466 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128,
593 GNUNET_YES); 467 GNUNET_YES);
594 GNUNET_break (GNUNET_OK == 468 GNUNET_break (GNUNET_OK ==
@@ -1499,16 +1373,6 @@ GSF_peer_disconnect_handler (void *cls,
1499 GNUNET_PEERSTORE_iterate_cancel (cp->respect_iterate_req); 1373 GNUNET_PEERSTORE_iterate_cancel (cp->respect_iterate_req);
1500 cp->respect_iterate_req = NULL; 1374 cp->respect_iterate_req = NULL;
1501 } 1375 }
1502 if (NULL != cp->rc)
1503 {
1504 GNUNET_ATS_reserve_bandwidth_cancel (cp->rc);
1505 cp->rc = NULL;
1506 }
1507 if (NULL != cp->rc_delay_task)
1508 {
1509 GNUNET_SCHEDULER_cancel (cp->rc_delay_task);
1510 cp->rc_delay_task = NULL;
1511 }
1512 GNUNET_CONTAINER_multihashmap_iterate (cp->request_map, 1376 GNUNET_CONTAINER_multihashmap_iterate (cp->request_map,
1513 &cancel_pending_request, 1377 &cancel_pending_request,
1514 cp); 1378 cp);