[newlib-cygwin] Cygwin: posix timers: fix resource leak

Corinna Vinschen corinna@sourceware.org
Wed Mar 6 21:19:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=094a2a17ad1cd65909fa2eee648d049d8d69fc45

commit 094a2a17ad1cd65909fa2eee648d049d8d69fc45
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed Mar 6 22:17:32 2019 +0100

    Cygwin: posix timers: fix resource leak
    
    On setting the timer, the thread is accidentally only canceled when
    disarming the timer.  This leaks one thread per timer_settimer call.
    Move the thread cancellation where it belongs.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/posix_timer.cc |  2 +-
 winsup/cygwin/release/3.0.3  | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/posix_timer.cc b/winsup/cygwin/posix_timer.cc
index d9d4a9a..a140b00 100644
--- a/winsup/cygwin/posix_timer.cc
+++ b/winsup/cygwin/posix_timer.cc
@@ -287,9 +287,9 @@ timer_tracker::settime (int flags, const itimerspec *new_value,
       if (old_value)
 	gettime (old_value, false);
 
+      cancel ();
       if (!new_value->it_value.tv_sec && !new_value->it_value.tv_nsec)
 	{
-	  cancel ();
 	  memset (&time_spec, 0, sizeof time_spec);
 	  interval = 0;
 	  exp_ts = 0;
diff --git a/winsup/cygwin/release/3.0.3 b/winsup/cygwin/release/3.0.3
new file mode 100644
index 0000000..66ae639
--- /dev/null
+++ b/winsup/cygwin/release/3.0.3
@@ -0,0 +1,13 @@
+What's new:
+-----------
+
+
+What changed:
+-------------
+
+
+Bug Fixes
+---------
+
+- Fix a resource leak in posix timers.
+  Addresses: https://cygwin.com/ml/cygwin/2019-03/msg00120.html



More information about the Cygwin-cvs mailing list