pthread_rwlock behaviour

Ian Campbell <[email protected]>
Newsgroups gmane.comp.lib.phil
Message-ID <[email protected]>
Hello,
	I have been using the NPTL with my code for a while and came across
the following situation:

#include <stdio.h>
#include <pthread.h>

int main() {

	pthread_rwlock_t lock;

	pthread_rwlock_init(&lock,NULL);

	fprintf(stderr,"doing write lock\n");

	pthread_rwlock_wrlock(&lock);

	fprintf(stderr,"doing unlock twice\n");

	pthread_rwlock_unlock(&lock);
	pthread_rwlock_unlock(&lock);

	fprintf(stderr,"doing write lock again\n");

	pthread_rwlock_wrlock(&lock);

	fprintf(stderr,"finished\n");

}

Now this causes the code to stop on the last call to
pthread_rwlock_wrlock(). I was wondering whether this was intentional or
not? The old pthreads implementation used to be quite happy with the double
pthread_rwlock_unlock() call.

Regards,

Ian Campbell
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.