Create mutexes with type PTHREAD_MUTEX_RECURSIVE to stop ghostscript from

aborting.

ok aja@
This commit is contained in:
kili 2012-09-09 08:57:36 +00:00
parent 7e0ef2d12d
commit 764b569ac0
2 changed files with 33 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.93 2012/08/22 06:24:17 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.94 2012/09/09 08:57:36 kili Exp $
COMMENT= GNU PostScript interpreter
@ -6,6 +6,7 @@ VERSION= 9.06
DISTNAME= ghostscript-${VERSION}
CATEGORIES= print lang
SHARED_LIBS= gs 15.0
REVISION= 0
MASTER_SITES= http://downloads.ghostscript.com/public/

View File

@ -0,0 +1,31 @@
$OpenBSD: patch-base_gp_psync_c,v 1.1 2012/09/09 08:57:36 kili Exp $
Use PTHREAD_MUTEX_RECURSIVE, which works fine even with the (broken)
wrappers still around which try to simulate PTHREAD_MUTEX_RECURSIVE
for mutexes created with default attributes.
--- base/gp_psync.c.orig Wed Aug 8 10:01:36 2012
+++ base/gp_psync.c Sun Sep 9 09:03:31 2012
@@ -147,13 +147,21 @@ int
gp_monitor_open(gp_monitor * mona)
{
pthread_mutex_t *mon;
+ pthread_mutexattr_t mattr;
int scode;
if (!mona)
return -1; /* monitors are not movable */
mon = &((gp_pthread_recursive_t *)mona)->mutex;
((gp_pthread_recursive_t *)mona)->self_id = 0; /* Not valid unless mutex is locked */
- scode = pthread_mutex_init(mon, NULL);
+ scode = pthread_mutexattr_init(&mattr);
+ if (scode != 0)
+ return SEM_ERROR_CODE(scode);
+ scode = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
+ if (scode != 0)
+ return SEM_ERROR_CODE(scode);
+ scode = pthread_mutex_init(mon, &mattr);
+ pthread_mutexattr_destroy(&mattr);
return SEM_ERROR_CODE(scode);
}