gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6570 - GNUnet/src/applications/fs/ecrs


From: gnunet
Subject: [GNUnet-SVN] r6570 - GNUnet/src/applications/fs/ecrs
Date: Tue, 18 Mar 2008 02:54:39 -0600 (MDT)

Author: holindho
Date: 2008-03-18 02:54:39 -0600 (Tue, 18 Mar 2008)
New Revision: 6570

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
Log:
fix threading issues


Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2008-03-17 00:55:22 UTC (rev 
6569)
+++ GNUnet/src/applications/fs/ecrs/download.c  2008-03-18 08:54:39 UTC (rev 
6570)
@@ -888,6 +888,7 @@
   char *rdir;
   int len;
 
+  GNUNET_mutex_lock(rm->lock);
   if ((rm->head == NULL) &&
       ((rm->completed == rm->total) ||
        ((rm->total != rm->length) && (rm->completed >= rm->length))))
@@ -933,6 +934,7 @@
                  __FUNCTION__, filename,
                  ret == GNUNET_OK ? "SUCCESS" : "INCOMPLETE");
 #endif
+  GNUNET_mutex_unlock(rm->lock);
   free_request_manager (rm, GNUNET_YES);
   return ret;
 }
@@ -984,9 +986,15 @@
   if (rm == NULL)
     return (length == 0) ? GNUNET_OK : GNUNET_SYSERR;
   while ((GNUNET_OK == tt (ttClosure)) &&
-         (GNUNET_YES != GNUNET_shutdown_test ()) &&
-         (rm->abortFlag == GNUNET_NO) && (rm->head != NULL))
+         (GNUNET_YES != GNUNET_shutdown_test ())) {
+    GNUNET_mutex_lock(rm->lock);
+    if ((rm->abortFlag != GNUNET_NO) || (rm->head == NULL)) {
+      GNUNET_mutex_unlock(rm->lock);
+      break;
+    }
+    GNUNET_mutex_unlock(rm->lock);
     GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
+  }
   return GNUNET_ECRS_file_download_partial_stop (rm);
 }
 





reply via email to

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