gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (cbd60b5e5 -> d38342d59)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (cbd60b5e5 -> d38342d59)
Date: Wed, 06 Jun 2018 07:56:13 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from cbd60b5e5 first batch of license fixes (boring)
     new f461f068d implement proper expiration logic also for postgres plugin
     new 73ab0f26d better indentation
     new f651dba09 better indentation, nicer formatting of SQL
     new d38342d59 fix linker issue

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/datacache/datacache.c                 |  3 +-
 src/datacache/plugin_datacache_postgres.c | 60 +++++++++++++++++++++----------
 src/datastore/plugin_datastore_postgres.c | 32 +++++++++--------
 src/datastore/plugin_datastore_sqlite.c   |  8 +++--
 src/rps/Makefile.am                       |  1 +
 5 files changed, 67 insertions(+), 37 deletions(-)

diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index 7ee8dc954..39cd6126d 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -311,7 +311,8 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
                             1,
                             GNUNET_NO);
   while (h->utilization + used > h->env.quota)
-    GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls));
+    GNUNET_assert (GNUNET_OK ==
+                  h->api->del (h->api->cls));
   h->utilization += used;
   return GNUNET_OK;
 }
diff --git a/src/datacache/plugin_datacache_postgres.c 
b/src/datacache/plugin_datacache_postgres.c
index 683c6148a..33b317e87 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     Copyright (C) 2006, 2009, 2010, 2012, 2015, 2017 GNUnet e.V.
+     Copyright (C) 2006, 2009, 2010, 2012, 2015, 2017, 2018 GNUnet e.V.
 
      GNUnet is free software: you can redistribute it and/or modify it
      under the terms of the GNU General Public License as published
