Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 97

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

autofs-5.0.1 - fix wait for master source mutex

From: Ian Kent <ikent@redhat.com>

A previous change that was meant to handle the case where the master map
source mutex read lock count was exceeded was incorrectly done for the
write lock case instead of the read lock case.
---

 lib/master.c |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)


--- autofs-5.0.1.orig/lib/master.c
+++ autofs-5.0.1/lib/master.c
@@ -547,38 +547,38 @@ void send_map_update_request(struct auto
 
 void master_source_writelock(struct master_mapent *entry)
 {
-	int retries = 5; /* 1 second maximum */
 	int status;
 
-	while (retries--) {
-		status = pthread_rwlock_wrlock(&entry->source_lock);
-		if (status != EAGAIN)
-			break;
-		else {
-                	struct timespec t = { 0, 200000000 };
-	                struct timespec r;
-                	while (nanosleep(&t, &r) == -1 && errno == EINTR)
-                        	memcpy(&t, &r, sizeof(struct timespec));
-		}
-	}
-
+	status = pthread_rwlock_wrlock(&entry->source_lock);
 	if (status) {
 		logmsg("master_mapent source write lock failed");
 		fatal(status);
 	}
-
 	return;
 }
 
 void master_source_readlock(struct master_mapent *entry)
 {
+	int retries = 5; /* 1 second maximum */
 	int status;
 
-	status = pthread_rwlock_rdlock(&entry->source_lock);
+	while (retries--) {
+		status = pthread_rwlock_tryrdlock(&entry->source_lock);
+		if (status != EAGAIN && status != EBUSY)
+			break;
+		else {
+                	struct timespec t = { 0, 200000000 };
+	                struct timespec r;
+                	while (nanosleep(&t, &r) == -1 && errno == EINTR)
+                        	memcpy(&t, &r, sizeof(struct timespec));
+		}
+	}
+
 	if (status) {
 		logmsg("master_mapent source read lock failed");
 		fatal(status);
 	}
+
 	return;
 }