(no commit message)
[oweals/gnunet.git] / src / datastore / plugin_datastore_postgres.c
index 248fe7a961b895721332ba14944d333439a73a02..aa92d7620908512e6abbb9050a6cbe92912cdd0f 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #include "platform.h"
-#include "plugin_datastore.h"
+#include "gnunet_datastore_plugin.h"
 #include <postgresql/libpq-fe.h>
 
 #define DEBUG_POSTGRES GNUNET_NO
@@ -315,22 +315,25 @@ init_connection (struct Plugin *plugin)
                                         "CONFIG",
                                         &conninfo);
   plugin->dbh = PQconnectdb (conninfo == NULL ? "" : conninfo);
-  GNUNET_free_non_null (conninfo);
   if (NULL == plugin->dbh)
     {
       /* FIXME: warn about out-of-memory? */
+      GNUNET_free_non_null (conninfo);
       return GNUNET_SYSERR;
     }
   if (PQstatus (plugin->dbh) != CONNECTION_OK)
     {
       GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
                       "datastore-postgres",
-                      _("Unable to initialize Postgres: %s"),
+                      _("Unable to initialize Postgres with configuration `%s': %s"),
+                      conninfo,
                       PQerrorMessage (plugin->dbh));
       PQfinish (plugin->dbh);
       plugin->dbh = NULL;
+      GNUNET_free_non_null (conninfo);
       return GNUNET_SYSERR;
     }
+  GNUNET_free_non_null (conninfo);
   ret = PQexec (plugin->dbh,
                 "CREATE TABLE gn090 ("
                 "  type INTEGER NOT NULL DEFAULT 0,"
@@ -605,7 +608,7 @@ postgres_plugin_put (void *cls,
   uint32_t btype = htonl (type);
   uint32_t bprio = htonl (priority);
   uint32_t banon = htonl (anonymity);
-  uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).value__;
+  uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).abs_value__;
   const char *paramValues[] = {
     (const char *) &btype,
     (const char *) &bprio,
@@ -847,8 +850,7 @@ postgres_plugin_next_request (void *next_cls,
   if (GNUNET_YES == end_it)
     nrc->end_it = GNUNET_YES;
   nrc->plugin->next_task_nc = nrc;
-  nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (nrc->plugin->env->sched,
-                                                    &postgres_next_request_cont,
+  nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (&postgres_next_request_cont,
                                                     nrc);
 }
 
@@ -886,7 +888,7 @@ postgres_plugin_update (void *cls,
   PGresult *ret;
   int32_t bdelta = (int32_t) htonl ((uint32_t) delta);
   uint32_t boid = htonl ( (uint32_t) uid);
-  uint64_t bexpire = GNUNET_TIME_absolute_hton (expire).value__;
+  uint64_t bexpire = GNUNET_TIME_absolute_hton (expire).abs_value__;
   const char *paramValues[] = {
     (const char *) &bdelta,
     (const char *) &bexpire,
@@ -996,7 +998,7 @@ postgres_iterate (struct Plugin *plugin,
       GNUNET_free (nrc);
       return;
     }
-  nrc->bnow = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()).value__;
+  nrc->bnow = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()).abs_value__;
   postgres_plugin_next_request (nrc,
                                GNUNET_NO);
 }
@@ -1358,8 +1360,7 @@ libgnunet_plugin_datastore_postgres_done (void *cls)
   
   if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK)
     {
-      GNUNET_SCHEDULER_cancel (plugin->env->sched,
-                              plugin->next_task);
+      GNUNET_SCHEDULER_cancel (plugin->next_task);
       plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
       GNUNET_free (plugin->next_task_nc);
       plugin->next_task_nc = NULL;