pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/multimedia/libbluray libblueray: Replace local pthread...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/524772935fe3
branches:  trunk
changeset: 423237:524772935fe3
user:      kamil <kamil%pkgsrc.org@localhost>
date:      Thu Feb 13 16:54:58 2020 +0000

description:
libblueray: Replace local pthread_equal(3) patch with a real fix

* mutex: Switch the POSIX backend to PTHREAD_MUTEX_RECURSIVE
  https://code.videolan.org/videolan/libbluray/merge_requests/17

diffstat:

 multimedia/libbluray/Makefile                       |   4 +-
 multimedia/libbluray/distinfo                       |   4 +-
 multimedia/libbluray/patches/patch-src_util_mutex.c |  88 ++++++++++++++++++--
 3 files changed, 82 insertions(+), 14 deletions(-)

diffs (132 lines):

diff -r fa87a1ebdb94 -r 524772935fe3 multimedia/libbluray/Makefile
--- a/multimedia/libbluray/Makefile     Thu Feb 13 15:28:58 2020 +0000
+++ b/multimedia/libbluray/Makefile     Thu Feb 13 16:54:58 2020 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.15 2020/02/12 15:33:37 ryoon Exp $
+# $NetBSD: Makefile,v 1.16 2020/02/13 16:54:58 kamil Exp $
 
 DISTNAME=      libbluray-1.1.2
-PKGREVISION=   1
+PKGREVISION=   2
 CATEGORIES=    multimedia
 MASTER_SITES=  http://download.videolan.org/pub/videolan/libbluray/${PKGVERSION_NOREV}/
 EXTRACT_SUFX=  .tar.bz2
diff -r fa87a1ebdb94 -r 524772935fe3 multimedia/libbluray/distinfo
--- a/multimedia/libbluray/distinfo     Thu Feb 13 15:28:58 2020 +0000
+++ b/multimedia/libbluray/distinfo     Thu Feb 13 16:54:58 2020 +0000
@@ -1,7 +1,7 @@
-$NetBSD: distinfo,v 1.15 2020/02/12 15:33:37 ryoon Exp $
+$NetBSD: distinfo,v 1.16 2020/02/13 16:54:58 kamil Exp $
 
 SHA1 (libbluray-1.1.2.tar.bz2) = 3885c0d0bd0f04a3a372ceec3a01a44a7624f272
 RMD160 (libbluray-1.1.2.tar.bz2) = bbfea1093f9fc5ea089cf5860e55e020b916a4b0
 SHA512 (libbluray-1.1.2.tar.bz2) = 5a82af6c1840a1dcb31d06d90203c68e2c4f0bbadc9212eb0bb2776d42b0ab3793a769ebe07b3051be151e8b15876874d5a0658292f72b7126dd915a1ada3fe7
 Size (libbluray-1.1.2.tar.bz2) = 745779 bytes
-SHA1 (patch-src_util_mutex.c) = 0c14aa467b0025f23c1cfda824e10cdd3fcdbd7b
+SHA1 (patch-src_util_mutex.c) = 38b7e8de22206bb7801af9be8bd799e79d75026f
diff -r fa87a1ebdb94 -r 524772935fe3 multimedia/libbluray/patches/patch-src_util_mutex.c
--- a/multimedia/libbluray/patches/patch-src_util_mutex.c       Thu Feb 13 15:28:58 2020 +0000
+++ b/multimedia/libbluray/patches/patch-src_util_mutex.c       Thu Feb 13 16:54:58 2020 +0000
@@ -1,24 +1,92 @@
-$NetBSD: patch-src_util_mutex.c,v 1.1 2020/02/12 15:33:37 ryoon Exp $
+$NetBSD: patch-src_util_mutex.c,v 1.2 2020/02/13 16:54:58 kamil Exp $
 
