gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3202 - in GNUnet: . src/applications/datastore src/include


From: grothoff
Subject: [GNUnet-SVN] r3202 - in GNUnet: . src/applications/datastore src/include
Date: Sun, 30 Jul 2006 21:46:31 -0700 (PDT)

Author: grothoff
Date: 2006-07-30 21:46:30 -0700 (Sun, 30 Jul 2006)
New Revision: 3202

Modified:
   GNUnet/src/applications/datastore/datastore.c
   GNUnet/src/applications/datastore/prefetch.c
   GNUnet/src/applications/datastore/prefetch.h
   GNUnet/src/include/gnunet_core.h
   GNUnet/todo
Log:
towards compiling datastore

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2006-07-31 04:34:44 UTC 
(rev 3201)
+++ GNUnet/src/applications/datastore/datastore.c       2006-07-31 04:46:30 UTC 
(rev 3202)
@@ -86,10 +86,10 @@
 #if DEBUG_DATASTORE
     EncName enc;
 
-    IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+    IF_GELOG(coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER,
          hash2enc(query,
                   &enc));
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+    GE_LOG(coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER,
        "Datastore availability pre-test failed for `%s'.\n",
        &enc);
 #endif
@@ -111,10 +111,10 @@
   int i;
 
   if (! testAvailable(query)) {
-    IF_GELOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+    IF_GELOG(coreAPI->ectx, GE_WARNING | GE_BULK | GE_USER,
          hash2enc(query,
                   &enc));
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+    GE_LOG(coreAPI->ectx, GE_WARNING | GE_BULK | GE_USER,
        _("Availability test failed for `%s' at %s:%d.\n"),
        &enc,
        __FILE__, __LINE__);
@@ -127,18 +127,18 @@
       available += ntohl(value->size);
     }
 #if DEBUG_DATASTORE
-    IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+    IF_GELOG(coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER,
          hash2enc(query,
                   &enc));
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+    GE_LOG(coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER,
        "Deleted `%s' from database.\n",
        &enc);
 #endif
   } else {
-    IF_GELOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+    IF_GELOG(coreAPI->ectx, GE_WARNING | GE_BULK | GE_USER,
          hash2enc(query,
                   &enc));
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+    GE_LOG(coreAPI->ectx, GE_WARNING | GE_BULK | GE_USER,
        _("Database failed to delete `%s'.\n"),
        &enc);
   }
@@ -161,7 +161,7 @@
   /* check if we have enough space / priority */
   if ( (available < ntohl(value->size) ) &&
        (minPriority > ntohl(value->prio)) ) {
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+    GE_LOG(coreAPI->ectx, GE_WARNING | GE_BULK | GE_USER,
        "Datastore full (%llu/%llu) and content priority too low to kick out 
other content.  Refusing put.\n",
        sq->getSize(), 
        quota);
@@ -247,7 +247,7 @@
     return OK;
   }
 #if DEBUG_DATASTORE
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+  GE_LOG(coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER,
       "Migration: available %llu (need %u), min priority %u have %u\n",
       available, ntohl(value->size),
       minPriority,
@@ -328,35 +328,46 @@
 Datastore_ServiceAPI *
 provide_module_datastore(CoreAPIForApplication * capi) {
   static Datastore_ServiceAPI api;
-  unsigned int lquota;
+  unsigned long long lquota;
+  unsigned int sqot;
 
-  lquota
-    = getConfigurationInt("FS", "QUOTA");
+  if (-1 == GC_get_configuration_value_number(capi->cfg,
+                                             "FS",
+                                             "QUOTA",
+                                             0,
+                                             ((unsigned long long)-1)/1024,
+                                             1024,
+                                             &lquota))
+    return; /* OOPS */  
+
   quota
-    = ((unsigned long long)lquota) * 1024L * 1024L; /* MB to bytes */
+    = lquota * 1024L * 1024L; /* MB to bytes */
   sq = capi->requestService("sqstore");
   if (sq == NULL) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK(coreAPI->ectx, 0);
     return NULL;
   }
-  lquota = htonl(lquota);
+  sqot = htonl(lquota);
   stateWriteContent("FS-LAST-QUOTA",
                    sizeof(unsigned int),
-                   &lquota);
+                   &sqot);
 
   coreAPI = capi;
 
