* 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.
This commit is contained in:
Christopher Faylor 2009-02-27 00:34:40 +00:00
parent c636f27d48
commit c7ef20e7fa
5 changed files with 78 additions and 9 deletions

View File

@ -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>

View File

@ -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;

View File

@ -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

View File

@ -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)
{

View File

@ -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)