gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r34824 - in gnunet/src: datastore include
Date: Tue, 6 Jan 2015 02:11:45 +0100

Author: amatus
Date: 2015-01-06 02:11:45 +0100 (Tue, 06 Jan 2015)
New Revision: 34824

Modified:
   gnunet/src/datastore/gnunet-service-datastore.c
   gnunet/src/datastore/plugin_datastore_heap.c
   gnunet/src/datastore/plugin_datastore_mysql.c
   gnunet/src/datastore/plugin_datastore_postgres.c
   gnunet/src/datastore/plugin_datastore_sqlite.c
   gnunet/src/datastore/plugin_datastore_template.c
   gnunet/src/datastore/test_plugin_datastore.c
   gnunet/src/include/gnunet_datastore_plugin.h
Log:
Workaround emscripten bug in returning int64_t

Emscripten can't return a 64-bit integer from dynamically loaded code.


Modified: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c     2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/datastore/gnunet-service-datastore.c     2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -1241,7 +1241,7 @@
                 _("Datastore payload must have been inaccurate (%lld < %lld). 
Recomputing it.\n"),
                 (long long) payload,
                 (long long) -delta);
-    payload = plugin->api->estimate_size (plugin->api->cls);
+    plugin->api->estimate_size (plugin->api->cls, &payload);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 _("New payload: %lld\n"),
                 (long long) payload);
