gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r7175 - in GNUnet/src: applications/fs/ecrs applications/fs


From: gnunet
Subject: [GNUnet-SVN] r7175 - in GNUnet/src: applications/fs/ecrs applications/fs/lib include
Date: Fri, 13 Jun 2008 02:20:08 -0600 (MDT)

Author: grothoff
Date: 2008-06-13 02:20:08 -0600 (Fri, 13 Jun 2008)
New Revision: 7175

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/include/gnunet_fs_lib.h
Log:
fixing recently introduced segv

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2008-06-13 07:42:18 UTC (rev 
7174)
+++ GNUnet/src/applications/fs/ecrs/download.c  2008-06-13 08:20:08 UTC (rev 
7175)
@@ -218,6 +218,8 @@
     rm->abortFlag = GNUNET_YES;
   if (rm->my_sctx == GNUNET_YES)
     GNUNET_FS_destroy_search_context (rm->sctx);
+  else
+    GNUNET_FS_suspend_search_context (rm->sctx);
   while (rm->head != NULL)
     {
       pos = rm->head;
@@ -226,6 +228,8 @@
       rm->head = pos->next;
       GNUNET_free (pos);
     }
+  if (rm->my_sctx != GNUNET_YES)
+    GNUNET_FS_resume_search_context (rm->sctx);
   rm->tail = NULL;
   if (rm->handle >= 0)
     CLOSE (rm->handle);

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2008-06-13 07:42:18 UTC (rev 
7174)
+++ GNUnet/src/applications/fs/lib/fslib.c      2008-06-13 08:20:08 UTC (rev 
7175)
@@ -103,6 +103,13 @@
    */
   int abort;
 
+  /**
+   * Counter for how many times this context has
+   * been suspended.  Results will not be passed
+   * on until the counter is zero.
+   */
+  unsigned int block_results;
+
 #if DEBUG_FSLIB
   unsigned int total_received;
 
@@ -199,6 +206,12 @@
           memcpy (&value[1], &rep[1], size);
           matched = 0;
           GNUNET_mutex_lock (ctx->lock);
+         while (ctx->block_results > 0)
+           {
+             GNUNET_mutex_unlock (ctx->lock);
+             GNUNET_thread_sleep(100 * GNUNET_CRON_MILLISECONDS);
+             GNUNET_mutex_lock (ctx->lock);
+           }
           prev = NULL;
           pos = ctx->handles;
           while (pos != NULL)
@@ -299,6 +312,24 @@
   return ret;
 }
 
+
+/**
+ * Resume the search context (start sending results again).
+ */
+void GNUNET_FS_resume_search_context (struct GNUNET_FS_SearchContext *ctx)
+{
+  ctx->block_results--;
+  GNUNET_thread_stop_sleep(ctx->thread);
+}
+
+void GNUNET_FS_suspend_search_context (struct GNUNET_FS_SearchContext *ctx)
+{
+  GNUNET_mutex_lock(ctx->lock);
+  ctx->block_results++;
+  GNUNET_mutex_unlock(ctx->lock);
+}
+
+
 void
 GNUNET_FS_destroy_search_context (struct GNUNET_FS_SearchContext *ctx)
 {

Modified: GNUnet/src/include/gnunet_fs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fs_lib.h  2008-06-13 07:42:18 UTC (rev 7174)
+++ GNUnet/src/include/gnunet_fs_lib.h  2008-06-13 08:20:08 UTC (rev 7175)
@@ -53,6 +53,18 @@
                                                                  
GNUNET_GC_Configuration
                                                                  *cfg);
 
+/**
+ * Pause the search context briefly (stop sending
+ * results).  This will NOT cause gnunetd to pause 
+ * searching for data.
+ */
+void GNUNET_FS_suspend_search_context (struct GNUNET_FS_SearchContext *ctx);
+
+/**
+ * Resume the search context (start sending results again).
+ */
+void GNUNET_FS_resume_search_context (struct GNUNET_FS_SearchContext *ctx);
+
 void GNUNET_FS_destroy_search_context (struct GNUNET_FS_SearchContext *ctx);
 
 /**





reply via email to

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