* 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.
This commit is contained in:
		| @@ -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> | 2012-01-20  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* fhandler.h (fhandler_registry::opendir): Declare. | 	* fhandler.h (fhandler_registry::opendir): Declare. | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /* cygheap.h: Cygwin heap manager. | /* cygheap.h: Cygwin heap manager. | ||||||
|  |  | ||||||
|    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |    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. | This file is part of Cygwin. | ||||||
|  |  | ||||||
| @@ -401,13 +401,9 @@ public: | |||||||
|   } |   } | ||||||
|   ~cygheap_fdget () |   ~cygheap_fdget () | ||||||
|   { |   { | ||||||
|     if (!fh) |     if (fh && fh->refcnt (-1) <= 0) | ||||||
|       /* nothing to do */; |  | ||||||
|     else if (fh->refcnt (-1) > 0) |  | ||||||
|       debug_only_printf ("fh %p, %s, refcnt %ld", fh, fh->get_name (), fh->refcnt ()); |  | ||||||
|     else |  | ||||||
|       { |       { | ||||||
| 	debug_only_printf ("deleting fh %p, %s, refcnt %ld", fh, fh->get_name (), fh->refcnt ()); | 	debug_only_printf ("deleting fh %p", fh); | ||||||
| 	delete fh; | 	delete fh; | ||||||
|       } |       } | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /* fhandler.cc.  See console.cc for fhandler_console functions. | /* fhandler.cc.  See console.cc for fhandler_console functions. | ||||||
|  |  | ||||||
|    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |    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. | This file is part of Cygwin. | ||||||
|  |  | ||||||
| @@ -50,6 +50,7 @@ fhandler_base::reset (const fhandler_base *from) | |||||||
|   raixget = 0; |   raixget = 0; | ||||||
|   raixput = 0; |   raixput = 0; | ||||||
|   rabuflen = 0; |   rabuflen = 0; | ||||||
|  |   _refcnt = 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
|   | |||||||
| @@ -178,7 +178,11 @@ class fhandler_base | |||||||
|   HANDLE read_state; |   HANDLE read_state; | ||||||
|  |  | ||||||
|  public: |  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; |   class fhandler_base *archetype; | ||||||
|   int usecount; |   int usecount; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /* fhandler_registry.cc: fhandler for /proc/registry virtual filesystem | /* fhandler_registry.cc: fhandler for /proc/registry virtual filesystem | ||||||
|  |  | ||||||
|    Copyright 2002, 2003, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |    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. | This file is part of Cygwin. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /* select.cc | /* select.cc | ||||||
|  |  | ||||||
|    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |    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. | 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); |   fd_set *e = allocfd_set (maxfds); | ||||||
|  |  | ||||||
|   int res = 0; |   int res = 0; | ||||||
|  |   sel.return_on_signal = &_my_tls == _main_tls; | ||||||
|   /* Degenerate case.  No fds to wait for.  Just wait. */ |   /* Degenerate case.  No fds to wait for.  Just wait. */ | ||||||
|   if (sel.start.next == NULL) |   if (sel.start.next == NULL) | ||||||
|     while (!res) |     while (!res) | ||||||
|       switch (cygwait (ms)) |       switch (cygwait (ms)) | ||||||
| 	{ | 	{ | ||||||
| 	case WAIT_OBJECT_0: | 	case WAIT_OBJECT_0: | ||||||
| 	  _my_tls.call_signal_handler (); |  | ||||||
| 	  if (&_my_tls != _main_tls) |  | ||||||
| 	    continue;		/* Emulate linux behavior */ |  | ||||||
| 	  select_printf ("signal received"); | 	  select_printf ("signal received"); | ||||||
|  | 	  _my_tls.call_signal_handler (); | ||||||
|  | 	  if (!sel.return_on_signal) | ||||||
|  | 	    continue;		/* Emulate linux behavior */ | ||||||
| 	  set_sig_errno (EINTR); | 	  set_sig_errno (EINTR); | ||||||
| 	  res = -1; | 	  res = -1; | ||||||
| 	  break; | 	  break; | ||||||
| @@ -328,8 +329,11 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, | |||||||
|       switch (wait_ret) |       switch (wait_ret) | ||||||
| 	{ | 	{ | ||||||
| 	case WAIT_OBJECT_0: | 	case WAIT_OBJECT_0: | ||||||
| 	  cleanup (); |  | ||||||
| 	  select_printf ("signal received"); | 	  select_printf ("signal received"); | ||||||
|  | 	  _my_tls.call_signal_handler (); | ||||||
|  | 	  if (!return_on_signal) | ||||||
|  | 	    continue;		/* Emulate linux behavior */ | ||||||
|  | 	  cleanup (); | ||||||
| 	  set_sig_errno (EINTR); | 	  set_sig_errno (EINTR); | ||||||
| 	  return -1; | 	  return -1; | ||||||
| 	case WAIT_OBJECT_0 + 1: | 	case WAIT_OBJECT_0 + 1: | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /* select.h | /* select.h | ||||||
|  |  | ||||||
|    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |    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. | This file is part of Cygwin. | ||||||
|  |  | ||||||
| @@ -70,6 +70,7 @@ class select_stuff | |||||||
| { | { | ||||||
| public: | public: | ||||||
|   ~select_stuff (); |   ~select_stuff (); | ||||||
|  |   bool return_on_signal; | ||||||
|   bool always_ready, windows_used; |   bool always_ready, windows_used; | ||||||
|   select_record start; |   select_record start; | ||||||
|  |  | ||||||
| @@ -84,7 +85,8 @@ public: | |||||||
|   int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms); |   int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms); | ||||||
|   void cleanup (); |   void cleanup (); | ||||||
|   void destroy (); |   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_pipe (0), | ||||||
| 		   device_specific_socket (0), | 		   device_specific_socket (0), | ||||||
| 		   device_specific_serial (0), | 		   device_specific_serial (0), | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user