diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 36d554544..f40e4239c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-12  Christopher Faylor  <me.cygwin2012@cgf.cx>
+
+	* DevNotes: Add entry cgf-000006.
+	* thread.cc (pthread::pop_cleanup_handler): Set cancel state to
+	disabled to avoid recursively waiting for cancel.
+
 2012-05-12  Christopher Faylor  <me.cygwin2012@cgf.cx>
 
 	* DevNotes: Add entry cgf-000005.
diff --git a/winsup/cygwin/DevNotes b/winsup/cygwin/DevNotes
index 5ad1ab8a2..aba32f1a2 100644
--- a/winsup/cygwin/DevNotes
+++ b/winsup/cygwin/DevNotes
@@ -1,3 +1,16 @@
+2012-05-12  cgf-000006
+
+<1.7.16>
+- Fix hang when calling pthread_testcancel in a canceled thread.
+  Fixes some of: http://cygwin.com/ml/cygwin/2012-05/msg00186.html
+</1.7.16>
+
+This should fix the first part of the reported problem in the above
+message.  The cancel seemed to actually be working but, the fprintf
+eventually ended up calling pthread_testcancel.  Since we'd gotten here
+via a cancel, it tried to recursively call the cancel handler causing a
+recursive loop.
+
 2012-05-12  cgf-000005
 
 <1.7.16>
diff --git a/winsup/cygwin/release/1.7.16 b/winsup/cygwin/release/1.7.16
index fe4fc6cbe..c73519da3 100644
--- a/winsup/cygwin/release/1.7.16
+++ b/winsup/cygwin/release/1.7.16
@@ -9,3 +9,6 @@ Bug fixes:
 - Fix pipe creation problem which manifested as a problem creating a
 fifo.  Fixes: http://cygwin.com/ml/cygwin/2012-05/msg00253.html
 
+- Fix hang when calling pthread_testcancel in a canceled thread.
+  Fixes some of: http://cygwin.com/ml/cygwin/2012-05/msg00186.html
+
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index af0d6afc7..1bea526bf 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -1057,6 +1057,9 @@ pthread::pop_cleanup_handler (int const execute)
 
   mutex.lock ();
 
+  /* We will no honor cancels since the thread is exiting.  */
+  cancelstate = PTHREAD_CANCEL_DISABLE;
+
   if (cleanup_stack != NULL)
     {
       __pthread_cleanup_handler *handler = cleanup_stack;