summaryrefslogtreecommitdiff
path: root/lib/server
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-04-20 22:08:07 +0000
committerChris Wilson <chris+github@qwirx.com>2007-04-20 22:08:07 +0000
commite7a6b4627a28c510a745d191150d0185e2480b6d (patch)
tree886de794ea528461fce01e038e35f4ad2983d2a5 /lib/server
parentc585fec3d8c28c82892ecf0c802d86f712e35603 (diff)
Don't log errors or throw exceptions when we get ERROR_NO_DATA, which just
means that the pipe is being closed. Treat it as a normal remote close (EOF) instead. Don't log an error if DisconnectNamedPipe tells us that the remote end already closed the pipe (ERROR_PIPE_NOT_CONNECTED). Treat ERR_PIPE_NOT_CONNECTED during pipe reads as EOF as well. Improve logging of pipe errors by including the error message. (refs #3, merges [1458] and [1463])
Diffstat (limited to 'lib/server')
-rw-r--r--lib/server/WinNamedPipeStream.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/lib/server/WinNamedPipeStream.cpp b/lib/server/WinNamedPipeStream.cpp
index ad5764ec..32ae42f2 100644
--- a/lib/server/WinNamedPipeStream.cpp
+++ b/lib/server/WinNamedPipeStream.cpp
@@ -373,9 +373,26 @@ int WinNamedPipeStream::Read(void *pBuffer, int NBytes, int Timeout)
&NumBytesRead, // number of bytes read
NULL)) // not overlapped
{
+ DWORD err = GetLastError();
+
Close();
- THROW_EXCEPTION(ConnectionException,
- Conn_SocketReadError)
+
+ // ERROR_NO_DATA is a strange name for
+ // "The pipe is being closed". No exception wanted.
+
+ if (err == ERROR_NO_DATA ||
+ err == ERROR_PIPE_NOT_CONNECTED)
+ {
+ NumBytesRead = 0;
+ }
+ else
+ {
+ ::syslog(LOG_ERR, "Failed to read from "
+ "control socket: %s",
+ GetErrorMessage(err).c_str());
+ THROW_EXCEPTION(ConnectionException,
+ Conn_SocketReadError)
+ }
}
// Closed for reading at EOF?
@@ -426,8 +443,19 @@ void WinNamedPipeStream::Write(const void *pBuffer, int NBytes)
::syslog(LOG_ERR, "Failed to write to control socket: "
"%s", GetErrorMessage(err).c_str());
Close();
- THROW_EXCEPTION(ConnectionException,
- Conn_SocketWriteError)
+
+ // ERROR_NO_DATA is a strange name for
+ // "The pipe is being closed". No exception wanted.
+
+ if (err == ERROR_NO_DATA)
+ {
+ return;
+ }
+ else
+ {
+ THROW_EXCEPTION(ConnectionException,
+ Conn_SocketWriteError)
+ }
}
NumBytesWrittenTotal += NumBytesWrittenThisTime;