From bf2d1ccefd7b5bd13295733a36bf19afba46f4b2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 19 Dec 2011 13:54:35 +0000 Subject: [PATCH] adding min_expiration argument to GNUNET_DATASTORE_ContinuationWithStatus callback to communicate which content has a chance of being stored in the medium term --- src/datastore/datastore.h | 6 +++++ src/datastore/datastore_api.c | 11 ++++++++-- src/datastore/perf_datastore_api.c | 8 ++++--- src/datastore/test_datastore_api.c | 6 ++--- src/datastore/test_datastore_api_management.c | 4 ++-- src/fs/fs_namespace.c | 16 +++++++++----- src/fs/fs_publish.c | 22 ++++++++++++++----- src/fs/fs_unindex.c | 3 ++- src/fs/gnunet-service-fs_indexing.c | 5 ++++- src/fs/gnunet-service-fs_pr.c | 11 +++++----- src/include/gnunet_datastore_service.h | 3 +++ 11 files changed, 68 insertions(+), 27 deletions(-) diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h index fa8352d24..563b7486c 100644 --- a/src/datastore/datastore.h +++ b/src/datastore/datastore.h @@ -72,6 +72,12 @@ struct StatusMessage */ int32_t status GNUNET_PACKED; + /** + * Minimum expiration time required for content to be stored + * by the datacache at this time, zero for unknown or no limit. + */ + struct GNUNET_TIME_AbsoluteNBO min_expiration; + }; diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 46004c4f3..36d1d98b7 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -697,10 +697,13 @@ process_queue (struct GNUNET_DATASTORE_Handle *h) * * @param cls closure * @param result result + * @param min_expiration expiration time * @param emsg error message */ static void -drop_status_cont (void *cls, int32_t result, const char *emsg) +drop_status_cont (void *cls, int32_t result, + struct GNUNET_TIME_Absolute min_expiration, + const char *emsg) { /* do nothing */ } @@ -765,6 +768,7 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg) process_queue (h); if (rc.cont != NULL) rc.cont (rc.cont_cls, GNUNET_SYSERR, + GNUNET_TIME_UNIT_ZERO_ABS, _("Failed to receive status response from database.")); return; } @@ -778,6 +782,7 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg) do_disconnect (h); if (rc.cont != NULL) rc.cont (rc.cont_cls, GNUNET_SYSERR, + GNUNET_TIME_UNIT_ZERO_ABS, _("Error reading response from datastore service")); return; } @@ -807,7 +812,9 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg) h->retry_time.rel_value = 0; process_queue (h); if (rc.cont != NULL) - rc.cont (rc.cont_cls, status, emsg); + rc.cont (rc.cont_cls, status, + GNUNET_TIME_absolute_ntoh (sm->min_expiration), + emsg); } diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 1ba215374..372a61f7d 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -111,7 +111,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); static void -check_success (void *cls, int success, const char *msg) +check_success (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; @@ -149,10 +149,12 @@ check_success (void *cls, int success, const char *msg) * * @param cls closure * @param success GNUNET_SYSERR on failure + * @param min_expiration minimum expiration time required for content to be stored + * by the datacache at this time, zero for unknown * @param msg NULL on success, otherwise an error message */ static void -remove_next (void *cls, int success, const char *msg) +remove_next (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; @@ -276,7 +278,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run_tests (void *cls, int success, const char *msg) +run_tests (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 0309a6592..942e0a11e 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -139,7 +139,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); static void -check_success (void *cls, int success, const char *msg) +check_success (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; @@ -158,7 +158,7 @@ check_success (void *cls, int success, const char *msg) static void -get_reserved (void *cls, int success, const char *msg) +get_reserved (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; @@ -450,7 +450,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run_tests (void *cls, int32_t success, const char *msg) +run_tests (void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index cb04d31d1..3cb8ed94a 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -122,7 +122,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); static void -check_success (void *cls, int success, const char *msg) +check_success (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; @@ -246,7 +246,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run_tests (void *cls, int success, const char *msg) +run_tests (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct CpsRunContext *crc = cls; diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index 9d754009b..ec4e2495a 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c @@ -311,10 +311,13 @@ do_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * * @param cls closure (our struct AdvertismentContext) * @param success GNUNET_SYSERR on failure + * @param min_expiration minimum expiration time required for content to be stored * @param msg NULL on success, otherwise an error message */ static void -advertisement_cont (void *cls, int success, const char *msg) +advertisement_cont (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { struct AdvertisementContext *ac = cls; const char *keyword; @@ -475,7 +478,7 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, ctx->ns = namespace; ctx->ns->rc++; ctx->bo = *bo; - advertisement_cont (ctx, GNUNET_OK, NULL); + advertisement_cont (ctx, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL); } @@ -697,10 +700,13 @@ struct PublishSksContext * * @param cls closure of type "struct PublishSksContext*" * @param success GNUNET_OK on success + * @param min_expiration minimum expiration time required for content to be stored * @param msg error message (or NULL) */ static void -sb_put_cont (void *cls, int success, const char *msg) +sb_put_cont (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { struct PublishSksContext *psc = cls; GNUNET_HashCode hc; @@ -867,7 +873,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, { GNUNET_free (sb_enc); GNUNET_free (sb); - sb_put_cont (psc, GNUNET_OK, NULL); + sb_put_cont (psc, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL); return; } psc->dsh = GNUNET_DATASTORE_connect (h->cfg); @@ -875,7 +881,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, { GNUNET_free (sb_enc); GNUNET_free (sb); - sb_put_cont (psc, GNUNET_NO, _("Failed to connect to datastore.")); + sb_put_cont (psc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, _("Failed to connect to datastore.")); return; } GNUNET_CRYPTO_hash_xor (&sks_uri->data.sks.namespace, &id, &query); diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 9a834ee86..05f667451 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -124,10 +124,13 @@ publish_cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * * @param cls the 'struct GNUNET_FS_PublishContext' * @param success GNUNET_OK on success + * @param min_expiration minimum expiration time required for content to be stored * @param msg error message (or NULL) */ static void -ds_put_cont (void *cls, int success, const char *msg) +ds_put_cont (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_ProgressInfo pi; @@ -224,10 +227,13 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p, * * @param cls the 'struct GNUNET_FS_PublishContext' * @param success success code (not used) + * @param min_expiration minimum expiration time required for content to be stored * @param msg error message (typically NULL, not used) */ static void -finish_release_reserve (void *cls, int success, const char *msg) +finish_release_reserve (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { struct GNUNET_FS_PublishContext *pc = cls; @@ -271,7 +277,7 @@ publish_sblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, } else { - finish_release_reserve (pc, GNUNET_OK, NULL); + finish_release_reserve (pc, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL); } } @@ -1067,10 +1073,13 @@ GNUNET_FS_publish_signal_suspend_ (void *cls) * * @param cls the 'struct GNUNET_FS_PublishContext*' * @param success positive reservation ID on success + * @param min_expiration minimum expiration time required for content to be stored * @param msg error message on error, otherwise NULL */ static void -finish_reserve (void *cls, int success, const char *msg) +finish_reserve (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { struct GNUNET_FS_PublishContext *pc = cls; @@ -1348,10 +1357,13 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); * * @param cls closure of type "struct PublishKskContext*" * @param success GNUNET_OK on success + * @param min_expiration minimum expiration time required for content to be stored * @param msg error message (or NULL) */ static void -kb_put_cont (void *cls, int success, const char *msg) +kb_put_cont (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { struct PublishKskContext *pkc = cls; diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 79b7e8c73..fa9147bcd 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c @@ -144,10 +144,11 @@ signal_unindex_error (struct GNUNET_FS_UnindexContext *uc) * * @param cls closure * @param success GNUNET_SYSERR on failure + * @param min_expiration minimum expiration time required for content to be stored * @param msg NULL on success, otherwise an error message */ static void -process_cont (void *cls, int success, const char *msg) +process_cont (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { struct GNUNET_FS_UnindexContext *uc = cls; diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 41a40e125..d3aef8917 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c @@ -477,10 +477,13 @@ GNUNET_FS_handle_unindex (void *cls, struct GNUNET_SERVER_Client *client, * * @param cls unused * @param success did the deletion work? + * @param min_expiration minimum expiration time required for content to be stored * @param msg error message */ static void -remove_cont (void *cls, int success, const char *msg) +remove_cont (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { if (GNUNET_OK != success) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index aa18e2fc8..12245c8a6 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -890,18 +890,19 @@ struct PutMigrationContext * * @param cls closure * @param success GNUNET_SYSERR on failure + * @param min_expiration minimum expiration time required for content to be stored * @param msg NULL on success, otherwise an error message */ static void -put_migration_continuation (void *cls, int success, const char *msg) +put_migration_continuation (void *cls, int success, + struct GNUNET_TIME_Absolute min_expiration, + const char *msg) { struct PutMigrationContext *pmc = cls; - struct GNUNET_TIME_Relative delay; struct GNUNET_TIME_Relative block_time; struct GSF_ConnectedPeer *cp; struct GSF_PeerPerformanceData *ppd; - delay = GNUNET_TIME_absolute_get_duration (pmc->start); cp = GSF_peer_get_ (&pmc->origin); if ((GNUNET_OK != success) && (GNUNET_NO == pmc->requested)) { @@ -1023,7 +1024,7 @@ handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &put_migration_continuation, pmc)) { - put_migration_continuation (pmc, GNUNET_NO, NULL); + put_migration_continuation (pmc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, NULL); } } } @@ -1538,7 +1539,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &put_migration_continuation, pmc)) { - put_migration_continuation (pmc, GNUNET_NO, NULL); + put_migration_continuation (pmc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, NULL); } } else diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index 03ec9117c..db680eaf3 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h @@ -86,10 +86,13 @@ GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop); * @param success GNUNET_SYSERR on failure (including timeout/queue drop) * GNUNET_NO if content was already there * GNUNET_YES (or other positive value) on success + * @param min_expiration minimum expiration time required for content to be stored + * by the datacache at this time, zero for unknown * @param msg NULL on success, otherwise an error message */ typedef void (*GNUNET_DATASTORE_ContinuationWithStatus) (void *cls, int32_t success, + struct GNUNET_TIME_Absolute min_expiration, const char *msg); -- 2.25.1