[vlc-commits] Initialize the configuration R/W lock statically

Rémi Denis-Courmont git at videolan.org
Thu Aug 18 17:37:15 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug 18 18:19:24 2011 +0300| [236a276618fc83c18e100ace359c51ba4734010c] | committer: Rémi Denis-Courmont

Initialize the configuration R/W lock statically

The lock is static anyway (and so is the data).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=236a276618fc83c18e100ace359c51ba4734010c
---

 src/config/core.c  |    2 +-
 src/modules/bank.c |    2 --
 src/win32/thread.c |    3 +++
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/config/core.c b/src/config/core.c
index d575061..66ba61e 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -36,7 +36,7 @@
 #include "configuration.h"
 #include "modules/modules.h"
 
-vlc_rwlock_t config_lock;
+vlc_rwlock_t config_lock = VLC_STATIC_RWLOCK;
 
 static inline char *strdupnull (const char *src)
 {
diff --git a/src/modules/bank.c b/src/modules/bank.c
index fa5b7f1..ece0f8d 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -92,7 +92,6 @@ void module_InitBank (void)
         if (likely(module != NULL))
             module_StoreBank (module);
 
-        vlc_rwlock_init (&config_lock);
         config_SortConfig ();
     }
     modules.usage++;
@@ -126,7 +125,6 @@ void module_EndBank (bool b_plugins)
     if (--modules.usage == 0)
     {
         config_UnsortConfig ();
-        vlc_rwlock_destroy (&config_lock);
         head = modules.head;
         modules.head = NULL;
     }
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 99e54b5..965db99 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -39,6 +39,7 @@
 #ifdef UNDER_CE
 # include <mmsystem.h>
 #endif
+#include "config/configuration.h"
 
 static vlc_threadvar_t thread_key;
 
@@ -79,9 +80,11 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
                 return FALSE;
             InitializeCriticalSection (&super_mutex);
             vlc_threadvar_create (&thread_key, NULL);
+            vlc_rwlock_init (&config_lock);
             break;
 
         case DLL_PROCESS_DETACH:
+            vlc_rwlock_destroy (&config_lock);
             vlc_threadvar_delete (&thread_key);
             DeleteCriticalSection (&super_mutex);
             CloseHandle (super_cond);



More information about the vlc-commits mailing list