gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r4638 - GNUnet/src/applications/datastore


From: gnunet
Subject: [GNUnet-SVN] r4638 - GNUnet/src/applications/datastore
Date: Sun, 4 Mar 2007 19:00:04 -0700 (MST)

Author: grothoff
Date: 2007-03-04 19:00:04 -0700 (Sun, 04 Mar 2007)
New Revision: 4638

Modified:
   GNUnet/src/applications/datastore/datastore.c
Log:
delete outdated content on update

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2007-03-05 01:51:42 UTC 
(rev 4637)
+++ GNUnet/src/applications/datastore/datastore.c       2007-03-05 02:00:04 UTC 
(rev 4638)
@@ -272,7 +272,7 @@
   if ( (available < ntohl(value->size) ) &&
        (minPriority > ntohl(value->prio)) )
     return NO; /* new content has such a low priority that
-                     we should not even bother! */
+                 we should not even bother! */
   if (ntohl(value->prio) < minPriority)
     minPriority = ntohl(value->prio);
 
@@ -286,9 +286,15 @@
   return ok;
 }
 
+/**
+ * @return *closure if we are below quota,
+ *         SYSERR if we have deleted all of the expired content
+ *         OK if we deleted expired content and are above quota
+ */
 static int freeSpaceExpired(const HashCode512 * key,
                            const Datastore_Value * value,
                            void * closure) {
+  int * icls = closure;
   int ret;
 
   if (get_time() < ntohll(value->expirationTime))
@@ -298,7 +304,7 @@
     available += ntohl(value->size);
   if ( (available > 0) &&
        (available >= MIN_FREE) )
-    return SYSERR;
+    return *icls;
   return OK;
 }
 
@@ -324,12 +330,14 @@
  * Also updates available and minPriority.
  */
 static void cronMaintenance(void * unused) {
+  int syserr = SYSERR;
+
   available = quota - sq->getSize();
   if ( (available < 0) ||
        (available < MIN_FREE) ) {
     sq->iterateExpirationTime(ANY_BLOCK,
                              &freeSpaceExpired,
-                             NULL);
+                             &syserr);
     if ( (available < 0) ||
         (available < MIN_FREE) ) {
       sq->iterateLowPriority(ANY_BLOCK,
@@ -452,6 +460,7 @@
   unsigned int lastQuota;
   int * lq;
   State_ServiceAPI * state;
+  int ok = OK;
 
   if (-1 == GC_get_configuration_value_number(uapi->cfg,
                                              "FS",
@@ -461,6 +470,16 @@
                                              1024,
                                              &quota))
     return; /* OOPS */
+  sq = uapi->requestService("sqstore");
+  GE_LOG(uapi->ectx,
+        GE_USER | GE_ADMIN | GE_INFO | GE_IMMEDIATE,
+        _("Deleting expired content.  This may take a while.\n"));
+  sq->iterateExpirationTime(ANY_BLOCK,
+                           &freeSpaceExpired,
+                           &ok);
+  GE_LOG(uapi->ectx,
+        GE_USER | GE_ADMIN | GE_INFO | GE_IMMEDIATE,
+        _("Completed deleting expired content.\n"));
   state = uapi->requestService("state");
   if (state != NULL) {
     lq = NULL;
@@ -473,6 +492,7 @@
     uapi->releaseService(state);
     lastQuota = ntohl(*lq);
     FREE(lq);
+    uapi->releaseService(sq);
     if (lastQuota == quota)
       return; /* unchanged */
   } else {
@@ -486,8 +506,8 @@
               uapi->cfg);
   initFilters(uapi->ectx,
              uapi->cfg);
-  sq = uapi->requestService("sqstore");
-  sq->get(NULL, ANY_BLOCK,
+  sq->get(NULL, 
+         ANY_BLOCK,
          &filterAddAll,
          NULL);
   uapi->releaseService(sq);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]