struct GNUNET_NAMESTORE_Client * client;
+ GNUNET_HashCode zone;
+
uint64_t op_id;
uint32_t offset;
zir_msg.op_id = htonl(zi->op_id);
zir_msg.header.size = htons (sizeof (struct ZoneIterationResponseMessage));
-
GNUNET_SERVER_notification_context_unicast (snc, zi->client->client, (const struct GNUNET_MessageHeader *) &zir_msg, GNUNET_NO);
}
struct ZoneIterationStartMessage * zis_msg = (struct ZoneIterationStartMessage *) message;
struct GNUNET_NAMESTORE_Client *nc;
struct GNUNET_NAMESTORE_ZoneIteration *zi;
+ int res;
nc = client_lookup(client);
if (nc == NULL)
zi->op_id = ntohl (zis_msg->op_id);
zi->offset = 0;
zi->client = nc;
+ zi->zone = zis_msg->zone;
GNUNET_CONTAINER_DLL_insert (nc->op_head, nc->op_tail, zi);
- GSN_database->iterate_records (GSN_database->cls, &zis_msg->zone, NULL, zi->offset , &zone_iteration_proc, zi);
+ res = GSN_database->iterate_records (GSN_database->cls, &zis_msg->zone, NULL, zi->offset , &zone_iteration_proc, zi);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "iterate_records: %i\n", res);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
const struct GNUNET_MessageHeader * message)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ZONE_ITERATION_STOP");
+
+ struct GNUNET_NAMESTORE_Client *nc;
+ struct GNUNET_NAMESTORE_ZoneIteration *zi;
+ struct ZoneIterationStopMessage * zis_msg = (struct ZoneIterationStopMessage *) message;
+ uint32_t id;
+
+ nc = client_lookup(client);
+ if (nc == NULL)
+ {
+ GNUNET_break_op (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+
+ id = ntohl (zis_msg->op_id);
+ for (zi = nc->op_head; zi != NULL; zi = zi->next)
+ {
+ if (zi->op_id == id)
+ break;
+ }
+ if (zi == NULL)
+ {
+ GNUNET_break_op (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+
+ GNUNET_CONTAINER_DLL_remove(nc->op_head, nc->op_tail, zi);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopped zone iteration for zone `%s'\n", GNUNET_h2s (&zi->zone));
+ GNUNET_free (zi);
+
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
static void handle_iteration_next (void *cls,
{&handle_iteration_start, NULL,
GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, sizeof (struct ZoneIterationStartMessage)},
{&handle_iteration_stop, NULL,
- GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, 0},
+ GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, sizeof (struct ZoneIterationStopMessage)},
{&handle_iteration_next, NULL,
GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, 0},
{NULL, NULL, 0, 0}
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);
}
static void