From: Christian Grothoff Date: Sat, 23 Jun 2012 08:35:49 +0000 (+0000) Subject: -passing total trust offered along (fixing #1369) X-Git-Tag: initial-import-from-subversion-38251~12872 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c00ade9abf751ea2157f1f78dd834257fe19ed6c;p=oweals%2Fgnunet.git -passing total trust offered along (fixing #1369) --- diff --git a/src/fs/fs.h b/src/fs/fs.h index 3aa9fcc1b..ffd448d2b 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) + (C) 2003--2012 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -321,6 +321,18 @@ struct ClientPutMessage */ struct GNUNET_TIME_AbsoluteNBO last_transmission; + /** + * How often did we transmit this query before getting an + * answer (estimate). + */ + uint32_t num_transmissions; + + /** + * How much respect did we offer (in total) before getting an + * answer (estimate). + */ + uint32_t respect_offered; + /* this is followed by the actual encrypted content */ }; diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 2e1633c8e..3434a9553 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -165,6 +165,11 @@ struct ProcessResultClosure */ struct GNUNET_FS_DownloadContext *dc; + /** + * When did we last transmit the request? + */ + struct GNUNET_TIME_Absolute last_transmission; + /** * Number of bytes in data. */ @@ -181,9 +186,14 @@ struct ProcessResultClosure int do_store; /** - * When did we last transmit the request? + * how much respect did we offer to get this reply? */ - struct GNUNET_TIME_Absolute last_transmission; + uint32_t respect_offered; + + /** + * how often did we transmit the query? + */ + uint32_t num_transmissions; }; @@ -1069,7 +1079,8 @@ process_result_with_request (void *cls, const struct GNUNET_HashCode * key, pi.value.download.specifics.progress.offset = dr->offset; pi.value.download.specifics.progress.data_len = prc->size; pi.value.download.specifics.progress.depth = dr->depth; - pi.value.download.specifics.progress.respect_offered = 0; + pi.value.download.specifics.progress.respect_offered = prc->respect_offered; + pi.value.download.specifics.progress.num_transmissions = prc->num_transmissions; if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_absolute_get_duration (prc->last_transmission); @@ -1195,6 +1206,8 @@ signal_error: * * @param dc our download context * @param type type of the result + * @param respect_offered how much respect did we offer to get this reply? + * @param num_transmissions how often did we transmit the query? * @param last_transmission when was this block requested the last time? (FOREVER if unknown/not applicable) * @param data the (encrypted) response * @param size size of data @@ -1202,6 +1215,8 @@ signal_error: static void process_result (struct GNUNET_FS_DownloadContext *dc, enum GNUNET_BLOCK_Type type, + uint32_t respect_offered, + uint32_t num_transmissions, struct GNUNET_TIME_Absolute last_transmission, const void *data, size_t size) { @@ -1209,10 +1224,12 @@ process_result (struct GNUNET_FS_DownloadContext *dc, prc.dc = dc; prc.data = data; + prc.last_transmission = last_transmission; prc.size = size; prc.type = type; prc.do_store = GNUNET_YES; - prc.last_transmission = last_transmission; + prc.respect_offered = respect_offered; + prc.num_transmissions = num_transmissions; GNUNET_CRYPTO_hash (data, size, &prc.query); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received result for query `%s' from `%s'-service\n", @@ -1247,6 +1264,8 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg) msize = ntohs (msg->size); cm = (const struct ClientPutMessage *) msg; process_result (dc, ntohl (cm->type), + ntohl (cm->respect_offered), + ntohl (cm->num_transmissions), GNUNET_TIME_absolute_ntoh (cm->last_transmission), &cm[1], msize - sizeof (struct ClientPutMessage)); if (NULL == dc->client) diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 542d8f2e9..d3ceead77 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c @@ -762,7 +762,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb, */ static void process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type, - struct GNUNET_TIME_Absolute expiration, const void *data, + struct GNUNET_TIME_Absolute expiration, + const void *data, size_t size) { if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0) diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c index f3b18256b..b37858028 100644 --- a/src/fs/gnunet-service-fs_lc.c +++ b/src/fs/gnunet-service-fs_lc.c @@ -267,6 +267,8 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval, pm->type = htonl (type); pm->expiration = GNUNET_TIME_absolute_hton (expiration); pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission); + pm->num_transmissions = htonl (prd->num_transmissions); + pm->respect_offered = htonl (prd->respect_offered); memcpy (&pm[1], data, data_len); GSF_local_client_transmit_ (lc, &pm->header); } diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 2893481f2..3c12edfb9 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -530,6 +530,8 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr, else prio = 0; pr->public_data.priority -= prio; + pr->public_data.num_transmissions++; + pr->public_data.respect_offered += prio; gm->priority = htonl (prio); now = GNUNET_TIME_absolute_get (); ttl = (int64_t) (pr->public_data.ttl.abs_value - now.abs_value); diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h index ab088f88f..10bc5c1f3 100644 --- a/src/fs/gnunet-service-fs_pr.h +++ b/src/fs/gnunet-service-fs_pr.h @@ -132,6 +132,22 @@ struct GSF_PendingRequestData */ uint32_t original_priority; + /** + * Counter for how often this request has been transmitted (estimate, + * because we might have the same request pending for multiple clients, + * and of course because a transmission may have failed at a lower + * layer). + */ + uint32_t num_transmissions; + + /** + * How much respect did we (in total) offer for this request so far (estimate, + * because we might have the same request pending for multiple clients, + * and of course because a transmission may have failed at a lower + * layer). + */ + uint32_t respect_offered; + /** * Options for the request. */ diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 4b7e726dd..f93f4e856 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h @@ -1017,6 +1017,12 @@ struct GNUNET_FS_ProgressInfo */ uint64_t data_len; + /** + * How much time passed between us asking for this block and + * actually getting it? GNUNET_TIME_UNIT_FOREVER_REL if unknown. + */ + struct GNUNET_TIME_Relative block_download_duration; + /** * Depth of the given block in the tree; * 0 would be the lowest level (DBLOCKS). @@ -1024,15 +1030,20 @@ struct GNUNET_FS_ProgressInfo unsigned int depth; /** - * How much respect did we offer for downloading this block? + * How much respect did we offer for downloading this block? (estimate, + * because we might have the same request pending for multiple clients, + * and of course because a transmission may have failed at a lower + * layer). */ - unsigned int respect_offered; + uint32_t respect_offered; /** - * How much time passed between us asking for this block and - * actually getting it? GNUNET_TIME_UNIT_FOREVER_REL if unknown. + * How often did we transmit the request? (estimate, + * because we might have the same request pending for multiple clients, + * and of course because a transmission may have failed at a lower + * layer). */ - struct GNUNET_TIME_Relative block_download_duration; + uint32_t num_transmissions; } progress;