svn commit: r211859 - head/lib/libthr/thread

Pawel Jakub Dawidek pjd at FreeBSD.org
Fri Aug 27 13:53:20 UTC 2010


On Fri, Aug 27, 2010 at 03:23:07AM +0000, David Xu wrote:
[...]

Hi David.

While you at libthr... I found implementation of
_pthread_mutex_isowned_np(), which makes me wonder:

int
_pthread_mutex_isowned_np(pthread_mutex_t *mutex)
{
	struct pthread *curthread = _get_curthread();
	int ret;

	if (__predict_false(*mutex == NULL)) {
		ret = init_static(curthread, mutex);
		if (__predict_false(ret))
			return (ret);
	}
	return ((*mutex)->m_owner == curthread);
}

When init_static() fails, the caller will interpret the answer as 'true',
which seems wrong. What does this if statement do exactly? It
initializes mutex if it isn't? If so, can't we simply assert that it has
to be initialized?

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20100827/10e8f206/attachment.pgp


More information about the svn-src-all mailing list