@@ -62,47 +62,57 @@ static int
 init_connection (struct Plugin *plugin)
 {
   struct GNUNET_PQ_ExecuteStatement es[] = {
-    GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS gn090dc ("
+    GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS gn011dc ("
                             "  type INTEGER NOT NULL,"
+                            "  prox INTEGER NOT NULL,"
                             "  discard_time BIGINT NOT NULL,"
                             "  key BYTEA NOT NULL,"
                             "  value BYTEA NOT NULL,"
                             "  path BYTEA DEFAULT NULL)"
                             "WITH OIDS"),
-    GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS idx_key ON gn090dc 
(key)"),
-    GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS idx_dt ON gn090dc 
(discard_time)"),
-    GNUNET_PQ_make_execute ("ALTER TABLE gn090dc ALTER value SET STORAGE 
EXTERNAL"),
-    GNUNET_PQ_make_execute ("ALTER TABLE gn090dc ALTER key SET STORAGE PLAIN"),
+    GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS idx_key ON gn011dc 
(key)"),
+    GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS idx_dt ON gn011dc 
(discard_time)"),
+    GNUNET_PQ_make_execute ("ALTER TABLE gn011dc ALTER value SET STORAGE 
EXTERNAL"),
+    GNUNET_PQ_make_execute ("ALTER TABLE gn011dc ALTER key SET STORAGE PLAIN"),
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
   struct GNUNET_PQ_PreparedStatement ps[] = {
     GNUNET_PQ_make_prepare ("getkt",
-                            "SELECT discard_time,type,value,path FROM gn090dc "
+                            "SELECT discard_time,type,value,path FROM gn011dc "
                             "WHERE key=$1 AND type=$2",
                             2),
     GNUNET_PQ_make_prepare ("getk",
-                            "SELECT discard_time,type,value,path FROM gn090dc "
+                            "SELECT discard_time,type,value,path FROM gn011dc "
                             "WHERE key=$1",
                             1),
+    GNUNET_PQ_make_prepare ("getex",
+                            "SELECT length(value) AS len,oid,key FROM gn011dc"
+                           " WHERE discard_time < $1"
+                            " ORDER BY discard_time ASC LIMIT 1",
+                            1),
     GNUNET_PQ_make_prepare ("getm",
-                            "SELECT length(value) AS len,oid,key FROM gn090dc "
+                            "SELECT length(value) AS len,oid,key FROM gn011dc"
+                            " ORDER BY prox ASC, discard_time ASC LIMIT 1",
+                            0),
+    GNUNET_PQ_make_prepare ("getp",
+                            "SELECT length(value) AS len,oid,key FROM gn011dc "
                             "ORDER BY discard_time ASC LIMIT 1",
                             0),
     GNUNET_PQ_make_prepare ("get_random",
-                            "SELECT discard_time,type,value,path,key FROM 
gn090dc "
+                            "SELECT discard_time,type,value,path,key FROM 
gn011dc "
                             "ORDER BY key ASC LIMIT 1 OFFSET $1",
                             1),
     GNUNET_PQ_make_prepare ("get_closest",
-                            "SELECT discard_time,type,value,path,key FROM 
gn090dc "
+                            "SELECT discard_time,type,value,path,key FROM 
gn011dc "
                             "WHERE key>=$1 ORDER BY key ASC LIMIT $2",
                             1),
     GNUNET_PQ_make_prepare ("delrow",
-                            "DELETE FROM gn090dc WHERE oid=$1",
+                            "DELETE FROM gn011dc WHERE oid=$1",
                             1),
     GNUNET_PQ_make_prepare ("put",
-                            "INSERT INTO gn090dc (type, discard_time, key, 
value, path) "
-                            "VALUES ($1, $2, $3, $4, $5)",
-                            5),
+                            "INSERT INTO gn011dc (type, prox, discard_time, 
key, value, path) "
+                            "VALUES ($1, $2, $3, $4, $5, $6)",
+                            6),
     GNUNET_PQ_PREPARED_STATEMENT_END
   };
 
@@ -136,7 +146,7 @@ init_connection (struct Plugin *plugin)
  *
  * @param cls closure (our `struct Plugin`)
  * @param key key to store @a data under
- * @param am_closest are we the closest peer?
+ * @param prox proximity of @a key to my PID
  * @param data_size number of bytes in @a data
  * @param data data to store
  * @param type type of the value
@@ -148,7 +158,7 @@ init_connection (struct Plugin *plugin)
 static ssize_t
 postgres_plugin_put (void *cls,
                      const struct GNUNET_HashCode *key,
-                     int am_closest,
+                     uint32_t prox,
                      size_t data_size,
                      const char *data,
                      enum GNUNET_BLOCK_Type type,
@@ -160,6 +170,7 @@ postgres_plugin_put (void *cls,
   uint32_t type32 = (uint32_t) type;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_uint32 (&type32),
+    GNUNET_PQ_query_param_uint32 (&prox),
     GNUNET_PQ_query_param_absolute_time (&discard_time),
     GNUNET_PQ_query_param_auto_from_type (key),
     GNUNET_PQ_query_param_fixed_size (data, data_size),
@@ -356,11 +367,22 @@ postgres_plugin_del (void *cls)
     GNUNET_PQ_query_param_uint32 (&oid),
     GNUNET_PQ_query_param_end
   };
+  struct GNUNET_TIME_Absolute now;
+  struct GNUNET_PQ_QueryParam xparam[] = {
+    GNUNET_PQ_query_param_absolute_time (&now),
+    GNUNET_PQ_query_param_end
+  };
 
+  now = GNUNET_TIME_absolute_get ();
   res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh,
-                                                  "getm",
-                                                  pempty,
+                                                  "getex",
+                                                  xparam,
                                                   rs);
+  if (0 >= res)
+    res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh,
+                                                   "getm",
+                                                   pempty,
+                                                   rs);
   if (0 > res)
     return GNUNET_SYSERR;
   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == res)
