[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20002 - gnunet/src/namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20002 - gnunet/src/namestore |
Date: |
Fri, 24 Feb 2012 11:57:17 +0100 |
Author: wachs
Date: 2012-02-24 11:57:17 +0100 (Fri, 24 Feb 2012)
New Revision: 20002
Modified:
gnunet/src/namestore/gnunet-service-namestore.c
gnunet/src/namestore/namestore_api.c
Log:
- changes
Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c 2012-02-24 10:51:42 UTC
(rev 20001)
+++ gnunet/src/namestore/gnunet-service-namestore.c 2012-02-24 10:57:17 UTC
(rev 20002)
@@ -30,7 +30,39 @@
#include "gnunet_namestore_plugin.h"
#include "namestore.h"
+
+
/**
+ * A namestore operation.
+ */
+struct GNUNET_NAMESTORE_Operation
+{
+ struct GNUNET_NAMESTORE_Operation *next;
+ struct GNUNET_NAMESTORE_Operation *prev;
+
+ uint64_t op_id;
+
+ char *data; /*stub data pointer*/
+};
+
+
+/**
+ * A namestore client
+ */
+struct GNUNET_NAMESTORE_Client
+{
+ struct GNUNET_NAMESTORE_Client *next;
+ struct GNUNET_NAMESTORE_Client *prev;
+
+ struct GNUNET_SERVER_Client * client;
+
+ struct GNUNET_NAMESTORE_Operation *op_head;
+ struct GNUNET_NAMESTORE_Operation *op_tail;
+};
+
+
+
+/**
* Configuration handle.
*/
const struct GNUNET_CONFIGURATION_Handle *GSN_cfg;
@@ -39,6 +71,10 @@
static char *db_lib_name;
+static struct GNUNET_NAMESTORE_Client *client_head;
+static struct GNUNET_NAMESTORE_Client *client_tail;
+
+
/**
* Task run during shutdown.
*
@@ -50,6 +86,21 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n");
+ struct GNUNET_NAMESTORE_Operation * no;
+ struct GNUNET_NAMESTORE_Client * nc;
+
+ for (nc = client_head; nc != NULL; nc = nc->next)
+ {
+ for (no = nc->op_head; no != NULL; no = no->next)
+ {
+ GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no);
+ GNUNET_free (no);
+ }
+ }
+
+ GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc);
+ GNUNET_free (nc);
+
GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, GSN_database));
GNUNET_free (db_lib_name);
}
@@ -64,8 +115,29 @@
static void
client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
{
- if (NULL != client)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected \n", client);
+ struct GNUNET_NAMESTORE_Operation * no;
+ struct GNUNET_NAMESTORE_Client * nc;
+ if (NULL == client)
+ return;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected \n", client);
+
+ for (nc = client_head; nc != NULL; nc = nc->next)
+ {
+ if (client == nc->client)
+ break;
+ }
+ if (NULL == client)
+ return;
+
+ for (no = nc->op_head; no != NULL; no = no->next)
+ {
+ GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no);
+ GNUNET_free (no);
+ }
+
+ GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc);
+ GNUNET_free (nc);
}
static void handle_start (void *cls,
@@ -73,6 +145,12 @@
const struct GNUNET_MessageHeader * message)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n");
+
+ struct GNUNET_NAMESTORE_Client * nc = GNUNET_malloc (sizeof (struct
GNUNET_NAMESTORE_Client));
+ nc->client = client;
+
+ GNUNET_CONTAINER_DLL_insert(client_head, client_tail, nc);
+
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c 2012-02-24 10:51:42 UTC (rev
20001)
+++ gnunet/src/namestore/namestore_api.c 2012-02-24 10:57:17 UTC (rev
20002)
@@ -45,6 +45,12 @@
uint64_t op_id;
+ GNUNET_NAMESTORE_ContinuationWithStatus cont;
+ void *cont_cls;
+
+ GNUNET_NAMESTORE_RecordProcessor proc;
+ void *proc_cls;
+
char *data; /*stub data pointer*/
};
@@ -452,7 +458,12 @@
struct GNUNET_NAMESTORE_QueueEntry *qe;
struct PendingMessage *pe;
size_t msg_size = 0;
+
+ GNUNET_assert (NULL != h);
+
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+ qe->cont = cont;
+ qe->cont_cls = cont_cls;
enqeue_namestore_operation(h, qe);
/* set msg_size*/
@@ -520,7 +531,25 @@
GNUNET_NAMESTORE_ContinuationWithStatus cont,
void *cont_cls)
{
- return NULL;
+ struct GNUNET_NAMESTORE_QueueEntry *qe;
+ struct PendingMessage *pe;
+ size_t msg_size = 0;
+
+ GNUNET_assert (NULL != h);
+
+ qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+ qe->cont = cont;
+ qe->cont_cls = cont_cls;
+ enqeue_namestore_operation(h, qe);
+
+ /* set msg_size*/
+ pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
+
+ /* create msg here */
+
+ GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, pe);
+ do_transmit(h);
+ return qe;
}
@@ -548,7 +577,24 @@
void *cont_cls)
{
struct GNUNET_NAMESTORE_QueueEntry *qe;
+ struct PendingMessage *pe;
+ size_t msg_size = 0;
+
+ GNUNET_assert (NULL != h);
+
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+ qe->cont = cont;
+ qe->cont_cls = cont_cls;
+ enqeue_namestore_operation(h, qe);
+
+ /* set msg_size*/
+ pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
+
+ /* create msg here */
+
+ GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, pe);
+ do_transmit(h);
+
#if 0
struct GNUNET_NAMESTORE_SimpleRecord *iter;
for (iter=h->records_head; iter != NULL; iter=iter->next)
@@ -589,8 +635,34 @@
GNUNET_NAMESTORE_RecordProcessor proc, void
*proc_cls)
{
struct GNUNET_NAMESTORE_QueueEntry *qe;
+ struct PendingMessage *pe;
+ size_t msg_size = 0;
+
+ GNUNET_assert (NULL != h);
+
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+ qe->proc = proc;
+ qe->proc_cls = proc_cls;
+ enqeue_namestore_operation(h, qe);
+ /* set msg_size*/
+ msg_size = sizeof (struct LookupNameMessage);
+ pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
+
+ /* create msg here */
+
+ struct LookupNameMessage * msg;
+ pe->size = msg_size;
+ pe->is_init = GNUNET_NO;
+ msg = (struct LookupNameMessage *) &pe[1];
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
+ msg->header.size = htons (msg_size);
+
+ /* create msg done */
+
+ GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, pe);
+ do_transmit(h);
+
#if 0
struct GNUNET_NAMESTORE_SimpleRecord *iter;
for (iter=h->records_head; iter != NULL; iter=iter->next)
@@ -606,21 +678,8 @@
GNUNET_TIME_absolute_get_forever(), 0, NULL, 0, NULL); /*TERMINATE*/
#endif
- GNUNET_assert (NULL != h);
- struct PendingMessage * p;
- struct LookupNameMessage * msg;
- size_t msg_len = sizeof (struct LookupNameMessage);
- p = GNUNET_malloc (sizeof (struct PendingMessage) + msg_len);
- p->size = msg_len;
- p->is_init = GNUNET_NO;
- msg = (struct LookupNameMessage *) &p[1];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
- msg->header.size = htons (msg_len);
- GNUNET_CONTAINER_DLL_insert (h->pending_head, h->pending_tail, p);
- do_transmit (h);
-
return qe;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20002 - gnunet/src/namestore,
gnunet <=