From owner-freebsd-gnome@FreeBSD.ORG Wed Sep 8 01:27:16 2004 Return-Path: Delivered-To: freebsd-gnome@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 785E516A4CF for ; Wed, 8 Sep 2004 01:27:16 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 098CD43D5D for ; Wed, 8 Sep 2004 01:27:16 +0000 (GMT) (envelope-from caelian@gmail.com) Received: by mproxy.gmail.com with SMTP id 76so231488rnl for ; Tue, 07 Sep 2004 18:27:15 -0700 (PDT) Received: by 10.38.82.8 with SMTP id f8mr2400010rnb; Tue, 07 Sep 2004 18:27:14 -0700 (PDT) Received: by 10.38.79.10 with HTTP; Tue, 7 Sep 2004 18:27:14 -0700 (PDT) Message-ID: Date: Tue, 7 Sep 2004 18:27:14 -0700 From: Pascal Hofstee To: freebsd-hackers@freebsd.org In-Reply-To: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_171_15976079.1094606834411" References: cc: gnome@FreeBSD.org Subject: Re: pthread_mutex_trylock and glib-2 X-BeenThere: freebsd-gnome@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Pascal Hofstee List-Id: GNOME for FreeBSD -- porting and maintaining List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2004 01:27:16 -0000 ------=_Part_171_15976079.1094606834411 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, 6 Sep 2004 15:12:08 -0700, Pascal Hofstee wrote: > After a few hours of digging through both the glib-2 as well as the > beep-media-player sources i finally managed to figure out why > beep-media-player apprently crashes on startup when using libpthread, > but not when using libc_r. > > i filed a bugreport against this problem on bugzilla.gnome.org ... in > the hope to get some feedback from glib-developers ... > > http://bugzilla.gnome.org/show_bug.cgi?id=152009 > > The problem is with the actual return value of pthread_mutex_trylock > returning EDEADLK instead of EBUSY. > > from what i have been able to glance from this previous discussion > regarding this particular subject > (http://lists.freebsd.org/pipermail/freebsd-threads/2004-January/001539.html) > > pthread_mutex_trylock should behave identical to pthread_mutex_lock > except return immediately in case of a blocking mutex, which would > suggest EDEADLK as a possible return value. > > This Seems to be the current implementation of both libpthread as well > as libthr ... with libc_r being the sole exception. > > The pthread_mutex_trylock manpage however does not reflect this actual > implementation and only mentions EBUSY and EINVAL. > > I was wondering assuming the implementation is actually correct if > this could be rectified in the pthread_mutex_trylock manpage ... and > if my assumption is wrong if the implementation could be changed to > reflect the manpage. > > In the former case i will have to bug the glib-devs to change the > implementation of their pthread_mutex_trylock wrapper ... to also > check for EDEADLK. I am hereby including an updated /usr/ports/devel/glib20/files/patch-gthread_gthread-posix.c that includes the additional check for EDEADLK besides EBUSY in glib's g_mutex_trylock_posix_impl function. With this fix applied to my installation of glib beep-media-player now works as expected with libpthread, and this is very likely to resolve similar behaviour with other ports that try to use glib's threading functions. I CC-ed glib20 port-maintainer (gnome@FreeBSD.org) in the hope this (or appropriate alternative) fix makes it in time for 5.3-RELEASE. -- Pascal Hofstee ------=_Part_171_15976079.1094606834411 Content-Type: application/octet-stream; name="patch-gthread_gthread-posix.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="patch-gthread_gthread-posix.c" LS0tIGd0aHJlYWQvZ3RocmVhZC1wb3NpeC5jLm9yaWcJVHVlIFNlcCAgNyAxNzo1Nzo1MyAyMDA0 CisrKyBndGhyZWFkL2d0aHJlYWQtcG9zaXguYwlUdWUgU2VwICA3IDE3OjU4OjMwIDIwMDQKQEAg LTExNiw2ICsxMTYsNyBAQAogI2VuZGlmIC8qIFBPU0lYX01JTl9QUklPUklUWSAmJiBQT1NJWF9N QVhfUFJJT1JJVFkgKi8KIAogc3RhdGljIGd1bG9uZyBnX3RocmVhZF9taW5fc3RhY2tfc2l6ZSA9 IDA7CitzdGF0aWMgZ3Vsb25nIG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Nr c2l6ZSAoJmF0dHIsIHN0YWNrX3NpemUpKTsKICAgICB9CisgIGVsc2UKKyAgICB7CisgICAgICBz dGFja19zaXplID0gTUFYIChnX3RocmVhZF9taW5fc3RhY2tfc2l6ZSwgZ190aHJlYWRfZGVmYXVs dF9zdGFja19zaXplKTsKKyAgICB9CisgIHBvc2l4X2NoZWNrX2NtZCAocHRocmVhZF9hdHRyX3Nl dHN0YWNrc2l6ZSAoJmF0dHIsIHN0YWNrX3NpemUpKTsKICNlbmRpZiAvKiBIQVZFX1BUSFJFQURf QVRUUl9TRVRTVEFDS1NJWkUgKi8KIAogI2lmZGVmIFBUSFJFQURfU0NPUEVfU1lTVEVNCg== ------=_Part_171_15976079.1094606834411--