gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3523 - in GNUnet/src: applications/fs/fsui applications/fs


From: grothoff
Subject: [GNUnet-SVN] r3523 - in GNUnet/src: applications/fs/fsui applications/fs/lib util/threads
Date: Fri, 20 Oct 2006 23:24:48 -0700 (PDT)

Author: grothoff
Date: 2006-10-20 23:24:43 -0700 (Fri, 20 Oct 2006)
New Revision: 3523

Modified:
   GNUnet/src/applications/fs/fsui/deserialize.c
   GNUnet/src/applications/fs/fsui/fsuitest.c
   GNUnet/src/applications/fs/fsui/searchtest.c
   GNUnet/src/applications/fs/fsui/serialize.c
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/util/threads/mutex.c
   GNUnet/src/util/threads/pthread.c
Log:
tuning shutdown sequences

Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c       2006-10-21 05:34:48 UTC 
(rev 3522)
+++ GNUnet/src/applications/fs/fsui/deserialize.c       2006-10-21 06:24:43 UTC 
(rev 3523)
@@ -354,7 +354,6 @@
       GE_BREAK(NULL, 0);       
       break;
     }
-    printf("Reading URI: %s\n", buf);
     list->uri
       = ECRS_stringToUri(NULL, buf);
     FREE(buf);
@@ -515,12 +514,11 @@
       READURI(l.uri);
     l.filename = read_string(fd, 1024*1024);
     if (l.filename == NULL) {
-      ECRS_freeUri(l.uri);
+      if (l.uri != NULL)
+       ECRS_freeUri(l.uri);
       GE_BREAK(NULL, 0);
       break;
     }
-    printf("Reading upload %s\n",
-          l.filename);
     list = MALLOC(sizeof(struct FSUI_UploadList));
     list->shared = shared;
     memcpy(list, &l, sizeof(struct FSUI_UploadList));
@@ -528,7 +526,8 @@
                             list,
                             fd,
                             shared)) {
-      ECRS_freeUri(l.uri);
+      if (l.uri != NULL)
+       ECRS_freeUri(l.uri);
       FREE(l.filename);
       FREE(list);
       GE_BREAK(NULL, 0);
@@ -558,7 +557,6 @@
       GE_BREAK(NULL, 0);
       break;
     }
-    printf("Reading shared\n");
     memset(&sshared,
           0,
           sizeof(FSUI_UploadShared));   
@@ -570,7 +568,6 @@
     if (big == 2) 
       READSTRING(sshared.extractor_config, 1024*1024);
     shared = MALLOC(sizeof(FSUI_UploadShared));
-    printf("Allocated shared %p\n", shared);
     memcpy(shared,
           &sshared,
           sizeof(FSUI_UploadShared));

Modified: GNUnet/src/applications/fs/fsui/fsuitest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest.c  2006-10-21 05:34:48 UTC (rev 
3522)
+++ GNUnet/src/applications/fs/fsui/fsuitest.c  2006-10-21 06:24:43 UTC (rev 
3523)
@@ -104,7 +104,7 @@
   return NULL;
 }
 
-#define START_DAEMON 0
+#define START_DAEMON 1
 
 int main(int argc, char * argv[]){
 #if START_DAEMON

Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c        2006-10-21 05:34:48 UTC 
(rev 3522)
+++ GNUnet/src/applications/fs/fsui/searchtest.c        2006-10-21 06:24:43 UTC 
(rev 3523)
@@ -50,6 +50,8 @@
 
 static volatile enum FSUI_EventType lastEvent;
 
+static struct FSUI_SearchList * search;
+
 static struct ECRS_URI * uri;
 
 static struct FSUI_Context * ctx;
@@ -60,6 +62,11 @@
  
   switch(event->type) {
   case FSUI_search_resumed:
+    search = event->data.SearchResumed.sc.pos;
+    break;
+  case FSUI_search_suspended:
+    search = NULL;
+    break;
   case FSUI_download_resumed:
   case FSUI_upload_resumed:
   case FSUI_unindex_resumed:
@@ -93,9 +100,12 @@
   return NULL;
 }
 
+#define START_DAEMON 0
 
 int main(int argc, char * argv[]){
+#if START_DAEMON
   pid_t daemon;
+#endif
   int ok;
   char * fn = NULL;
   char * keywords[] = {
@@ -111,7 +121,6 @@
   struct FSUI_UploadList * upload;
   struct FSUI_UnindexList * unindex;
   struct FSUI_DownloadList * download;
-  struct FSUI_SearchList * search;
   struct ECRS_URI * luri;
 
   ok = YES;
@@ -121,6 +130,7 @@
     GC_free(cfg);
     return -1;  
   }
+#if START_DAEMON
   daemon  = os_daemon_start(NULL,
                            cfg,
                            "peer.conf",
@@ -131,6 +141,7 @@
                                                    30 * cronSECONDS));
   PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
   /* ACTUAL TEST CODE */
+#endif
 
   ctx = FSUI_start(NULL,
                   cfg,
@@ -205,7 +216,7 @@
   while (uri == NULL) {
     prog++;
     CHECK(prog < 10000)
-    PTHREAD_SLEEP(500 * cronMILLIS);
+    PTHREAD_SLEEP(50 * cronMILLIS);
   }
   FSUI_abortSearch(ctx,
                   search);
@@ -259,8 +270,9 @@
   UNLINK(fn);
   FREE(fn);
 
- 
+#if START_DAEMON
   GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
+#endif
   GC_free(cfg);
   return (ok == YES) ? 0 : 1;
 }

Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2006-10-21 05:34:48 UTC (rev 
3522)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2006-10-21 06:24:43 UTC (rev 
3523)
@@ -178,7 +178,6 @@
     WRITEINT(fd, spos->sizeUnmatchedResultsReceived);
     tmp = ECRS_uriToString(spos->uri);
     GE_ASSERT(NULL, tmp != NULL);
-    printf("Writing URI: %s\n", tmp);
     WRITESTRING(fd, tmp);
     FREE(tmp);
     for (i=0;i<spos->sizeResultsReceived;i++)
@@ -231,7 +230,6 @@
 
   while (upos != NULL) {
     if (upos->parent == &ctx->activeUploads) {
-      printf("Writing shared!\n");
       shared = upos->shared;
       WRITEINT(fd, (shared->extractor_config != NULL) ? 2 : 3);
       WRITEINT(fd, shared->doIndex);
@@ -245,8 +243,6 @@
       WRITEINT(fd, 1);
       WRITEINT(fd, (upos->uri != NULL) ? 1 : 2);
     }
-    printf("Writing upload %s!\n",
-          upos->filename);
     WRITEINT(fd, upos->state);
     WRITELONG(fd, upos->completed);
     WRITELONG(fd, upos->total);

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2006-10-21 05:34:48 UTC (rev 
3522)
+++ GNUnet/src/applications/fs/lib/fslib.c      2006-10-21 06:24:43 UTC (rev 
3523)
@@ -136,7 +136,8 @@
             "FSLIB: error communicating with gnunetd; sleeping for %ums\n",
             delay);
 #endif
-      PTHREAD_SLEEP(delay);
+      if (ctx->abort == NO)
+       PTHREAD_SLEEP(delay);
       delay *= 2;
       if (delay > 5 * cronSECONDS)
        delay = 5 * cronSECONDS;
@@ -177,6 +178,7 @@
            ctx->handleCount == 0);
   ctx->abort = YES;
   connection_close_temporarily(ctx->sock);
