gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11395 - gnunet/src/datastore


From: gnunet
Subject: [GNUnet-SVN] r11395 - gnunet/src/datastore
Date: Mon, 17 May 2010 11:13:22 +0200

Author: grothoff
Date: 2010-05-17 11:13:22 +0200 (Mon, 17 May 2010)
New Revision: 11395

Modified:
   gnunet/src/datastore/datastore_api.c
Log:
fix

Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c        2010-05-17 08:54:38 UTC (rev 
11394)
+++ gnunet/src/datastore/datastore_api.c        2010-05-17 09:13:22 UTC (rev 
11395)
@@ -333,8 +333,15 @@
       c++;
       pos = pos->next;
     }
-  if (c >= max_queue_size)
-    return NULL;
+  ret = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_QueueEntry) + msize);
+  ret->h = h;
+  ret->response_proc = response_proc;
+  ret->client_ctx = client_ctx;
+  ret->timeout = GNUNET_TIME_relative_to_absolute (timeout);
+  ret->priority = queue_priority;
+  ret->max_queue = max_queue_size;
+  ret->message_size = msize;
+  ret->was_transmitted = GNUNET_NO;
   if (pos == NULL)
     {
       /* append at the tail */
@@ -349,25 +356,22 @@
           (h->queue_head->was_transmitted) )
        pos = h->queue_head;
     }
-  ret = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_QueueEntry) + msize);
+  c++;
   GNUNET_CONTAINER_DLL_insert_after (h->queue_head,
                                     h->queue_tail,
                                     pos,
                                     ret);
-  ret->h = h;
-  ret->response_proc = response_proc;
-  ret->client_ctx = client_ctx;
+  h->queue_size++;
+  if (c > max_queue_size)
+    {
+      response_proc (ret, NULL);
+      GNUNET_free (ret);
+      return NULL;
+    }
   ret->task = GNUNET_SCHEDULER_add_delayed (h->sched,
                                            timeout,
                                            &timeout_queue_entry,
                                            ret);
-  ret->timeout = GNUNET_TIME_relative_to_absolute (timeout);
-  ret->priority = queue_priority;
-  ret->max_queue = max_queue_size;
-  ret->message_size = msize;
-  ret->was_transmitted = GNUNET_NO;
-  h->queue_size++;
-  c++;
   pos = ret->next;
   while (pos != NULL) 
     {
@@ -1106,7 +1110,7 @@
                         queue_priority, max_queue_size, timeout,
                         &process_result_message, rcont);
   if (qe == NULL)
-    return NULL;
+    return NULL;    
   m = (struct GNUNET_MessageHeader*) &qe[1];
   m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM);
   m->size = htons(sizeof (struct GNUNET_MessageHeader));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]