gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14852 - in gnunet/src: datastore include


From: gnunet
Subject: [GNUnet-SVN] r14852 - in gnunet/src: datastore include
Date: Mon, 4 Apr 2011 19:57:21 +0200

Author: grothoff
Date: 2011-04-04 19:57:21 +0200 (Mon, 04 Apr 2011)
New Revision: 14852

Modified:
   gnunet/src/datastore/datastore_api.c
   gnunet/src/datastore/gnunet-service-datastore.c
   gnunet/src/datastore/plugin_datastore_sqlite.c
   gnunet/src/include/gnunet_datastore_plugin.h
   gnunet/src/include/gnunet_datastore_service.h
   gnunet/src/include/gnunet_protocols.h
Log:
renaming, fixes

Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c        2011-04-04 17:57:02 UTC (rev 
14851)
+++ gnunet/src/datastore/datastore_api.c        2011-04-04 17:57:21 UTC (rev 
14852)
@@ -166,8 +166,14 @@
    * Note that the overall struct should end at a 
    * multiple of 64 bits.
    */
-  int32_t was_transmitted;
+  int was_transmitted;
   
+  /**
+   * Are we expecting a single message in response to this
+   * request (and, if it is data, no 'END' message)?
+   */
+  int one_shot; 
+  
 };
 
 /**
@@ -1251,7 +1257,10 @@
          do_disconnect (h);      
          return;
        }
-      GNUNET_DATASTORE_iterate_get_next (h);
+      if (GNUNET_YES == qe->one_shot)
+       free_queue_entry (qe);
+      else
+       GNUNET_DATASTORE_iterate_get_next (h);
       return;
     }
   dm = (const struct DataMessage*) msg;
@@ -1273,6 +1282,8 @@
           ntohl(dm->anonymity),
           GNUNET_TIME_absolute_ntoh(dm->expiration),   
           GNUNET_ntohll(dm->uid));
+  if (GNUNET_YES == qe->one_shot)
+    free_queue_entry (qe);
 }
 
 
@@ -1310,7 +1321,7 @@
 
 #if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Asked to get random entry in %llu ms\n",
+             "Asked to get replication entry in %llu ms\n",
              (unsigned long long) timeout.rel_value);
 #endif
   qc.rc.iter = iter;
@@ -1322,16 +1333,17 @@
     {
 #if DEBUG_DATASTORE
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Could not create queue entry for GET RANDOM\n");
+                 "Could not create queue entry for GET REPLICATION\n");
 #endif
       return NULL;    
     }
+  qe->one_shot = GNUNET_YES;
   GNUNET_STATISTICS_update (h->stats,
-                           gettext_noop ("# GET RANDOM requests executed"),
+                           gettext_noop ("# GET REPLICATION requests 
executed"),
                            1,
                            GNUNET_NO);
   m = (struct GNUNET_MessageHeader*) &qe[1];
-  m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM);
+  m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION);
   m->size = htons(sizeof (struct GNUNET_MessageHeader));
   process_queue (h);
   return qe;
@@ -1368,6 +1380,7 @@
   struct GetZeroAnonymityMessage *m;
   union QueueContext qc;
 
+  GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
 #if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Asked to get zero-anonymity entry in %llu ms\n",

Modified: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c     2011-04-04 17:57:02 UTC 
(rev 14851)
+++ gnunet/src/datastore/gnunet-service-datastore.c     2011-04-04 17:57:21 UTC 
(rev 14852)
@@ -1240,24 +1240,24 @@
 
 
 /**
- * Handle GET_RANDOM-message.
+ * Handle GET_REPLICATION-message.
  *
  * @param cls closure
  * @param client identification of the client
  * @param message the actual message
  */
 static void
