-dequeue download on error, another attempt to fix #2403
authorChristian Grothoff <christian@grothoff.org>
Sat, 9 Jun 2012 19:30:21 +0000 (19:30 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 9 Jun 2012 19:30:21 +0000 (19:30 +0000)
src/fs/fs_api.c
src/fs/fs_download.c

index ec959433a1225d71c5c262902b105a11f7f73bbf..4265d8d51b61c4f6579f998b405c120f0d38dd03 100644 (file)
@@ -51,7 +51,7 @@ start_job (struct GNUNET_FS_QueueEntry *qe)
 {
   GNUNET_assert (NULL == qe->client);
   qe->client = GNUNET_CLIENT_connect ("fs", qe->h->cfg);
 {
   GNUNET_assert (NULL == qe->client);
   qe->client = GNUNET_CLIENT_connect ("fs", qe->h->cfg);
-  if (qe->client == NULL)
+  if (NULL == qe->client)
   {
     GNUNET_break (0);
     return;
   {
     GNUNET_break (0);
     return;
@@ -114,7 +114,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   while (NULL != (qe = next))
   {
     next = qe->next;
   while (NULL != (qe = next))
   {
     next = qe->next;
-    if (h->running_head == NULL)
+    if (NULL == h->running_head)
     {
       start_job (qe);
       continue;
     {
       start_job (qe);
       continue;
@@ -126,7 +126,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       continue;
     }
   }
       continue;
     }
   }
-  if (h->pending_head == NULL)
+  if (NULL == h->pending_head)
     return;                     /* no need to stop anything */
   /* then, check if we should stop some jobs */
   next = h->running_head;
     return;                     /* no need to stop anything */
   /* then, check if we should stop some jobs */
   next = h->running_head;
@@ -221,7 +221,7 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh)
   struct GNUNET_FS_Handle *h;
 
   h = qh->h;
   struct GNUNET_FS_Handle *h;
 
   h = qh->h;
-  if (qh->client != NULL)
+  if (NULL != qh->client)
     stop_job (qh);
   GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, qh);
   GNUNET_free (qh);
     stop_job (qh);
   GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, qh);
   GNUNET_free (qh);
index c7e3a60238c3ebb12c4746480c4a91d35febbee8..61178766b3f805f74d30e5a4f6b8606aad1fbef8 100644 (file)
@@ -1178,6 +1178,11 @@ signal_error:
   dc->top_request = NULL;
   GNUNET_CONTAINER_multihashmap_destroy (dc->active);
   dc->active = NULL;
   dc->top_request = NULL;
   GNUNET_CONTAINER_multihashmap_destroy (dc->active);
   dc->active = NULL;
+  if (NULL != dc->job_queue)
+  {
+    GNUNET_FS_dequeue_ (dc->job_queue);
+    dc->job_queue = NULL;
+  }
   dc->pending_head = NULL;
   dc->pending_tail = NULL;
   GNUNET_FS_download_sync_ (dc);
   dc->pending_head = NULL;
   dc->pending_tail = NULL;
   GNUNET_FS_download_sync_ (dc);