svn commit: r299521 - stable/10/lib/libthr/thread

Konstantin Belousov kib at FreeBSD.org
Thu May 12 06:53:24 UTC 2016


Author: kib
Date: Thu May 12 06:53:22 2016
New Revision: 299521
URL: https://svnweb.freebsd.org/changeset/base/299521

Log:
  MFC r299114:
  Do not leak THR_FLAGS_SUSPENDED from the previous suspend/resume
  cycle.
  
  PR:	209233

Modified:
  stable/10/lib/libthr/thread/thr_resume_np.c
  stable/10/lib/libthr/thread/thr_sig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libthr/thread/thr_resume_np.c
==============================================================================
--- stable/10/lib/libthr/thread/thr_resume_np.c	Thu May 12 06:39:13 2016	(r299520)
+++ stable/10/lib/libthr/thread/thr_resume_np.c	Thu May 12 06:53:22 2016	(r299521)
@@ -90,7 +90,7 @@ static void
 resume_common(struct pthread *thread)
 {
 	/* Clear the suspend flag: */
-	thread->flags &= ~THR_FLAGS_NEED_SUSPEND;
+	thread->flags &= ~(THR_FLAGS_NEED_SUSPEND | THR_FLAGS_SUSPENDED);
 	thread->cycle++;
 	_thr_umtx_wake(&thread->cycle, 1, 0);
 }

Modified: stable/10/lib/libthr/thread/thr_sig.c
==============================================================================
--- stable/10/lib/libthr/thread/thr_sig.c	Thu May 12 06:39:13 2016	(r299520)
+++ stable/10/lib/libthr/thread/thr_sig.c	Thu May 12 06:53:22 2016	(r299521)
@@ -373,8 +373,7 @@ check_suspend(struct pthread *curthread)
 	 */
 	curthread->critical_count++;
 	THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
-	while ((curthread->flags & (THR_FLAGS_NEED_SUSPEND |
-		THR_FLAGS_SUSPENDED)) == THR_FLAGS_NEED_SUSPEND) {
+	while ((curthread->flags & THR_FLAGS_NEED_SUSPEND) != 0) {
 		curthread->cycle++;
 		cycle = curthread->cycle;
 
@@ -391,7 +390,6 @@ check_suspend(struct pthread *curthread)
 		THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
 		_thr_umtx_wait_uint(&curthread->cycle, cycle, NULL, 0);
 		THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
-		curthread->flags &= ~THR_FLAGS_SUSPENDED;
 	}
 	THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
 	curthread->critical_count--;


More information about the svn-src-all mailing list