-* Fix segfault on NetBSD/amd64 9.99.46
+* mutex: Switch the POSIX backend to PTHREAD_MUTEX_RECURSIVE
+  https://code.videolan.org/videolan/libbluray/merge_requests/17
 
 --- src/util/mutex.c.orig      2019-06-07 18:00:28.000000000 +0000
 +++ src/util/mutex.c
-@@ -89,7 +89,7 @@ static int _mutex_init(MUTEX_IMPL *p)
+@@ -68,18 +68,16 @@ static int _mutex_destroy(MUTEX_IMPL *p)
+ 
+ #elif defined(HAVE_PTHREAD_H)
+ 
+-typedef struct {
+-    int             lock_count;
+-    pthread_t       owner;
+-    pthread_mutex_t mutex;
+-} MUTEX_IMPL;
++typedef pthread_mutex_t MUTEX_IMPL;
+ 
+ static int _mutex_init(MUTEX_IMPL *p)
+ {
+-    p->owner      = (pthread_t)-1;
+-    p->lock_count = 0;
++    pthread_mutexattr_t attr;
+ 
+-    if (pthread_mutex_init(&p->mutex, NULL)) {
++    pthread_mutexattr_init(&attr);
++    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
++
++    if (pthread_mutex_init(p, &attr)) {
+         BD_DEBUG(DBG_BLURAY|DBG_CRIT, "pthread_mutex_init() failed !\n");
+         return -1;
+     }
+@@ -89,40 +87,17 @@ static int _mutex_init(MUTEX_IMPL *p)
  
  static int _mutex_lock(MUTEX_IMPL *p)
  {
 -    if (pthread_equal(p->owner, pthread_self())) {
-+    if (p->owner == pthread_self()) {
-         /* recursive lock */
-         p->lock_count++;
-         return 0;
-@@ -108,7 +108,7 @@ static int _mutex_lock(MUTEX_IMPL *p)
+-        /* recursive lock */
+-        p->lock_count++;
+-        return 0;
+-    }
+-
+-    if (pthread_mutex_lock(&p->mutex)) {
++    if (pthread_mutex_lock(p)) {
+         BD_DEBUG(DBG_BLURAY|DBG_CRIT, "pthread_mutex_lock() failed !\n");
+         return -1;
+     }
+ 
+-    p->owner      = pthread_self();
+-    p->lock_count = 1;
+-
+     return 0;
+ }
  
  static int _mutex_unlock(MUTEX_IMPL *p)
  {
 -    if (!pthread_equal(p->owner, pthread_self())) {
-+    if (!(p->owner == pthread_self())) {
-         BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_unlock(): not owner !\n");
+-        BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_unlock(): not owner !\n");
+-        return -1;
+-    }
+-
+-    p->lock_count--;
+-    if (p->lock_count > 0) {
+-        return 0;
+-    }
+-
+-    /* unlock */
+-
+-    p->owner = (pthread_t)-1;
+-
+-    if (pthread_mutex_unlock(&p->mutex)) {
++    if (pthread_mutex_unlock(p)) {
+         BD_DEBUG(DBG_BLURAY|DBG_CRIT, "pthread_mutex_unlock() failed !\n");
          return -1;
      }
+@@ -132,10 +107,7 @@ static int _mutex_unlock(MUTEX_IMPL *p)
+ 
+ static int _mutex_destroy(MUTEX_IMPL *p)
+ {
+-    _mutex_lock(p);
+-    _mutex_unlock(p);
+-
+-    if (pthread_mutex_destroy(&p->mutex)) {
++    if (pthread_mutex_destroy(p)) {
+         BD_DEBUG(DBG_BLURAY|DBG_CRIT, "pthread_mutex_destroy() failed !\n");
+         return -1;
+     }
+@@ -193,4 +165,3 @@ int bd_mutex_destroy(BD_MUTEX *p)
+     X_FREE(p->impl);
+     return 0;
+ }
+-



Home | Main Index | Thread Index | Old Index