DEVEL15-demand-attach-init-fsstate-rwlock-20070712
authorDerrick Brashear <shadow@dementia.org>
Thu, 12 Jul 2007 09:29:34 +0000 (09:29 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 12 Jul 2007 09:29:34 +0000 (09:29 +0000)
the rwlock needs to be initd before use

(cherry picked from commit 1e86d1f3cc8166b8303e208e3a12922d44061317)

src/viced/viced.c
src/viced/viced.h

index 353fcc4..4a75a67 100644 (file)
@@ -2185,6 +2185,7 @@ main(int argc, char *argv[])
 
 #ifdef AFS_PTHREAD_ENV
     ViceLog(5, ("Starting pthreads\n"));
+    FS_STATE_INIT;
     assert(pthread_attr_init(&tattr) == 0);
     assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
 
index e6e08a1..e632bc8 100644 (file)
@@ -246,6 +246,7 @@ struct fs_state {
 extern struct fs_state fs_state;
 
 /* this lock is defined to be directly above FS_LOCK in the locking hierarchy */
+#define FS_STATE_INIT    assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0)
 #define FS_STATE_RDLOCK  assert(pthread_rwlock_rdlock(&fs_state.state_lock) == 0)
 #define FS_STATE_WRLOCK  assert(pthread_rwlock_wrlock(&fs_state.state_lock) == 0)
 #define FS_STATE_UNLOCK  assert(pthread_rwlock_unlock(&fs_state.state_lock) == 0)