@@ -1404,7 +1404,7 @@
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Failed to obtain value from statistics service, recomputing 
it\n");
-    payload = plugin->api->estimate_size (plugin->api->cls);
+    plugin->api->estimate_size (plugin->api->cls, &payload);
   }
   if (GNUNET_YES == refresh_bf)
   {

Modified: gnunet/src/datastore/plugin_datastore_heap.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_heap.c        2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/datastore/plugin_datastore_heap.c        2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -184,12 +184,13 @@
  * @param cls our "struct Plugin*"
  * @return number of bytes used on disk
  */
-static unsigned long long
-heap_plugin_estimate_size (void *cls)
+static void
+heap_plugin_estimate_size (void *cls, unsigned long long *estimate)
 {
   struct Plugin *plugin = cls;
 
-  return plugin->size;
+  if (NULL != estimate)
+    *estimate = plugin->size;
 }
 
 

Modified: gnunet/src/datastore/plugin_datastore_mysql.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_mysql.c       2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/datastore/plugin_datastore_mysql.c       2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -246,22 +246,25 @@
  * @param cls our "struct Plugin *"
  * @return number of bytes used on disk
  */
-static unsigned long long
-mysql_plugin_estimate_size (void *cls)
+static void
+mysql_plugin_estimate_size (void *cls, unsigned long long *estimate)
 {
   struct Plugin *plugin = cls;
   MYSQL_BIND cbind[1];
   long long total;
 
+  if (NULL == estimate)
+    return;
   memset (cbind, 0, sizeof (cbind));
   total = 0;
   cbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
   cbind[0].buffer = &total;
   cbind[0].is_unsigned = GNUNET_NO;
-  if (GNUNET_OK !=
+  if (GNUNET_OK ==
       GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, 
plugin->get_size, 1, cbind, NULL, NULL, -1))
-    return 0;
-  return total;
+    *estimate = total;
+  else
+    *estimate = 0;
 }
 
 

Modified: gnunet/src/datastore/plugin_datastore_postgres.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_postgres.c    2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/datastore/plugin_datastore_postgres.c    2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -228,13 +228,15 @@
  * @param cls our `struct Plugin *`
  * @return number of bytes used on disk
  */
-static unsigned long long
-postgres_plugin_estimate_size (void *cls)
+static void
+postgres_plugin_estimate_size (void *cls, unsigned long long *estimate)
 {
   struct Plugin *plugin = cls;
   unsigned long long total;
   PGresult *ret;
 
+  if (NULL == estimate)
+    return;
   ret =
       PQexecParams (plugin->dbh,
                     "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0,
@@ -242,23 +244,26 @@
   if (GNUNET_OK !=
       GNUNET_POSTGRES_check_result (plugin->dbh, ret, PGRES_TUPLES_OK, 
"PQexecParams", "get_size"))
   {
-    return 0;
+    *estimate = 0;
+    return;
   }
   if ((PQntuples (ret) != 1) || (PQnfields (ret) != 1) )
   {
     GNUNET_break (0);
     PQclear (ret);
-    return 0;
+    *estimate = 0;
+    return;
   }
   if (PQgetlength (ret, 0, 0) != sizeof (unsigned long long))
   {
     GNUNET_break (0 == PQgetlength (ret, 0, 0));
     PQclear (ret);
-    return 0;
+    *estimate = 0;
+    return;
   }
   total = GNUNET_ntohll (*(const unsigned long long *) PQgetvalue (ret, 0, 0));
   PQclear (ret);
-  return total;
+  *estimate = total;
 }
 
 

Modified: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c      2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c      2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -1135,8 +1135,8 @@
  * @param cls the `struct Plugin`
  * @return the size of the database on disk (estimate)
  */
-static unsigned long long
-sqlite_plugin_estimate_size (void *cls)
+static void
+sqlite_plugin_estimate_size (void *cls, unsigned long long *estimate)
 {
   struct Plugin *plugin = cls;
   sqlite3_stmt *stmt;
@@ -1147,12 +1147,15 @@
   char *e;
 #endif
 
+  if (NULL == estimate)
+    return;
   if (SQLITE_VERSION_NUMBER < 3006000)
   {
     GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "datastore-sqlite",
                      _
                      ("sqlite version to old to determine size, assuming 
zero\n"));
-    return 0;
+    *estimate = 0;
+    return;
   }
   CHECK (SQLITE_OK == sqlite3_exec (plugin->dbh, "VACUUM", NULL, NULL, ENULL));
   CHECK (SQLITE_OK ==
@@ -1172,7 +1175,7 @@
               _
               ("Using sqlite page utilization to estimate payload (%llu pages 
of size %llu bytes)\n"),
               (unsigned long long) pages, (unsigned long long) page_size);
-  return pages * page_size;
+  *estimate = pages * page_size;
 }
 
 

Modified: gnunet/src/datastore/plugin_datastore_template.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_template.c    2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/datastore/plugin_datastore_template.c    2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -47,11 +47,13 @@
  * @param cls our "struct Plugin*"
  * @return number of bytes used on disk
  */
-static unsigned long long
-template_plugin_estimate_size (void *cls)
+static void
+template_plugin_estimate_size (void *cls, unsigned long long *estimate)
 {
+  if (NULL == estimate)
+    return;
   GNUNET_break (0);
-  return 0;
+  *estimate = 0;
 }
 
 

Modified: gnunet/src/datastore/test_plugin_datastore.c
===================================================================
--- gnunet/src/datastore/test_plugin_datastore.c        2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/datastore/test_plugin_datastore.c        2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -241,7 +241,7 @@
     for (j = 0; j < PUT_10; j++)
     {
       put_value (crc->api, j, crc->i);
-      cs = crc->api->estimate_size (crc->api->cls);
+      crc->api->estimate_size (crc->api->cls, &cs);
       GNUNET_assert (os <= cs);
       os = cs;
     }

Modified: gnunet/src/include/gnunet_datastore_plugin.h
===================================================================
--- gnunet/src/include/gnunet_datastore_plugin.h        2015-01-05 14:57:33 UTC 
(rev 34823)
+++ gnunet/src/include/gnunet_datastore_plugin.h        2015-01-06 01:11:45 UTC 
(rev 34824)
@@ -103,9 +103,10 @@
  * currently using.
  *
  * @param cls closure
+ * @param estimate location to store estimate
  * @return number of bytes used on disk
  */
-typedef unsigned long long (*PluginEstimateSize) (void *cls);
+typedef void (*PluginEstimateSize) (void *cls, unsigned long long *estimate);
 
 
 /**




reply via email to

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