From 816b7a1abcc0a5e6665273958101e3c95447e56b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 27 Mar 2011 14:08:36 +0000 Subject: [PATCH] stuff --- src/fs/gnunet-service-fs.h | 8 +++++++ src/fs/gnunet-service-fs_cp.c | 41 ++++++++++++++++++++++++++++----- src/fs/gnunet-service-fs_new.c | 9 -------- src/fs/gnunet-service-fs_pr.c | 15 +++++++++++- src/fs/gnunet-service-fs_push.c | 14 +++++++++-- 5 files changed, 69 insertions(+), 18 deletions(-) diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h index c4a3d4bb9..9e8c06d16 100644 --- a/src/fs/gnunet-service-fs.h +++ b/src/fs/gnunet-service-fs.h @@ -56,6 +56,14 @@ #define SUPPORT_DELAYS GNUNET_NO +/** + * At what frequency should our datastore load decrease + * automatically (since if we don't use it, clearly the + * load must be going down). + */ +#define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250) + + /** * A connected peer. diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index a6f151e9e..80b9c4f11 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -324,9 +324,9 @@ peer_transmit_ready_cb (void *cls, GNUNET_assert (0 < cp->ppd.pending_replies--); } GNUNET_LOAD_update (cp->ppd.transmission_delay, - GNUNET_TIME_absolute_get_duration (pth->transmission_request_start_time).rel_value); + GNUNET_TIME_absolute_get_duration (pth->transmission_request_start_time).rel_value); ret = pth->gmc (pth->gmc_cls, - 0, NULL); + size, buf); GNUNET_free (pth); return ret; } @@ -1057,7 +1057,11 @@ peer_transmit_timeout (void *cls, { struct GSF_PeerTransmitHandle *pth = cls; struct GSF_ConnectedPeer *cp; - + +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Timeout trying to transmit to other peer\n"); +#endif pth->timeout_task = GNUNET_SCHEDULER_NO_TASK; cp = pth->cp; GNUNET_CONTAINER_DLL_remove (cp->pth_head, @@ -1184,8 +1188,21 @@ GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, /* pth->cth could be NULL here, that's OK, we'll try again later... */ } + else + { +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Not ready to ask for transmission to `%s'\n", + GNUNET_i2s (&target)); +#endif + } if (pth->cth == NULL) { +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "No transmission task scheduled, creating timeout task (%llu ms)\n", + (unsigned long long) timeout.rel_value); +#endif /* if we're waiting for reservation OR if we could not do notify_transmit_ready, install a timeout task to be on the safe side */ pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, @@ -1490,7 +1507,7 @@ create_migration_stop_message (void *cls, cp->migration_pth = NULL; if (NULL == buf) return 0; - GNUNET_assert (size > sizeof (struct MigrationStopMessage)); + GNUNET_assert (size >= sizeof (struct MigrationStopMessage)); msm.header.size = htons (sizeof (struct MigrationStopMessage)); msm.header.type = htons (GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP); msm.duration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block)); @@ -1510,8 +1527,20 @@ void GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Relative block_time) { - if (GNUNET_TIME_absolute_get_duration (cp->last_migration_block).rel_value > block_time.rel_value) - return; /* already blocked */ + if (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block).rel_value > block_time.rel_value) + { +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Migration already blocked for another %llu ms\n", + (unsigned long long) GNUNET_TIME_absolute_get_remaining (cp->last_migration_block).rel_value); +#endif + return; /* already blocked */ + } +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Asking to stop migration for %llu ms\n", + (unsigned long long) block_time.rel_value); +#endif cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time); if (cp->migration_pth != NULL) GSF_peer_transmit_cancel_ (cp->migration_pth); diff --git a/src/fs/gnunet-service-fs_new.c b/src/fs/gnunet-service-fs_new.c index 827c9ed11..acfb95600 100644 --- a/src/fs/gnunet-service-fs_new.c +++ b/src/fs/gnunet-service-fs_new.c @@ -24,8 +24,6 @@ * @author Christian Grothoff * * To use: - * - GSF_plan_get_ (!) - * - GSF_plan_size_ (?) * - consider re-issue GSF_dht_lookup_ after non-DHT reply received * - implement 'SUPPORT_DELAYS' * @@ -67,13 +65,6 @@ */ #define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) -/** - * At what frequency should our datastore load decrease - * automatically (since if we don't use it, clearly the - * load must be going down). - */ -#define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250) - /* ****************************** globals ****************************** */ diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 3bf429620..ed156daf5 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -1189,6 +1189,16 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, &put_migration_continuation, start); } + else + { +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Choosing not to keep content `%s' (%d/%d)\n", + GNUNET_h2s (&query), + active_to_migration, + test_put_load_too_high (prq.priority)); +#endif + } putl = GNUNET_LOAD_get_load (datastore_put_load); if ( (NULL != (cp = prq.sender)) && (GNUNET_NO == prq.request_found) && @@ -1201,7 +1211,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, 5000 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, (unsigned int) (60000 * putl * putl))); GSF_block_peer_migration_ (cp, block_time); - } + } return GNUNET_OK; } @@ -1222,6 +1232,7 @@ GSF_pending_request_init_ () _("Configuration fails to specify `%s', assuming default value."), "MAX_PENDING_REQUESTS"); } + datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024); requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); } @@ -1240,6 +1251,8 @@ GSF_pending_request_done_ () pr_map = NULL; GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap); requests_by_expiration_heap = NULL; + GNUNET_LOAD_value_free (datastore_put_load); + datastore_put_load = NULL; } diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c index 58588ebdb..65b15f356 100644 --- a/src/fs/gnunet-service-fs_push.c +++ b/src/fs/gnunet-service-fs_push.c @@ -219,6 +219,10 @@ transmit_message (void *cls, peer->msg = NULL; if (buf == NULL) { +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Failed to migrate content to another peer (disconnect)\n"); +#endif GNUNET_free (msg); return 0; } @@ -257,9 +261,10 @@ transmit_content (struct MigrationReadyPeer *peer, GNUNET_assert (NULL == peer->th); msize = sizeof (struct PutMessage) + block->size; msg = GNUNET_malloc (msize); - msg->header.type = htons (42); + msg->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); msg->header.size = htons (msize); - GNUNET_break (0); + msg->type = htonl (block->type); + msg->expiration = GNUNET_TIME_absolute_hton (block->expiration); memcpy (&msg[1], &block[1], block->size); @@ -282,6 +287,11 @@ transmit_content (struct MigrationReadyPeer *peer, { ret = GNUNET_NO; } +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Asking for transmission of %u bytes for migration\n", + msize); +#endif peer->th = GSF_peer_transmit_ (peer->peer, GNUNET_NO, 0 /* priority */, -- 2.25.1