static struct GNUNET_NAMESTORE_Handle * nsh;
static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
+static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task;
static struct GNUNET_OS_Process *arm;
static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
static void
endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (stopiteration_task);
+ stopiteration_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+
if (nsh != NULL)
GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
nsh = NULL;
static void
end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (stopiteration_task);
+ stopiteration_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+
if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = GNUNET_SCHEDULER_NO_TASK;
}
+
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
privkey = NULL;
res = 0;
}
+static void
+stop_iteration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ stopiteration_task = GNUNET_SCHEDULER_NO_TASK;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping iteration for zone `%s'\n", GNUNET_h2s (&zone));
+ GNUNET_NAMESTORE_zone_iteration_stop (zi);
+
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+}
void zone_proc (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
const struct GNUNET_CRYPTO_RsaSignature *signature)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_h2s (&zone));
- endbadly_task = GNUNET_SCHEDULER_add_now (&end, NULL);
+
+ stopiteration_task = GNUNET_SCHEDULER_add_now (&stop_iteration, NULL);
+}
+
+void
+delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ char *afsdir;
+
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite",
+ "FILENAME", &afsdir))
+ {
+ if (GNUNET_OK == GNUNET_DISK_file_test (afsdir))
+ if (GNUNET_OK == GNUNET_DISK_file_test (afsdir))
+ if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir);
+ GNUNET_free (afsdir);
+ }
+
}
static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ delete_existing_db(cfg);
endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL);
privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey");