From: Christian Grothoff Date: Mon, 19 Dec 2011 14:02:25 +0000 (+0000) Subject: -actually initialize min_expiration field X-Git-Tag: initial-import-from-subversion-38251~15581 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=61e81163b05a44b3d0e72b4ef8c781f98b6c2c6c;p=oweals%2Fgnunet.git -actually initialize min_expiration field --- diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 5474bc101..0e82a38fd 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -198,6 +198,13 @@ static GNUNET_SCHEDULER_TaskIdentifier expired_kill_task; */ const struct GNUNET_CONFIGURATION_Handle *cfg; +/** + * Minimum time that content should have to not be discarded instantly + * (time stamp of any content that we've been discarding recently to + * stay below the quota). FOREVER if we had to expire content with + * non-zero priority. + */ +static struct GNUNET_TIME_Absolute min_expiration; /** * Handle for reporting statistics. @@ -336,6 +343,7 @@ expired_processor (void *cls, const GNUNET_HashCode * key, uint32_t size, GNUNET_h2s (key), type, (unsigned long long) (now.abs_value - expiration.abs_value)); #endif + min_expiration = now; GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size, GNUNET_YES); GNUNET_CONTAINER_bloomfilter_remove (filter, key); @@ -401,6 +409,10 @@ quota_processor (void *cls, const GNUNET_HashCode * key, uint32_t size, *need = 0; else *need -= size + GNUNET_DATASTORE_ENTRY_OVERHEAD; + if (priority > 0) + min_expiration = GNUNET_TIME_UNIT_FOREVER_ABS; + else + min_expiration = expiration; GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes purged (low-priority)"), size, GNUNET_YES); @@ -543,6 +555,7 @@ transmit_status (struct GNUNET_SERVER_Client *client, int code, const char *msg) sm->header.size = htons (sizeof (struct StatusMessage) + slen); sm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_STATUS); sm->status = htonl (code); + sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration); if (slen > 0) memcpy (&sm[1], msg, slen); transmit (client, &sm->header); diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index db680eaf3..b4af0e6fd 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h @@ -86,8 +86,9 @@ 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 min_expiration minimum expiration time required for 0-priority content to be stored + * by the datacache at this time, zero for unknown, forever if we have no + * space for 0-priority content * @param msg NULL on success, otherwise an error message */ typedef void (*GNUNET_DATASTORE_ContinuationWithStatus) (void *cls,