diff --git a/src/datastore/plugin_datastore_postgres.c 
b/src/datastore/plugin_datastore_postgres.c
index 0dc22b0f2..30013ef76 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -96,23 +96,23 @@ init_connection (struct Plugin *plugin)
 #define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, oid"
   struct GNUNET_PQ_PreparedStatement ps[] = {
     GNUNET_PQ_make_prepare ("get",
-                            "SELECT " RESULT_COLUMNS " FROM gn090 "
-                            "WHERE oid >= $1::bigint AND "
-                            "(rvalue >= $2 OR 0 = $3::smallint) AND "
-                            "(hash = $4 OR 0 = $5::smallint) AND "
-                            "(type = $6 OR 0 = $7::smallint) "
-                            "ORDER BY oid ASC LIMIT 1",
+                            "SELECT " RESULT_COLUMNS " FROM gn090"
+                            " WHERE oid >= $1::bigint AND"
+                            " (rvalue >= $2 OR 0 = $3::smallint) AND"
+                            " (hash = $4 OR 0 = $5::smallint) AND"
+                            " (type = $6 OR 0 = $7::smallint)"
+                            " ORDER BY oid ASC LIMIT 1",
                             7),
     GNUNET_PQ_make_prepare ("put",
                             "INSERT INTO gn090 (repl, type, prio, anonLevel, 
expire, rvalue, hash, vhash, value) "
                             "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
                             9),
     GNUNET_PQ_make_prepare ("update",
-                            "UPDATE gn090 "
-                            "SET prio = prio + $1, "
-                            "repl = repl + $2, "
-                            "expire = GREATEST(expire, $3) "
-                            "WHERE hash = $4 AND vhash = $5",
+                            "UPDATE gn090"
+                            " SET prio = prio + $1,"
+                            " repl = repl + $2,"
+                            " expire = GREATEST(expire, $3)"
+                            " WHERE hash = $4 AND vhash = $5",
                             5),
     GNUNET_PQ_make_prepare ("decrepl",
                             "UPDATE gn090 SET repl = GREATEST (repl - 1, 0) "
@@ -136,11 +136,13 @@ init_connection (struct Plugin *plugin)
                             "ORDER BY repl DESC,RANDOM() LIMIT 1",
                             0),
     GNUNET_PQ_make_prepare ("delrow",
-                            "DELETE FROM gn090 " "WHERE oid=$1",
+                            "DELETE FROM gn090 "
+                           "WHERE oid=$1",
                             1),
-    GNUNET_PQ_make_prepare ("remove", "DELETE FROM gn090 "
-                            "WHERE hash = $1 AND "
-                            "value = $2",
+    GNUNET_PQ_make_prepare ("remove",
+                           "DELETE FROM gn090"
+                            " WHERE hash = $1 AND"
+                            " value = $2",
                             2),
     GNUNET_PQ_make_prepare ("get_keys",
                             "SELECT hash FROM gn090",
diff --git a/src/datastore/plugin_datastore_sqlite.c 
b/src/datastore/plugin_datastore_sqlite.c
index 331b9f7f1..862977b9a 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -704,12 +704,16 @@ sqlite_plugin_put (void *cls,
     break;
   case SQLITE_BUSY:
     GNUNET_break (0);
-    LOG_SQLITE_MSG (plugin, &msg, GNUNET_ERROR_TYPE_ERROR | 
GNUNET_ERROR_TYPE_BULK,
+    LOG_SQLITE_MSG (plugin,
+                   &msg,
+                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                     "sqlite3_step");
     ret = GNUNET_SYSERR;
     break;
   default:
-    LOG_SQLITE_MSG (plugin, &msg, GNUNET_ERROR_TYPE_ERROR | 
GNUNET_ERROR_TYPE_BULK,
+    LOG_SQLITE_MSG (plugin,
+                   &msg,
+                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                     "sqlite3_step");
     GNUNET_SQ_reset (plugin->dbh,
                      stmt);
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am
index aa354dff7..33e03af76 100644
--- a/src/rps/Makefile.am
+++ b/src/rps/Makefile.am
@@ -91,6 +91,7 @@ rps_test_src = \
 ld_rps_test_lib = \
        libgnunetrps.la \
   $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/testbed/libgnunettestbed.la \
   -lm
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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