-handle_get_random (void *cls,
-                  struct GNUNET_SERVER_Client *client,
-                  const struct GNUNET_MessageHeader *message)
+handle_get_replication (void *cls,
+                       struct GNUNET_SERVER_Client *client,
+                       const struct GNUNET_MessageHeader *message)
 {
 #if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Processing `%s' request\n",
-             "GET_RANDOM");
+             "GET_REPLICATION");
 #endif
   GNUNET_STATISTICS_update (stats,
-                           gettext_noop ("# GET RANDOM requests received"),
+                           gettext_noop ("# GET REPLICATION requests 
received"),
                            1,
                            GNUNET_NO);
   GNUNET_SERVER_client_keep (client);
@@ -1282,6 +1282,12 @@
   enum GNUNET_BLOCK_Type type;
 
   type = (enum GNUNET_BLOCK_Type) ntohl (msg->type);
+  if (type == GNUNET_BLOCK_TYPE_ANY)
+    {
+      GNUNET_break (0);
+      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+      return;
+    }
 #if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Processing `%s' request\n",
@@ -1706,7 +1712,7 @@
     {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE, 
      sizeof (struct UpdateMessage) }, 
     {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 }, 
-    {&handle_get_random, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM, 
+    {&handle_get_replication, NULL, 
GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION, 
      sizeof(struct GNUNET_MessageHeader) }, 
     {&handle_get_zero_anonymity, NULL, 
GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, 
      sizeof(struct GetZeroAnonymityMessage) }, 

Modified: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c      2011-04-04 17:57:02 UTC 
(rev 14851)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c      2011-04-04 17:57:21 UTC 
(rev 14852)
@@ -1028,12 +1028,14 @@
   sqlite3_stmt *stmt_2;
   char *q;
 
+  GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
   now = GNUNET_TIME_absolute_get ();
   GNUNET_asprintf (&q, 
                   "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM 
gn090 "
-                  "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND 
hash < ?2) "
+                  "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND 
type=%d AND hash < ?2) "
                   "ORDER BY hash DESC LIMIT 1",
-                  (unsigned long long) now.abs_value);
+                  (unsigned long long) now.abs_value,
+                  type);
   if (sq_prepare (plugin->dbh, q, &stmt_1) != SQLITE_OK)
     {
       LOG_SQLITE (plugin, NULL,
@@ -1046,9 +1048,10 @@
   GNUNET_free (q);
   GNUNET_asprintf (&q, 
                   "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM 
gn090 "
-                  "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0) "
+                  "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0 AND 
type=%d) "
                   "ORDER BY prio DESC, hash DESC LIMIT 1",
-                  (unsigned long long) now.abs_value);
+                  (unsigned long long) now.abs_value,
+                  type);
   if (sq_prepare (plugin->dbh, q, &stmt_2) != SQLITE_OK)
     {
       LOG_SQLITE (plugin, NULL,

Modified: gnunet/src/include/gnunet_datastore_plugin.h
===================================================================
--- gnunet/src/include/gnunet_datastore_plugin.h        2011-04-04 17:57:02 UTC 
(rev 14851)
+++ gnunet/src/include/gnunet_datastore_plugin.h        2011-04-04 17:57:21 UTC 
(rev 14852)
@@ -245,7 +245,7 @@
  *
  * @param cls closure
  * @param type entries of which type should be considered?
- *        Use 0 for any type.
+ *        Myst not be zero (ANY).
  * @param iter function to call on each matching value; however,
  *        after the first call to "iter", the plugin must wait
  *        until "NextRequest" was called before giving the iterator
@@ -294,6 +294,16 @@
   PluginPut put;
 
   /**
+   * Update the priority for a particular key in the datastore.  If
+   * the expiration time in value is different than the time found in
+   * the datastore, the higher value should be kept.  For the
+   * anonymity level, the lower value is to be used.  The specified
+   * priority should be added to the existing priority, ignoring the
+   * priority in value.
+   */
+  PluginUpdate update;
+
+  /**
    * Function called by iterators whenever they want the next value;
    * note that unlike all of the other callbacks, this one does get a
    * the "next_cls" closure which is usually different from the "cls"
@@ -308,6 +318,11 @@
   PluginGet get;
 
   /**
+   * Iterate over content with anonymity level zero.
+   */
+  PluginSelector iter_zero_anonymity;
+
+  /**
    * Function to get a random item with high replication score from
    * the database, lowering the item's replication score.  Returns a
    * single, not expired, random item from those with the highest
@@ -323,21 +338,6 @@
   PluginRandomGet expiration_get;
 
   /**
-   * Update the priority for a particular key in the datastore.  If
-   * the expiration time in value is different than the time found in
-   * the datastore, the higher value should be kept.  For the
-   * anonymity level, the lower value is to be used.  The specified
-   * priority should be added to the existing priority, ignoring the
-   * priority in value.
-   */
-  PluginUpdate update;
-
-  /**
-   * Iterate over content with anonymity level zero.
-   */
-  PluginSelector iter_zero_anonymity;
-
-  /**
    * Delete the database.  The next operation is
    * guaranteed to be unloading of the module.
    */

Modified: gnunet/src/include/gnunet_datastore_service.h
===================================================================
--- gnunet/src/include/gnunet_datastore_service.h       2011-04-04 17:57:02 UTC 
(rev 14851)
+++ gnunet/src/include/gnunet_datastore_service.h       2011-04-04 17:57:21 UTC 
(rev 14852)
@@ -322,7 +322,7 @@
  * @param max_queue_size at what queue size should this request be dropped
  *        (if other requests of higher priority are in the queue)
  * @param timeout how long to wait at most for a response
- * @param type allowed type for the operation (ANY for 'all types')
+ * @param type allowed type for the operation (never zero)
  * @param iter function to call on a random value; it
  *        will be called once with a value (if available)
  *        and always once with a value of NULL at the end.

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2011-04-04 17:57:02 UTC (rev 
14851)
+++ gnunet/src/include/gnunet_protocols.h       2011-04-04 17:57:21 UTC (rev 
14852)
@@ -452,7 +452,7 @@
 /**
  * Message sent by datastore client to get random data.
  */
-#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM 98
+#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION 98
 
 /**
  * Message sent by datastore client to get random data.




reply via email to

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