Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Sep 2016 07:21:42 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r305185 - stable/10/sys/kern
Message-ID:  <201609010721.u817LgiI044093@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609010721.u817LgiI044093>