[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2635 - GNUnet/src/applications/fs/fsui GNUnet/src/applicat
From: |
grothoff |
Subject: |
[GNUnet-SVN] r2635 - GNUnet/src/applications/fs/fsui GNUnet/src/applications/fs/tools GNUnet/src/util gnunet-gtk/src/common gnunet-gtk/src/include |
Date: |
Sat, 22 Apr 2006 13:10:10 -0700 (PDT) |
Author: grothoff
Date: 2006-04-22 13:10:05 -0700 (Sat, 22 Apr 2006)
New Revision: 2635
Modified:
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/tools/gnunet-search.c
GNUnet/src/util/cron.c
gnunet-gtk/src/common/helper.c
gnunet-gtk/src/include/gnunetgtk_common.h
Log:
fixing Mantis 1026
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2006-04-22 19:25:41 UTC (rev
2634)
+++ GNUnet/src/applications/fs/fsui/download.c 2006-04-22 20:10:05 UTC (rev
2635)
@@ -549,6 +549,8 @@
FSUI_DownloadList * prev;
unsigned int backup;
+ LOG(LOG_DEBUG,
+ "FSUI_stopDownload called.\n");
GNUNET_ASSERT(filename != NULL);
MUTEX_LOCK(&ctx->lock);
dl = ctx->activeDownloads.child;
@@ -565,12 +567,16 @@
freeDownloadList(dl);
ctx->threadPoolSize = backup;
MUTEX_UNLOCK(&ctx->lock);
+ LOG(LOG_DEBUG,
+ "FSUI_stopDownload completed successfully.\n");
return OK;
}
prev = dl;
dl = dl->next;
}
MUTEX_UNLOCK(&ctx->lock);
+ LOG(LOG_DEBUG,
+ "FSUI_stopDownload failed to locate download.\n");
return SYSERR;
}
Modified: GNUnet/src/applications/fs/tools/gnunet-search.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-search.c 2006-04-22 19:25:41 UTC
(rev 2634)
+++ GNUnet/src/applications/fs/tools/gnunet-search.c 2006-04-22 20:10:05 UTC
(rev 2635)
@@ -365,7 +365,9 @@
NULL);
startCron();
ret = runSearch();
+ printf("4)\n");
stopCron();
+ printf("5)\n");
delCronJob((CronJob)&run_shutdown,
0,
NULL);
Modified: GNUnet/src/util/cron.c
===================================================================
--- GNUnet/src/util/cron.c 2006-04-22 19:25:41 UTC (rev 2634)
+++ GNUnet/src/util/cron.c 2006-04-22 20:10:05 UTC (rev 2635)
@@ -216,7 +216,12 @@
what the cron jobs may be doing */
}
-static void noJob(void * unused) {}
+static void noJob(void * unused) {
+#if DEBUG_CRON
+ LOG(LOG_CRON,
+ "In noJob.\n");
+#endif
+}
/**
* Stop the cron service.
@@ -224,10 +229,6 @@
void stopCron() {
void * unused;
-#if DEBUG_CRON
- LOG(LOG_INFO,
- _("Cron stopped\n"));
-#endif
cron_shutdown = YES;
addCronJob(&noJob, 0, 0, NULL);
SEMAPHORE_DOWN(cron_signal);
@@ -235,6 +236,10 @@
cron_signal = NULL;
cronPID = 0;
PTHREAD_JOIN(&cron_handle, &unused);
+#if DEBUG_CRON
+ LOG(LOG_INFO,
+ _("Cron stopped\n"));
+#endif
}
static int inBlock = 0;
@@ -626,7 +631,8 @@
#endif
if (next > MAXSLEEP)
next = MAXSLEEP;
- gnunet_util_sleep(next);
+ if (cron_shutdown == NO)
+ gnunet_util_sleep(next);
#if DEBUG_CRON
LOG(LOG_CRON,
"woke up at %llu - %lld CS late\n",
@@ -635,6 +641,11 @@
#endif
}
SEMAPHORE_UP(cron_signal);
+#if DEBUG_CRON
+ LOG(LOG_CRON,
+ "Cron thread exits.\n");
+ printCronTab();
+#endif
return NULL;
}
Modified: gnunet-gtk/src/common/helper.c
===================================================================
--- gnunet-gtk/src/common/helper.c 2006-04-22 19:25:41 UTC (rev 2634)
+++ gnunet-gtk/src/common/helper.c 2006-04-22 20:10:05 UTC (rev 2635)
@@ -78,6 +78,7 @@
SaveCall * call = data;
int i;
+ printf("Running save call!\n");
/* clearly, we are no longer pending,
so remove from psc */
if (call->sem != NULL) {
@@ -98,6 +99,7 @@
call->func(call->args);
if (call->sem != NULL)
SEMAPHORE_UP(call->sem);
+ printf("Running save call done.\n");
return FALSE;
}
@@ -132,32 +134,6 @@
}
}
-int gtkRunSomeSaveCalls() {
- int i;
-
- if (! PTHREAD_SELF_TEST(&mainThread))
- return NO;
- MUTEX_LOCK(&sclock);
- if (pscCount == 0) {
- MUTEX_UNLOCK(&sclock);
- return NO;
- }
- i = randomi(pscCount);
- if (TRUE == g_idle_remove_by_data(psc[i]))
- saveCallWrapper(psc[i]);
- MUTEX_UNLOCK(&sclock);
- gnunet_util_sleep(50 * cronMILLIS);
- /* sleep here is somewhat important, first of
- all, after completion we need to give the
- semaphore-mechanism time to remove the save-call
- from the list to avoid running it twice;
- also, this function might be called in a tight
- loop (see search.c), so we should give the
- other threads some time to run. */
-
- return YES;
-}
-
/**
* Callback for handling "delete_event": close the window
*/
@@ -483,6 +459,7 @@
ret = cls->realMain(cls->arg);
SEMAPHORE_UP(cls->sig);
+ PTHREAD_KILL(&mainThread, SIGALRM);
return ret;
}
@@ -491,6 +468,7 @@
PTHREAD_T doneThread;
void * unused;
struct rwsc_closure cls;
+ int i;
cls.sig = SEMAPHORE_NEW(0);
cls.realMain = cb;
@@ -500,8 +478,22 @@
&cls,
64*1024))
DIE_STRERROR("pthread_create");
- while (OK != SEMAPHORE_DOWN_NONBLOCKING(cls.sig))
- gtkRunSomeSaveCalls();
+ if ( (! PTHREAD_SELF_TEST(&mainThread)) ||
+ (pscCount == 0) ) {
+ /* another thread will run the save calls */
+ SEMAPHORE_DOWN(cls.sig);
+ } else {
+ while (OK != SEMAPHORE_DOWN_NONBLOCKING(cls.sig)) {
+ MUTEX_LOCK(&sclock);
+ if (pscCount > 0) {
+ i = randomi(pscCount);
+ if (TRUE == g_idle_remove_by_data(psc[i]))
+ saveCallWrapper(psc[i]);
+ }
+ MUTEX_UNLOCK(&sclock);
+ gnunet_util_sleep(50 * cronMILLIS);
+ }
+ }
PTHREAD_JOIN(&doneThread,
&unused);
SEMAPHORE_FREE(cls.sig);
Modified: gnunet-gtk/src/include/gnunetgtk_common.h
===================================================================
--- gnunet-gtk/src/include/gnunetgtk_common.h 2006-04-22 19:25:41 UTC (rev
2634)
+++ gnunet-gtk/src/include/gnunetgtk_common.h 2006-04-22 20:10:05 UTC (rev
2635)
@@ -75,13 +75,6 @@
void * arg);
/**
- * Use this method when blocking the
- * GTK event thread and save calls should
- * still continue.
- */
-int gtkRunSomeSaveCalls();
-
-/**
* Run the given "cb" function and save calls
* in parallel (used within the event loop to
* keep save calls going while something else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2635 - GNUnet/src/applications/fs/fsui GNUnet/src/applications/fs/tools GNUnet/src/util gnunet-gtk/src/common gnunet-gtk/src/include,
grothoff <=