aboutsummaryrefslogtreecommitdiff
path: root/src/fs
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
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')
-rw-r--r--src/fs/gnunet-service-fs.c19
-rw-r--r--src/fs/gnunet-service-fs.h1
-rw-r--r--src/fs/gnunet-service-fs_cp.c138
3 files changed, 4 insertions, 154 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 597e89e14..c4193c2e4 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -33,7 +33,6 @@
33#include "gnunet_protocols.h" 33#include "gnunet_protocols.h"
34#include "gnunet_signatures.h" 34#include "gnunet_signatures.h"
35#include "gnunet_statistics_service.h" 35#include "gnunet_statistics_service.h"
36#include "gnunet_transport_service.h"
37#include "gnunet_util_lib.h" 36#include "gnunet_util_lib.h"
38#include "gnunet-service-fs_cp.h" 37#include "gnunet-service-fs_cp.h"
39#include "gnunet-service-fs_indexing.h" 38#include "gnunet-service-fs_indexing.h"
@@ -248,11 +247,6 @@ struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime;
248 */ 247 */
249struct GNUNET_TIME_Relative GSF_avg_latency = { 500 }; 248struct GNUNET_TIME_Relative GSF_avg_latency = { 500 };
250 249
251/**
252 * Handle to ATS service.
253 */
254struct GNUNET_ATS_PerformanceHandle *GSF_ats;
255
256 250
257/** 251/**
258 * Typical priorities we're seeing from other peers right now. Since 252 * Typical priorities we're seeing from other peers right now. Since
@@ -1042,12 +1036,12 @@ hash_for_index_val (void *cls,
1042 GNUNET_h2s (&isc->file_id)); 1036 GNUNET_h2s (&isc->file_id));
1043 1037
1044 const char *emsg = "hash mismatch"; 1038 const char *emsg = "hash mismatch";
1045 const size_t msize = strlen(emsg) + 1; 1039 const size_t msize = strlen (emsg) + 1;
1046 1040
1047 env = GNUNET_MQ_msg_extra (msg, 1041 env = GNUNET_MQ_msg_extra (msg,
1048 msize, 1042 msize,
1049 GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED); 1043 GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED);
1050 memcpy((char*) &msg[1], emsg, msize); 1044 memcpy ((char*) &msg[1], emsg, msize);
1051 GNUNET_MQ_send (lc->mq, 1045 GNUNET_MQ_send (lc->mq,
1052 env); 1046 env);
1053 GNUNET_SERVICE_client_continue (lc->client); 1047 GNUNET_SERVICE_client_continue (lc->client);
@@ -1182,11 +1176,6 @@ shutdown_task (void *cls)
1182 GNUNET_CORE_disconnect (GSF_core); 1176 GNUNET_CORE_disconnect (GSF_core);
1183 GSF_core = NULL; 1177 GSF_core = NULL;
1184 } 1178 }
1185 if (NULL != GSF_ats)
1186 {
1187 GNUNET_ATS_performance_done (GSF_ats);
1188 GSF_ats = NULL;
1189 }
1190 GSF_put_done_ (); 1179 GSF_put_done_ ();
1191 GSF_push_done_ (); 1180 GSF_push_done_ ();
1192 GSF_pending_request_done_ (); 1181 GSF_pending_request_done_ ();
@@ -1378,9 +1367,7 @@ run (void *cls,
1378 GSF_plan_init (); 1367 GSF_plan_init ();
1379 GSF_pending_request_init_ (); 1368 GSF_pending_request_init_ ();
1380 GSF_connected_peer_init_ (); 1369 GSF_connected_peer_init_ ();
1381 GSF_ats = GNUNET_ATS_performance_init (GSF_cfg, 1370
1382 &update_latencies,
1383 NULL);
1384 GSF_push_init_ (); 1371 GSF_push_init_ ();
1385 GSF_put_init_ (); 1372 GSF_put_init_ ();
1386 if ((GNUNET_OK != GNUNET_FS_indexing_init (cfg, 1373 if ((GNUNET_OK != GNUNET_FS_indexing_init (cfg,
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h
index 56d102673..7bbab1022 100644
--- a/src/fs/gnunet-service-fs.h
+++ b/src/fs/gnunet-service-fs.h
@@ -28,7 +28,6 @@
28 28
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
31#include "gnunet_transport_service.h"
32#include "gnunet_core_service.h" 31#include "gnunet_core_service.h"
33#include "gnunet_block_lib.h" 32#include "gnunet_block_lib.h"
34#include "gnunet_ats_service.h" 33#include "gnunet_ats_service.h"
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);