gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5168 - in GNUnet/src/util: network threads


From: gnunet
Subject: [GNUnet-SVN] r5168 - in GNUnet/src/util: network threads
Date: Thu, 28 Jun 2007 19:32:38 -0600 (MDT)

Author: grothoff
Date: 2007-06-28 19:32:38 -0600 (Thu, 28 Jun 2007)
New Revision: 5168

Modified:
   GNUnet/src/util/network/dns.c
   GNUnet/src/util/threads/mutex.c
Log:
nolog

Modified: GNUnet/src/util/network/dns.c
===================================================================
--- GNUnet/src/util/network/dns.c       2007-06-29 01:32:28 UTC (rev 5167)
+++ GNUnet/src/util/network/dns.c       2007-06-29 01:32:38 UTC (rev 5168)
@@ -264,7 +264,7 @@
   lock = MUTEX_CREATE(YES);
 #if HAVE_ADNS
   adns_init(&a_state,
-           adns_if_none, // adns_if_noerrprint,
+           adns_if_noerrprint,
            NULL);
 #endif
 }

Modified: GNUnet/src/util/threads/mutex.c
===================================================================
--- GNUnet/src/util/threads/mutex.c     2007-06-29 01:32:28 UTC (rev 5167)
+++ GNUnet/src/util/threads/mutex.c     2007-06-29 01:32:38 UTC (rev 5168)
@@ -67,6 +67,7 @@
   const char * locked_file;
   cron_t       locked_time;
   unsigned int locked_line;
+  unsigned int locked_depth;
 } Mutex;
 
 Mutex * MUTEX_CREATE(int isRecursive) {
@@ -108,6 +109,9 @@
 #endif
   }
   mut = MALLOC(sizeof(Mutex));
+  memset(mut,
+        0,
+        sizeof(Mutex));
   GE_ASSERT(NULL,
            0 == pthread_mutex_init(&mut->pt,
                                    &attr));
@@ -155,9 +159,11 @@
              "pthread_mutex_lock");
     GE_ASSERT(NULL, 0);
   }
-  mutex->locked_file = file;
-  mutex->locked_line = line;
-  mutex->locked_time = end;
+  if (mutex->locked_depth++ == 0) {
+    mutex->locked_file = file;
+    mutex->locked_line = line;
+    mutex->locked_time = end;
+  } 
 }
 
 void MUTEX_UNLOCK(Mutex * mutex) {
@@ -165,15 +171,20 @@
   cron_t now;
 
   GE_ASSERT(NULL, mutex != NULL);
-  now = get_time();
-  if ( (now - mutex->locked_time > REALTIME_LIMIT) &&
-       (REALTIME_LIMIT != 0) )
-    GE_LOG(NULL,
-          GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
-          _("Lock aquired for too long (%llu ms) at %s:%u\n"),
-          now - mutex->locked_time,
-          mutex->locked_file,
-          mutex->locked_line);
+  if (0 == --mutex->locked_depth) {
+    now = get_time();
+    if ( (now - mutex->locked_time > REALTIME_LIMIT) &&
+        (REALTIME_LIMIT != 0) )
+      GE_LOG(NULL,
+            GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
+            _("Lock aquired for too long (%llu ms) at %s:%u\n"),
+            now - mutex->locked_time,
+            mutex->locked_file,
+            mutex->locked_line);
+    mutex->locked_file = NULL;
+    mutex->locked_line = 0;
+    mutex->locked_time = 0;
+  }
   ret = pthread_mutex_unlock(&mutex->pt);
   if (ret != 0) {
     if (ret == EINVAL)





reply via email to

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