TRUST = $SERVICEHOME/data/credit/
IDENTITY_DIR = $SERVICEHOME/identities/
STATE_DIR = $SERVICEHOME/persistence/
+UPDATE_DIR = $SERVICEHOME/updates/
PORT = 2094
HOSTNAME = localhost
HOME = $SERVICEHOME
if (msg == NULL)
{
free_queue_entry (qe);
+ rc.cont (rc.cont_cls,
+ GNUNET_SYSERR,
+ _("Failed to receive response from database."));
if (NULL == h->client)
return; /* forced disconnect */
if (was_transmitted == GNUNET_YES)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to receive response from database.\n"));
- do_disconnect (h);
- }
+ do_disconnect (h);
return;
}
GNUNET_assert (GNUNET_YES == qe->was_transmitted);
h->in_receive = GNUNET_NO;
if (msg == NULL)
- {
+ {
was_transmitted = qe->was_transmitted;
free_queue_entry (qe);
if (was_transmitted == GNUNET_YES)
GNUNET_SCHEDULER_add_delayed (sched,
GNUNET_TIME_UNIT_FOREVER_REL,
&cleaning_task, NULL);
-
}
}
+
+static void
+run_tests (void *cls,
+ int success,
+ const char *msg)
+{
+ struct CpsRunContext *crc = cls;
+
+ if (success != GNUNET_YES)
+ {
+ fprintf (stderr,
+ "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
+ msg);
+ GNUNET_free (crc);
+ return;
+ }
+ GNUNET_SCHEDULER_add_continuation (crc->sched,
+ &run_continuation,
+ crc,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+}
+
+
static void
run (void *cls,
struct GNUNET_SCHEDULER_Handle *sched,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct CpsRunContext *crc;
+ static GNUNET_HashCode zkey;
datastore = GNUNET_DATASTORE_connect (cfg, sched);
start_time = GNUNET_TIME_absolute_get ();
crc->sched = sched;
crc->cfg = cfg;
crc->phase = RP_PUT;
- GNUNET_SCHEDULER_add_continuation (crc->sched,
- &run_continuation,
- crc,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ if (NULL ==
+ GNUNET_DATASTORE_put (datastore, 0,
+ &zkey, 4, "TEST",
+ GNUNET_BLOCK_TYPE_TEST,
+ 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
+ 0, 1, GNUNET_TIME_UNIT_MINUTES,
+ &run_tests, crc))
+ {
+ fprintf (stderr,
+ "Test 'put' operation failed.\n");
+ ok = 1;
+ GNUNET_free (crc);
+ }
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Loading `%s' datastore plugin\n"), name);
GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
- GNUNET_assert (NULL != (ret = GNUNET_PLUGIN_load (libname, &env)));
+ if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env)))
+ {
+ fprintf (stderr,
+ "Failed to load plugin `%s'!\n",
+ name);
+ return NULL;
+ }
GNUNET_free (libname);
GNUNET_free (name);
return ret;
struct CpsRunContext *crc;
api = load_plugin (c, s);
- GNUNET_assert (api != NULL);
+ if (api == NULL)
+ {
+ fprintf (stderr,
+ "Could not initialize plugin, assuming database not configured. Test not run!\n");
+ return;
+ }
crc = GNUNET_malloc(sizeof(struct CpsRunContext));
crc->api = api;
crc->sched = s;
crc->cfg = c;
crc->phase = RP_PUT;
- GNUNET_SCHEDULER_add_after (s,
- GNUNET_SCHEDULER_NO_TASK,
- &test, crc);
+ GNUNET_SCHEDULER_add_now (crc->sched,
+ &test, crc);
}
# REJECT_FROM6 =
# PREFIX =
+
[dht]
AUTOSTART = NO
}
+static void
+run_tests (void *cls,
+ int success,
+ const char *msg)
+{
+ struct CpsRunContext *crc = cls;
+
+ if (success != GNUNET_YES)
+ {
+ fprintf (stderr,
+ "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
+ msg);
+ GNUNET_free (crc);
+ return;
+ }
+ GNUNET_SCHEDULER_add_continuation (crc->sched,
+ &run_continuation,
+ crc,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+}
+
+
static void
run (void *cls,
struct GNUNET_SCHEDULER_Handle *sched,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct CpsRunContext *crc;
+ static GNUNET_HashCode zkey;
crc = GNUNET_malloc(sizeof(struct CpsRunContext));
crc->sched = sched;
crc->phase = RP_PUT;
now = GNUNET_TIME_absolute_get ();
datastore = GNUNET_DATASTORE_connect (cfg, sched);
- GNUNET_SCHEDULER_add_continuation (crc->sched,
- &run_continuation,
- crc,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-
+ if (NULL ==
+ GNUNET_DATASTORE_put (datastore, 0,
+ &zkey, 4, "TEST",
+ GNUNET_BLOCK_TYPE_TEST,
+ 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
+ 0, 1, GNUNET_TIME_UNIT_MINUTES,
+ &run_tests, crc))
+ {
+ fprintf (stderr,
+ "Test 'put' operation failed.\n");
+ ok = 1;
+ GNUNET_free (crc);
+ }
}
-
static int
check ()
{
}
+static void
+run_tests (void *cls,
+ int success,
+ const char *msg)
+{
+ struct CpsRunContext *crc = cls;
+
+ if (success != GNUNET_YES)
+ {
+ fprintf (stderr,
+ "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
+ msg);
+ GNUNET_free (crc);
+ return;
+ }
+ GNUNET_SCHEDULER_add_continuation (crc->sched,
+ &run_continuation,
+ crc,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+}
+
+
static void
run (void *cls,
struct GNUNET_SCHEDULER_Handle *sched,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct CpsRunContext *crc;
+ static GNUNET_HashCode zkey;
crc = GNUNET_malloc(sizeof(struct CpsRunContext));
crc->sched = sched;
crc->phase = RP_PUT;
now = GNUNET_TIME_absolute_get ();
datastore = GNUNET_DATASTORE_connect (cfg, sched);
- GNUNET_SCHEDULER_add_continuation (crc->sched,
- &run_continuation,
- crc,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-
+ if (NULL ==
+ GNUNET_DATASTORE_put (datastore, 0,
+ &zkey, 4, "TEST",
+ GNUNET_BLOCK_TYPE_TEST,
+ 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
+ 0, 1, GNUNET_TIME_UNIT_MINUTES,
+ &run_tests, crc))
+ {
+ fprintf (stderr,
+ "Test 'put' operation failed.\n");
+ GNUNET_free (crc);
+ ok = 1;
+ }
}
/**
* Type of a block that is used to advertise a namespace.
*/
- GNUNET_BLOCK_TYPE_NBLOCK = 6
+ GNUNET_BLOCK_TYPE_NBLOCK = 6,
+
+ GNUNET_BLOCK_TYPE_TEST = 9999
};
/**
- * List all of the identifiers in the namespace for
- * which we could produce an update.
+ * List all of the identifiers in the namespace for which we could
+ * produce an update. Namespace updates form a graph where each node
+ * has a name. Each node can have any number of URI/meta-data entries
+ * which can each be linked to other nodes. Cycles are possible.
+ *
+ * Calling this function with "next_id" NULL will cause the library to
+ * call "ip" with a root for each strongly connected component of the
+ * graph (a root being a node from which all other nodes in the Scc
+ * are reachable).
+ *
+ * Calling this function with "next_id" being the name of a node will
+ * cause the library to call "ip" with all children of the node. Note
+ * that cycles within an SCC are possible (including self-loops).
*
* @param namespace namespace to inspect for updateable content
+ * @param next_id ID to look for; use NULL to look for SCC roots
* @param ip function to call on each updateable identifier
* @param ip_cls closure for ip
*/
void
GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
+ const char *next_id,
GNUNET_FS_IdentifierProcessor ip,
void *ip_cls);
int
GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg)
{
- *emsg = h->emsg;
+ int err;
+
+ err = (NULL == h->emsg) ? GNUNET_OK : GNUNET_SYSERR;
+ if (emsg != NULL)
+ *emsg = h->emsg;
+ else
+ GNUNET_free_non_null (h->emsg);
GNUNET_DISK_file_close (h->fd);
GNUNET_free (h);
- return (NULL == *emsg) ? GNUNET_OK : GNUNET_SYSERR;
+ return err;
}