static void
do_transmit (struct GNUNET_NAMESTORE_Handle *nsh);
+
+/**
+ * Type of a function to call when we receive a message
+ * from the service.
+ *
+ * @param cls the 'struct GNUNET_NAMESTORE_SchedulingHandle'
+ * @param msg message received, NULL on timeout or fatal error
+ */
+static void
+process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
+{
+ struct GNUNET_NAMESTORE_Handle *nsh = cls;
+ uint16_t size;
+ uint16_t type;
+
+ if (NULL == msg)
+ {
+ force_reconnect (nsh);
+ return;
+ }
+
+ size = ntohs (msg->size);
+ type = ntohs (msg->type);
+
+ switch (type) {
+ case GNUNET_MESSAGE_TYPE_TEST:
+ /* handle message here */
+ break;
+ default:
+ break;
+ }
+
+ GNUNET_CLIENT_receive (nsh->client, &process_namestore_message, nsh,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+
+ if (GNUNET_YES == nsh->reconnect)
+ force_reconnect (nsh);
+}
+
/**
* We can now transmit a message to NAMESTORE. Do it.
*
size -= p->size;
GNUNET_CONTAINER_DLL_remove (nsh->pending_head, nsh->pending_tail, p);
if (GNUNET_YES == p->is_init)
- GNUNET_CLIENT_receive (nsh->client,/* &process_namestore_message*/ NULL, nsh,
+ GNUNET_CLIENT_receive (nsh->client, &process_namestore_message, nsh,
GNUNET_TIME_UNIT_FOREVER_REL);
GNUNET_free (p);
}
nsh->reconnect = GNUNET_NO;
GNUNET_CLIENT_disconnect (nsh->client, GNUNET_NO);
nsh->client = NULL;
- nsh->reconnect_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
+ nsh->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &reconnect_task,
nsh);
}
nsh = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
nsh->cfg = cfg;
- nsh->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, nsh);
+ nsh->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, nsh);
return nsh;
}
* @param handle handle of the NAMESTORE connection to stop
*/
void
-GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *handle, int drop)
+GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *nsh, int drop)
{
- GNUNET_free(handle);
+ struct PendingMessage *p;
+
+ while (NULL != (p = nsh->pending_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (nsh->pending_head, nsh->pending_tail, p);
+ GNUNET_free (p);
+ }
+ if (NULL != nsh->client)
+ {
+ GNUNET_CLIENT_disconnect (nsh->client, GNUNET_NO);
+ nsh->client = NULL;
+ }
+ if (GNUNET_SCHEDULER_NO_TASK != nsh->reconnect_task)
+ {
+ GNUNET_SCHEDULER_cancel (nsh->reconnect_task);
+ nsh->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ GNUNET_free(nsh);
+ nsh = NULL;
}
/**
* @param h handle to the namestore
* @param zone_key public key of the zone
* @param loc location in the B-tree
- * @param ploc parent's location in the B-tree (must have depth = loc.depth - 1), NULL for root
- * @param top_sig signature at the top, NULL if 'loc.depth > 0'
+ * @param ploc parent's location in the B-tree (must have depth = loc.depth - 1)
* @param num_entries number of entries at this node in the B-tree
* @param entries the 'num_entries' entries to store (hashes over the
* records)
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
const struct GNUNET_NAMESTORE_SignatureLocation *loc,
const struct GNUNET_NAMESTORE_SignatureLocation *ploc,
- const struct GNUNET_CRYPTO_RsaSignature *sig,
unsigned int num_entries,
const GNUNET_HashCode *entries,
GNUNET_NAMESTORE_ContinuationWithStatus cont,