use debug mutex types for now
authorSteve McIntyre <steve@einval.com>
Sun, 23 Jan 2011 17:19:42 +0000 (17:19 +0000)
committerSteve McIntyre <steve@einval.com>
Sun, 23 Jan 2011 17:19:42 +0000 (17:19 +0000)
C/fuse-music.c

index 3112362..081493b 100644 (file)
@@ -302,6 +302,10 @@ static int add_todo_entry_file(const char *flac_path, work_list_t **enqueued)
 {
     work_list_t *entry;
     char dbgname[64];
+    pthread_mutexattr_t attr;
+    pthread_mutexattr_init(&attr);
+    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
+
     sprintf(dbgname, "%s(%ld):", __func__, (unsigned long)pthread_self());
     
     /* Check if we already have an entry for this file; if so, just
@@ -330,7 +334,7 @@ static int add_todo_entry_file(const char *flac_path, work_list_t **enqueued)
     entry->next = NULL;
     entry->error = 0;
     strcpy(entry->flac_path, flac_path);
-    pthread_mutex_init(&entry->lock, NULL);    
+    pthread_mutex_init(&entry->lock, &attr);
     pthread_cond_init(&entry->cv, NULL);    
     entry->state = ENCODE_WAITING;
     entry->refcount = 1;
@@ -905,7 +909,9 @@ int main(int argc, char *argv[])
     int error = 0;
     struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
     int *threadcount;
-    
+    pthread_mutexattr_t attr;
+    pthread_mutexattr_init(&attr);
+    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);    
     umask(0);
 
     logfile = stderr;
@@ -993,9 +999,8 @@ int main(int argc, char *argv[])
 
     strcpy(dir_state.last, "");
     dir_state.num = 0;
-    pthread_mutex_init(&dir_state.lock, NULL);
-
-    pthread_mutex_init(&global_work.lock, NULL);
+    pthread_mutex_init(&dir_state.lock, &attr);
+    pthread_mutex_init(&global_work.lock, &attr);
     pthread_cond_init(&global_work.cv, NULL);
     bg_thread = malloc(mo.num_threads * sizeof(pthread_t));
     if (!bg_thread)