Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2009-06-15 03:42:09 +0400
committerChristopher Faylor <me@cgf.cx>2009-06-15 03:42:09 +0400
commitfee56469d473166006476374717805e0901bda0f (patch)
tree28aa717f4264869399392b91b4218ac47f580597 /winsup/cygwin/fhandler.cc
parent313c719cb83191e8ea0072edba4d9d399737eac4 (diff)
* errno.cc (errmap): Add mapping for ERROR_IO_INCOMPLETE.
* fhandler.cc (fhandler_base::fcntl): Fix comment. (fhandler_base::wait_overlapped): Accept an optional len parameter. Use the len parameter when WriteFile fails with ERROR_IO_PENDING. Make debug output less alarming. (fhandler_base::write_overlapped): Pass len to wait_overlapped. * fhandler.h (fhandler_base::wait_overlapped): Add an optional argument denoting the number of characters intended to be written. * fhandler_tty.cc (fhandler_pty_master::close): Don't close archetype handles when cygwin is still initializing since the handles aren't actually opened at that point.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc34
1 files changed, 23 insertions, 11 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 0d499ba9c..2e909fbd1 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1185,12 +1185,10 @@ int fhandler_base::fcntl (int cmd, void *arg)
break;
case F_SETFL:
{
- /*
- * Only O_APPEND, O_ASYNC and O_NONBLOCK/O_NDELAY are allowed.
- * Each other flag will be ignored.
- * Since O_ASYNC isn't defined in fcntl.h it's currently
- * ignored as well.
- */
+ /* Only O_APPEND, O_ASYNC and O_NONBLOCK/O_NDELAY are allowed.
+ Each other flag will be ignored.
+ Since O_ASYNC isn't defined in fcntl.h it's currently
+ ignored as well. */
const int allowed_flags = O_APPEND | O_NONBLOCK_MASK;
int new_flags = (int) arg & allowed_flags;
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
@@ -1676,7 +1674,7 @@ fhandler_base::destroy_overlapped ()
}
int
-fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes)
+fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes, DWORD len)
{
if (!get_overlapped ())
return inres;
@@ -1686,8 +1684,22 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes)
DWORD err;
if (is_nonblocking ())
{
- err = GetLastError ();
- res = inres;
+ if (inres || GetLastError () == ERROR_IO_PENDING)
+ {
+ if (writing && !inres)
+ *bytes = len; /* This really isn't true but it seems like
+ this is a corner-case for linux's
+ non-blocking I/O implementation. How can
+ you know how many bytes were written until
+ the I/O operation really completes? */
+ res = 1;
+ err = 0;
+ }
+ else
+ {
+ res = 0;
+ err = GetLastError ();
+ }
}
else if (inres || ((err = GetLastError ()) == ERROR_IO_PENDING))
{
@@ -1719,7 +1731,7 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes)
else if (!wores)
{
err = GetLastError ();
- debug_printf ("general error");
+ debug_printf ("GetOverLappedResult failed");
}
else
{
@@ -1779,7 +1791,7 @@ fhandler_base::write_overlapped (const void *ptr, size_t len)
{
bool res = WriteFile (get_output_handle (), ptr, len, &bytes_written,
get_overlapped ());
- int wres = wait_overlapped (res, true, &bytes_written);
+ int wres = wait_overlapped (res, true, &bytes_written, (size_t) len);
if (wres || !_my_tls.call_signal_handler ())
break;
}