protect against cancellation in dlopen

i'm not sure that it's "correct" for dlopen to block cancellation
when calling constructors for libraries it loads, but it sure seems
like the right thing. in any case, dlopen itself needs cancellation
blocked.
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index eda0046..6ff8850 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -610,9 +610,11 @@
 {
 	struct dso *volatile p, *orig_tail = tail, *next;
 	size_t i;
+	int cs;
 
 	if (!file) return head;
 
+	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
 	pthread_rwlock_wrlock(&lock);
 
 	if (setjmp(rtld_fail)) {
@@ -628,8 +630,8 @@
 		}
 		tail = orig_tail;
 		tail->next = 0;
-		pthread_rwlock_unlock(&lock);
-		return 0;
+		p = 0;
+		goto end;
 	}
 
 	p = load_library(file);
@@ -658,6 +660,7 @@
 	do_init_fini(tail);
 end:
 	pthread_rwlock_unlock(&lock);
+	pthread_setcancelstate(cs, 0);
 	return p;
 }