-  initPrefetch(sq);
-  if (OK != initFilters()) {
+  initPrefetch(capi->ectx,
+              capi->cfg,
+              sq);
+  if (OK != initFilters(capi->ectx,
+                       capi->cfg)) {
     donePrefetch();
     return NULL;
   }
   cronMaintenance(NULL);
-  addCronJob(&cronMaintenance,
-            10 * cronSECONDS,
-            10 * cronSECONDS,
-            NULL);
-
+  cron_add_job(capi->cron,
+              &cronMaintenance,
+              10 * cronSECONDS,
+              10 * cronSECONDS,
+              NULL);
   api.getSize = &getSize;
   api.put = &put;
   api.fast_get = &fastGet;
@@ -372,9 +383,10 @@
  * Shutdown the manager module.
  */
 void release_module_datastore() {
-  delCronJob(&cronMaintenance,
-            10 * cronSECONDS,
-            NULL);
+  cron_del_job(coreAPI->cron,
+              &cronMaintenance,
+              10 * cronSECONDS,
+              NULL);
   donePrefetch();
   doneFilters();
   coreAPI->releaseService(sq);
@@ -399,12 +411,18 @@
  * different sqstore's here, too.
  */
 void update_module_datastore(UpdateAPI * uapi) {
-  int quota;
+  unsigned long long quota;
+  unsigned int lastQuota;
   int * lq;
-  int lastQuota;
 
-  quota
-    = getConfigurationInt("FS", "QUOTA");
+  if (-1 == GC_get_configuration_value_number(uapi->cfg,
+                                             "FS",
+                                             "QUOTA",
+                                             0,
+                                             ((unsigned long long)-1)/1024,
+                                             1024,
+                                             &quota))
+    return; /* OOPS */
   lq = NULL;
   if (sizeof(int) != stateReadContent("FS-LAST-QUOTA",
                                      (void**)&lq))
@@ -414,8 +432,10 @@
   if (lastQuota == quota)
     return; /* unchanged */
   /* ok, need to convert! */
-  deleteFilter();
-  initFilters();
+  deleteFilter(uapi->ectx,
+              uapi->cfg);
+  initFilters(uapi->ectx,
+             uapi->cfg);
   sq = uapi->requestService("sqstore");
   sq->get(NULL, ANY_BLOCK,
          &filterAddAll,

Modified: GNUnet/src/applications/datastore/prefetch.c
===================================================================
--- GNUnet/src/applications/datastore/prefetch.c        2006-07-31 04:34:44 UTC 
(rev 3201)
+++ GNUnet/src/applications/datastore/prefetch.c        2006-07-31 04:46:30 UTC 
(rev 3202)
@@ -79,7 +79,11 @@
 
 static struct PTHREAD * gather_thread;
 
+static struct GE_Context * ectx;
 
+static struct GC_Configuration * cfg;
+                 
+
 static int aquire(const HashCode512 * key,
                  const Datastore_Value * value,
                  void * closure) {
@@ -114,7 +118,8 @@
         value,
         ntohl(value->size));
   MUTEX_UNLOCK(lock);
-  load = getCPULoad(); /* FIXME: should use 'IO load' here */
+  load = os_cpu_get_load(ectx,
+                        cfg); /* FIXME: should use 'IO load' here */
   if (load < 10)
     load = 10;    /* never sleep less than 500 ms */
   if (load > 100)
@@ -140,7 +145,8 @@
                              NULL);
     /* sleep here, too - otherwise we start looping immediately
        if there is no content in the DB! */
-    load = getCPULoad();
+    load = os_cpu_get_load(ectx,
+                          cfg);
     if (load < 10)
       load = 10;    /* never sleep less than 500 ms */
     if (load > 100)
@@ -220,7 +226,11 @@
   return OK;
 }
                                
-void initPrefetch(SQstore_ServiceAPI * s) {
+void initPrefetch(struct GE_Context * e,
+                 struct GC_Configuration * c,
+                 SQstore_ServiceAPI * s) {
+  ectx = e;
+  cfg = c;
   sq = s;
   memset(randomContentBuffer,
         0,
@@ -240,15 +250,19 @@
   void * unused;
 
   doneSignal = SEMAPHORE_CREATE(0);
+  PTHREAD_STOP_SLEEP(gather_thread);
   SEMAPHORE_UP(acquireMoreSignal);
   SEMAPHORE_DOWN(doneSignal, YES);
   SEMAPHORE_DESTROY(acquireMoreSignal);
   SEMAPHORE_DESTROY(doneSignal);
-  PTHREAD_JOIN(&gather_thread, &unused);
+  PTHREAD_JOIN(gather_thread, &unused);
   for (i=0;i<rCBPos;i++)
     FREENONNULL(randomContentBuffer[i].value);
   MUTEX_DESTROY(lock);
   lock = NULL;
+  sq = NULL;
+  cfg = NULL;
+  ectx = NULL;
 }
 
 /* end of prefetch.c */

Modified: GNUnet/src/applications/datastore/prefetch.h
===================================================================
--- GNUnet/src/applications/datastore/prefetch.h        2006-07-31 04:34:44 UTC 
(rev 3201)
+++ GNUnet/src/applications/datastore/prefetch.h        2006-07-31 04:46:30 UTC 
(rev 3202)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002 Christian Grothoff (and other contributing authors)
+     (C) 2001, 2002, 2006 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
@@ -33,9 +33,11 @@
 /**
  * Initialize the migration module.
  */
-void initPrefetch(SQstore_ServiceAPI * sq);
+void initPrefetch(struct GE_Context * ectx,
+                 struct GC_Configuration * cfg,
+                 SQstore_ServiceAPI * sq);
 
-void donePrefetch();
+void donePrefetch(void);
 
 /**
  * Get a random value from the datastore that has

Modified: GNUnet/src/include/gnunet_core.h
===================================================================
--- GNUnet/src/include/gnunet_core.h    2006-07-31 04:34:44 UTC (rev 3201)
+++ GNUnet/src/include/gnunet_core.h    2006-07-31 04:46:30 UTC (rev 3202)
@@ -720,6 +720,16 @@
 typedef struct {
 
   /**
+   * System error context
+   */
+  struct GE_Context * ectx;
+
+  /**
+   * System configuration
+   */
+  struct GC_Configuration * cfg;
+
+  /**
    * Trigger updates for another module.
    */
   int (*updateModule)(const char * module);

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-07-31 04:34:44 UTC (rev 3201)
+++ GNUnet/todo 2006-07-31 04:46:30 UTC (rev 3202)
@@ -25,6 +25,7 @@
     + SMTP/HTTP: do not yet compile (commented out from build)
   * server:
     + needs testing, also likely to be missing features
+      - gnunet-update needs to initialize ectx + cfg in UpdateAPI struct
   * applications:
     + fragmentation, identity,  pingpong, session, transport,
       stats, topology_default, state, getoption, advertising,





reply via email to

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