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>2008-08-20 06:25:06 +0400
committerChristopher Faylor <me@cgf.cx>2008-08-20 06:25:06 +0400
commitfbf39a58cbbd92f3f185bad685c67099cc1ec805 (patch)
tree52d78923e8a61c058d6ecfba274985cd8ff549e8
parentec8a7e416f570407fe5360959272418a2b4c79f8 (diff)
* fhandler.cc (fhandler_base::wait_overlapped): Always assume that bytes will
be non-NULL. Distinguish input result from result derived from WFMO and GetOverlappedResult or res can never be -1. Only raise SIGPIPE when writing. * fhandler.h (fhandler_base::wait_overlapped): Pass first argument by value. * fhandler_fifo.cc (fhandler_fifo::wait): Pass in dummy byte count to wait_overlapped. * pipe.cc (DEFAULT_PIPEBUFSIZE): Define to 65536 explicitly.
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/fhandler.cc23
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/fhandler_fifo.cc3
-rw-r--r--winsup/cygwin/pipe.cc2
5 files changed, 27 insertions, 15 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 42e57fb92..056af7255 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,15 @@
+2008-08-19 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * fhandler.cc (fhandler_base::wait_overlapped): Always assume that
+ bytes will be non-NULL. Distinguish input result from result derived
+ from WFMO and GetOverlappedResult or res can never be -1. Only raise
+ SIGPIPE when writing.
+ * fhandler.h (fhandler_base::wait_overlapped): Pass first argument by
+ value.
+ * fhandler_fifo.cc (fhandler_fifo::wait): Pass in dummy byte count to
+ wait_overlapped.
+ * pipe.cc (DEFAULT_PIPEBUFSIZE): Define to 65536 explicitly.
+
2008-08-19 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Drop fattr variable
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 3fdddd549..1db40ac76 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1680,18 +1680,17 @@ fhandler_base::destroy_overlapped ()
}
int
-fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
+fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes)
{
- if (bytes)
- *bytes = (DWORD) -1;
+ int res;
+ *bytes = (DWORD) -1;
DWORD err = GetLastError ();
- if (!res && err != ERROR_IO_PENDING)
+ if (!inres && err != ERROR_IO_PENDING)
{
- if (err != ERROR_HANDLE_EOF)
+ if (err != ERROR_HANDLE_EOF && err != ERROR_BROKEN_PIPE)
goto err;
res = 1;
- if (*bytes)
- *bytes = 0;
+ *bytes = 0;
}
else
{
@@ -1707,12 +1706,13 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
if (&_my_tls == _main_tls)
w4[n++] = signal_arrived;
HANDLE h = writing ? get_output_handle () : get_handle ();
- switch (WaitForMultipleObjects (n, w4, false, INFINITE))
+ DWORD res = WaitForMultipleObjects (n, w4, false, INFINITE);
+ ResetEvent (get_overlapped ()->hEvent);
+ switch (res)
{
case WAIT_OBJECT_0:
debug_printf ("normal read");
- if (!bytes ||
- GetOverlappedResult (h, get_overlapped (), bytes, false))
+ if (GetOverlappedResult (h, get_overlapped (), bytes, false))
res = 1;
else
{
@@ -1738,10 +1738,9 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
err:
__seterrno_from_win_error (err);
res = -1;
- if (err == ERROR_NO_DATA || err == ERROR_BROKEN_PIPE)
+ if (writing && (err == ERROR_NO_DATA || err == ERROR_BROKEN_PIPE))
raise (SIGPIPE);
out:
- ResetEvent (get_overlapped ()->hEvent);
return res;
}
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 1430b28ed..05ed03c38 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -143,7 +143,7 @@ class fhandler_base
void del_my_locks (bool);
HANDLE read_state;
- int wait_overlapped (bool&, bool, DWORD *) __attribute__ ((regparm (3)));
+ int wait_overlapped (bool, bool, DWORD *) __attribute__ ((regparm (3)));
bool setup_overlapped () __attribute__ ((regparm (1)));
void destroy_overlapped () __attribute__ ((regparm (1)));
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 0faaec95e..a97d949ee 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -132,9 +132,10 @@ fhandler_fifo::wait (bool iswrite)
{
case fifo_wait_for_client:
bool res = ConnectNamedPipe (get_handle (), get_overlapped ());
+ DWORD dummy_bytes;
if (res || GetLastError () == ERROR_PIPE_CONNECTED)
return true;
- return wait_overlapped (res, iswrite, NULL);
+ return wait_overlapped (res, iswrite, &dummy_bytes);
default:
break;
}
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 2cad3fe26..b9e8b176f 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -490,7 +490,7 @@ fhandler_pipe::fstatvfs (struct statvfs *sfs)
return -1;
}
-#define DEFAULT_PIPEBUFSIZE (16 * PIPE_BUF)
+#define DEFAULT_PIPEBUFSIZE 65536
extern "C" int
pipe (int filedes[2])