diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 15 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/select.cc | 61 | ||||
-rw-r--r-- | winsup/cygwin/shared_info.h | 2 |
5 files changed, 78 insertions, 9 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1088de8c4..54fe9acbd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,17 @@ +2009-02-26 Christopher Faylor <me+cygwin@cgf.cx> + + * dtable.cc (dtable::select_read): Add ability to override fh. + * fhandler.h (fhandler_fifo::select_read): Declare new function. + (fhandler_fifo::select_write): Ditto. + (fhandler_fifo::select_except): Ditto. + * select.cc (peek_pipe): Treat certain classes of pipe errors as "no + data". + (fhandler_fifo::select_read): Define new function. + (fhandler_fifo::select_write): Ditto. + (fhandler_fifo::select_except): Ditto. + + * shared_info.h (CURR_SHARED_MAGIC): Update. + 2009-02-23 Sjors Gielen <mailinglist@dazjorz.com> * Makefile.in: Add DESTDIR functionality. @@ -410,7 +424,6 @@ * mount.h: Move USER_* defines back to shared_info.h. * speclib: Force temporary directory cleanup. - 2009-01-02 Christopher Faylor <me+cygwin@cgf.cx> diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 4c002908e..30f78e1ae 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -1,7 +1,7 @@ /* dtable.cc: file descriptor support. Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008 Red Hat, Inc. + 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. This file is part of Cygwin. @@ -640,7 +640,8 @@ dtable::select_read (int fd, select_record *s) fhandler_base *fh = fds[fd]; s = fh->select_read (s); s->fd = fd; - s->fh = fh; + if (!s->fh) + s->fh = fh; s->thread_errno = 0; debug_printf ("%s fd %d", fh->get_name (), fd); return s; diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index b737c481b..80ec297a5 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -558,6 +558,7 @@ public: void init (HANDLE, DWORD, mode_t); static int create (fhandler_pipe *[2], unsigned, int); static int create_selectable (LPSECURITY_ATTRIBUTES, HANDLE&, HANDLE&, DWORD, const char * = NULL); + friend class fhandler_fifo; }; enum fifo_state @@ -582,6 +583,9 @@ public: int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2))); OVERLAPPED *get_overlapped () {return &io_status;} OVERLAPPED *get_overlapped_buffer () {return &io_status;} + select_record *select_read (select_record *s); + select_record *select_write (select_record *s); + select_record *select_except (select_record *s); }; class fhandler_dev_raw: public fhandler_base diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index da54da5a1..747444884 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 Red Hat, Inc. + 2005, 2006, 2007, 2008, 2009 Red Hat, Inc. This file is part of Cygwin. @@ -465,10 +465,19 @@ peek_pipe (select_record *s, bool from_select) select_printf ("%s, select for read/except on write end of pipe", fh->get_name ()); else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL)) - { - select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ()); - n = -1; - } + switch (GetLastError ()) + { + case ERROR_BAD_PIPE: + case ERROR_PIPE_BUSY: + case ERROR_NO_DATA: + case ERROR_PIPE_NOT_CONNECTED: + n = 0; + break; + default: + select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ()); + n = -1; + break; + } if (n < 0) { @@ -691,6 +700,48 @@ fhandler_pipe::select_except (select_record *s) return s; } +select_record * +fhandler_fifo::select_read (select_record *s) +{ + if (!s) + s = new select_record; + s->startup = start_thread_pipe; + s->peek = peek_pipe; + s->verify = verify_ok; + s->cleanup = pipe_cleanup; + s->read_selected = true; + s->read_ready = false; + return s; +} + +select_record * +fhandler_fifo::select_write (select_record *s) +{ + if (!s) + s = new select_record; + s->startup = start_thread_pipe; + s->peek = peek_pipe; + s->verify = verify_ok; + s->cleanup = pipe_cleanup; + s->write_selected = true; + s->write_ready = false; + return s; +} + +select_record * +fhandler_fifo::select_except (select_record *s) +{ + if (!s) + s = new select_record; + s->startup = start_thread_pipe; + s->peek = peek_pipe; + s->verify = verify_ok; + s->cleanup = pipe_cleanup; + s->except_selected = true; + s->except_ready = false; + return s; +} + static int peek_console (select_record *me, bool) { diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index e332829df..bf4be4e2b 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -31,7 +31,7 @@ public: #define SHARED_INFO_CB 39328 -#define CURR_SHARED_MAGIC 0x22f9ff0bU +#define CURR_SHARED_MAGIC 0x398d8baU #define USER_VERSION 1 // increment when mount table changes and #define USER_VERSION_MAGIC CYGWIN_VERSION_MAGIC (USER_MAGIC, USER_VERSION) |