summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog13
-rw-r--r--winsup/cygwin/cygheap.h10
-rw-r--r--winsup/cygwin/fhandler.cc3
-rw-r--r--winsup/cygwin/fhandler.h6
-rw-r--r--winsup/cygwin/fhandler_registry.cc2
-rw-r--r--winsup/cygwin/select.cc12
-rw-r--r--winsup/cygwin/select.h6
7 files changed, 36 insertions, 16 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 1ceba8b7b..5b2ed1468 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,16 @@
+2012-01-22 Christopher Faylor <me.cygwin2012@cgf.cx>
+
+ * cygheap.h (cygheap_fdget::~cygheap_fdget): Simplify now that refcnt
+ reports reference count changes itself.
+ * fhandler.cc (fhandler_base::reset): Set _refcnt to 0.
+ * fhandler.h (fhandler_base::refcnt): Report refcnt when debugging.
+
+ * select.cc (cygwin_select): Set return_on_signal to indicate when
+ select should be interrupted.
+ (select_stuff::wait): Keep looping unless return_on_signal is set.
+ * select.h (select_stuff::return_on_signal): New variable.
+ (select_stuff::select_stuff): Zero return_on_signal.
+
2012-01-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (fhandler_registry::opendir): Declare.
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 5d7b93dcc..3bba1ae9f 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -1,7 +1,7 @@
/* cygheap.h: Cygwin heap manager.
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
- 2010, 2011 Red Hat, Inc.
+ 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@@ -401,13 +401,9 @@ public:
}
~cygheap_fdget ()
{
- if (!fh)
- /* nothing to do */;
- else if (fh->refcnt (-1) > 0)
- debug_only_printf ("fh %p, %s, refcnt %ld", fh, fh->get_name (), fh->refcnt ());
- else
+ if (fh && fh->refcnt (-1) <= 0)
{
- debug_only_printf ("deleting fh %p, %s, refcnt %ld", fh, fh->get_name (), fh->refcnt ());
+ debug_only_printf ("deleting fh %p", fh);
delete fh;
}
}
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 5fade14e5..9c229933e 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1,7 +1,7 @@
/* fhandler.cc. See console.cc for fhandler_console functions.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@@ -50,6 +50,7 @@ fhandler_base::reset (const fhandler_base *from)
raixget = 0;
raixput = 0;
rabuflen = 0;
+ _refcnt = 0;
}
int
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index e3a71368d..7608664f9 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -178,7 +178,11 @@ class fhandler_base
HANDLE read_state;
public:
- long refcnt(long i = 0) {return _refcnt += i;}
+ long refcnt(long i = 0)
+ {
+ debug_only_printf ("%p, %s, i %d, refcnt %ld", this, get_name (), i, _refcnt + i);
+ return _refcnt += i;
+ }
class fhandler_base *archetype;
int usecount;
diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc
index 5f6246439..f252a4435 100644
--- a/winsup/cygwin/fhandler_registry.cc
+++ b/winsup/cygwin/fhandler_registry.cc
@@ -1,7 +1,7 @@
/* fhandler_registry.cc: fhandler for /proc/registry virtual filesystem
Copyright 2002, 2003, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
- 2010, 2011 Red Hat, Inc.
+ 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 52e2eabd5..ff63b1e5e 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -1,7 +1,7 @@
/* select.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@@ -130,16 +130,17 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
fd_set *e = allocfd_set (maxfds);
int res = 0;
+ sel.return_on_signal = &_my_tls == _main_tls;
/* Degenerate case. No fds to wait for. Just wait. */
if (sel.start.next == NULL)
while (!res)
switch (cygwait (ms))
{
case WAIT_OBJECT_0:
+ select_printf ("signal received");
_my_tls.call_signal_handler ();
- if (&_my_tls != _main_tls)
+ if (!sel.return_on_signal)
continue; /* Emulate linux behavior */
- select_printf ("signal received");
set_sig_errno (EINTR);
res = -1;
break;
@@ -328,8 +329,11 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
switch (wait_ret)
{
case WAIT_OBJECT_0:
- cleanup ();
select_printf ("signal received");
+ _my_tls.call_signal_handler ();
+ if (!return_on_signal)
+ continue; /* Emulate linux behavior */
+ cleanup ();
set_sig_errno (EINTR);
return -1;
case WAIT_OBJECT_0 + 1:
diff --git a/winsup/cygwin/select.h b/winsup/cygwin/select.h
index 45081b1fb..57cd59673 100644
--- a/winsup/cygwin/select.h
+++ b/winsup/cygwin/select.h
@@ -1,7 +1,7 @@
/* select.h
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin.
@@ -70,6 +70,7 @@ class select_stuff
{
public:
~select_stuff ();
+ bool return_on_signal;
bool always_ready, windows_used;
select_record start;
@@ -84,7 +85,8 @@ public:
int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms);
void cleanup ();
void destroy ();
- select_stuff (): always_ready (0), windows_used (0), start (0),
+ select_stuff (): return_on_signal (false), always_ready (false),
+ windows_used (false), start (0),
device_specific_pipe (0),
device_specific_socket (0),
device_specific_serial (0),