svn commit: r305185 - stable/10/sys/kern

Konstantin Belousov kib at FreeBSD.org
Thu Sep 1 07:21:43 UTC 2016


Author: kib
Date: Thu Sep  1 07:21:42 2016
New Revision: 305185
URL: https://svnweb.freebsd.org/changeset/base/305185

Log:
  MFC r304812:
  In both do_rw_wrlock() and do_rw_rdlock(), do not obliterate possible
  error from sleep.

Modified:
  stable/10/sys/kern/kern_umtx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_umtx.c
==============================================================================
--- stable/10/sys/kern/kern_umtx.c	Thu Sep  1 07:20:50 2016	(r305184)
+++ stable/10/sys/kern/kern_umtx.c	Thu Sep  1 07:21:42 2016	(r305185)
@@ -2831,7 +2831,7 @@ do_rw_rdlock(struct thread *td, struct u
 	uint32_t flags, wrflags;
 	int32_t state, oldstate;
 	int32_t blocked_readers;
-	int error, rv;
+	int error, error1, rv;
 
 	uq = td->td_umtxq;
 	error = fueword32(&rwlock->rw_flags, &flags);
@@ -2980,9 +2980,12 @@ sleep:
 				if (oldstate == state)
 					break;
 				state = oldstate;
-				error = umtxq_check_susp(td);
-				if (error != 0)
+				error1 = umtxq_check_susp(td);
+				if (error1 != 0) {
+					if (error == 0)
+						error = error1;
 					break;
+				}
 			}
 		}
 
@@ -3005,7 +3008,7 @@ do_rw_wrlock(struct thread *td, struct u
 	int32_t state, oldstate;
 	int32_t blocked_writers;
 	int32_t blocked_readers;
-	int error, rv;
+	int error, error1, rv;
 
 	uq = td->td_umtxq;
 	error = fueword32(&rwlock->rw_flags, &flags);
@@ -3151,14 +3154,17 @@ sleep:
 				if (oldstate == state)
 					break;
 				state = oldstate;
-				error = umtxq_check_susp(td);
+				error1 = umtxq_check_susp(td);
 				/*
 				 * We are leaving the URWLOCK_WRITE_WAITERS
 				 * behind, but this should not harm the
 				 * correctness.
 				 */
-				if (error != 0)
+				if (error1 != 0) {
+					if (error == 0)
+						error = error1;
 					break;
+				}
 			}
 			rv = fueword32(&rwlock->rw_blocked_readers,
 			    &blocked_readers);


More information about the svn-src-stable mailing list