[libbluray-devel] maintain mutex lock order between register and player state
joakim
git at videolan.org
Tue Feb 5 12:56:08 CET 2013
libbluray | branch: master | joakim <joakim at mefx.(none)> | Mon Feb 4 23:05:28 2013 +0100| [b0a7e5a941c1bfaaab1154735a36b4b520ec300c] | committer: hpi1
maintain mutex lock order between register and player state
bd_psr_write can trigger lock of bd mutex in a callback, which
can already be held by other thread waiting for psr mutex.
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=b0a7e5a941c1bfaaab1154735a36b4b520ec300c
---
src/libbluray/bdj/native/org_videolan_Libbluray.c | 6 +++++-
src/libbluray/bluray.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.c b/src/libbluray/bdj/native/org_videolan_Libbluray.c
index e4fbc9e..7802f97 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.c
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.c
@@ -26,6 +26,7 @@
#include "libbluray/bluray.h"
#include "libbluray/bluray_internal.h"
+#include "util/mutex.h"
#include "util/strutl.h"
#include "util/macro.h"
#include "util/logging.h"
@@ -325,7 +326,10 @@ JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readGPRN(JNIEnv * env,
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writePSRN(JNIEnv * env,
jclass cls, jlong np, jint num, jint value) {
BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
- return bd_psr_write(bdj->reg, num, value);
+ bd_mutex_lock((BD_MUTEX*)bdj->bd);
+ int res = bd_psr_write(bdj->reg, num, value);
+ bd_mutex_unlock((BD_MUTEX*)bdj->bd);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readPSRN(JNIEnv * env,
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 2452312..1e52181 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -109,7 +109,7 @@ typedef struct {
struct bluray {
- BD_MUTEX mutex; /* protect API function access to internal data */
+ BD_MUTEX mutex; /* protect API function access to internal data (must be first element in struct) */
/* current disc */
char *device_path;
More information about the libbluray-devel
mailing list