+  PTHREAD_STOP_SLEEP(ctx->thread);
   PTHREAD_JOIN(ctx->thread,
               &unused);
   ctx->lock = NULL;
@@ -425,8 +427,9 @@
         &block[1],
         size);
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "Sending index request to gnunetd\n");
+  GE_LOG(ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "Sending index request to gnunetd\n");
 #endif
   if (OK != connection_write(sock,
                          &ri->header)) {
@@ -435,8 +438,9 @@
   }
   FREE(ri);
 #if DEBUG_FSLIB
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "Waiting for confirmation of index request by gnunetd\n");
+  GE_LOG(ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "Waiting for confirmation of index request by gnunetd\n");
 #endif
   if (OK != connection_read_result(sock,
                          &ret))

Modified: GNUnet/src/util/threads/mutex.c
===================================================================
--- GNUnet/src/util/threads/mutex.c     2006-10-21 05:34:48 UTC (rev 3522)
+++ GNUnet/src/util/threads/mutex.c     2006-10-21 06:24:43 UTC (rev 3523)
@@ -119,11 +119,25 @@
   FREE(mutex);
 }
 
-void MUTEX_LOCK(Mutex * mutex) {
+#define DEBUG_LOCK_DELAY 0
+
+void MUTEX_LOCK_(Mutex * mutex) {
   int ret;
+#if DEBUG_LOCK_DELAY
+  cron_t start;
+#endif
 
   GE_ASSERT(NULL, mutex != NULL);
+#if DEBUG_LOCK_DELAY
+  start = get_time();
+#endif
   ret = pthread_mutex_lock(&mutex->pt);
+#if DEBUG_LOCK_DELAY
+  start = get_time() - start;
+  if (start > 10)
+    printf("Locking took %llu ms!\n", 
+          start);
+#endif
   if (ret != 0) {
     if (ret == EINVAL)
       GE_LOG(NULL,

Modified: GNUnet/src/util/threads/pthread.c
===================================================================
--- GNUnet/src/util/threads/pthread.c   2006-10-21 05:34:48 UTC (rev 3522)
+++ GNUnet/src/util/threads/pthread.c   2006-10-21 06:24:43 UTC (rev 3523)
@@ -120,15 +120,34 @@
   return handle;
 }
 
+/**
+ * Should we debug the time a join takes? 
+ * Useful for detecting missing PTHREAD_STOP_SLEEPS
+ * and similar signaling operations.
+ */
+#define DEBUG_JOIN_DELAY NO
+
 void PTHREAD_JOIN(PThread * handle,
                  void ** ret) {
+#if DEBUG_JOIN_DELAY
+  cron_t start;
+#endif
   int k;
 
   GE_ASSERT(NULL, 
            handle != NULL);
   GE_ASSERT(NULL, 
-           NO == PTHREAD_TEST_SELF(handle));
+           NO == PTHREAD_TEST_SELF(handle)); 
+#if DEBUG_JOIN_DELAY
+  start = get_time();
+#endif
   k = pthread_join(handle->pt, ret);
+#if DEBUG_JOIN_DELAY
+  start = get_time() - start;
+  if (start > 10) 
+    printf("Join took %llu ms\n", 
+          start);
+#endif
   FREE(handle);
   switch (k) {
   case 0:
@@ -206,6 +225,7 @@
       GE_LOG_STRERROR(NULL,
                      GE_WARNING | GE_USER | GE_BULK,
                      "nanosleep");
+
 #elif WINDOWS
   SleepEx(delay, TRUE);
 #else





reply via email to

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