* sigproc.h (wait_for_sigthread): Eliminate parameter.

* sigproc.cc (wait_for_sigthread): Ditto.  Don't synchronize with wait_sig
after receiving an event that it is ready to go.
(init_sig_pipe): New function.
(wait_sig): Call init_sig_pipe to create pipes for communicating signals to
this process.  Don't send sigCONT signal when initializing.
* fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change.
* fhandler.h (fhandler_*::write): Make ssize_t/__stdcall.
(fhandler_*::write_overlapped): Ditto.
(fhandler_*::raw_write): Ditto.
(fhandler_*::readv): Ditto.
(fhandler_*::writev): Ditto.
(fhandler_*::raw_read): Make __stdcall.
* fhandler: Accommodate changes to read/write functions throughout.
* fhandler_clipboard.cc: Ditto.
* fhandler_console.cc: Ditto.
* fhandler_dsp.cc: Ditto.
* fhandler_fifo.cc: Ditto.
* fhandler_mailslot.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_random.cc: Ditto.
* fhandler_tape.cc: Ditto.
* fhandler_tty.cc: Ditto.
* fhandler_virtual.cc: Ditto.
* fhandler_windows.cc: Ditto.
* fhandler_zero.cc: Ditto.
* syscalls.cc (readv): Use ssize_t as temp variable.
* fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will
never be treated as < 0.
(fhandler_base::wait_overlapped): Minimize calls to GetLastError.  Remove
duplicate debugging test.  Fix error return.
* fhandler.h (fhandler_fifo::fifo_name): Declare new function.
(fhandler_fifo::close): Ditto.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
* fhandler.cc (fhandler_fifo::fifo_name): Define new function.
(FIFO_BUF_SIZE): New define.
(cnp): Ditto.
(fhandler_fifo::open): Rework.  Use cnp to open named pipe.  Always open write
side as a client.  Open dummy client when writing and can't connect.
(wait): Rework.  Implement fifo_wait_for_next_client.  Handle signals during
connect better.  Add new fifo_wait_for_server code which polls
(sigh) waiting for server.
(fhandler_fifo::raw_read): Handle transition states when one client closes and
another is available.
(fhandler_fifo::close): Define.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
This commit is contained in:
Christopher Faylor
2009-07-24 20:54:33 +00:00
parent a58ebe50c2
commit 43c23d4b82
21 changed files with 341 additions and 143 deletions

View File

@ -209,7 +209,7 @@ fhandler_base::set_flags (int flags, int supplied_bin)
/* Cover function to ReadFile to achieve (as much as possible) Posix style
semantics and use of errno. */
void
void __stdcall
fhandler_base::raw_read (void *ptr, size_t& ulen)
{
#define bytes_read ulen
@ -278,7 +278,7 @@ retry:
static LARGE_INTEGER off_current = { QuadPart:FILE_USE_FILE_POINTER_POSITION };
static LARGE_INTEGER off_append = { QuadPart:FILE_WRITE_TO_END_OF_FILE };
int
ssize_t __stdcall
fhandler_base::raw_write (const void *ptr, size_t len)
{
NTSTATUS status;
@ -649,7 +649,7 @@ done:
an \n. If last char is an \r, look ahead one more char, if \n then
modify \r, if not, remember char.
*/
void
void __stdcall
fhandler_base::read (void *in_ptr, size_t& len)
{
char *ptr = (char *) in_ptr;
@ -676,7 +676,7 @@ fhandler_base::read (void *in_ptr, size_t& len)
else
len = copied_chars;
if (rbinary () || len <= 0)
if (rbinary () || (ssize_t) len <= 0)
goto out;
/* Scan buffer and turn \r\n into \n */
@ -739,7 +739,7 @@ out:
debug_printf ("returning %d, %s mode", len, rbinary () ? "binary" : "text");
}
int
ssize_t __stdcall
fhandler_base::write (const void *ptr, size_t len)
{
int res;
@ -834,7 +834,7 @@ fhandler_base::write (const void *ptr, size_t len)
return res;
}
ssize_t
ssize_t __stdcall
fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
ssize_t tot)
{
@ -891,7 +891,7 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
return len;
}
ssize_t
ssize_t __stdcall
fhandler_base::writev (const struct iovec *const iov, const int iovcnt,
ssize_t tot)
{
@ -1682,10 +1682,10 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes, DWORD le
int res = 0;
DWORD err;
DWORD err = GetLastError ();
if (is_nonblocking ())
{
if (inres || GetLastError () == ERROR_IO_PENDING)
if (inres || err == ERROR_IO_PENDING)
{
if (writing && !inres)
*bytes = len; /* This really isn't true but it seems like
@ -1696,17 +1696,10 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes, DWORD le
res = 1;
err = 0;
}
else
{
res = 0;
err = GetLastError ();
}
}
else if (inres || ((err = GetLastError ()) == ERROR_IO_PENDING))
else if (inres || err == ERROR_IO_PENDING)
{
#ifdef DEBUGGING
if (!get_overlapped ())
system_printf ("get_overlapped is zero?");
if (!get_overlapped ()->hEvent)
system_printf ("hEvent is zero?");
#endif
@ -1749,7 +1742,7 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes, DWORD le
debug_printf ("err %u", err);
__seterrno_from_win_error (err);
*bytes = (DWORD) -1;
res = -1;
res = 0;
}
else
{
@ -1796,7 +1789,7 @@ fhandler_base::read_overlapped (void *ptr, size_t& len)
len = (size_t) nbytes;
}
int __stdcall
ssize_t __stdcall
fhandler_base::write_overlapped (const void *ptr, size_t len)
{
DWORD nbytes;