[Box Backup-commit] COMMIT r1522 - box/chris/merge/lib/server
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Fri Apr 20 23:08:07 BST 2007
Author: chris
Date: 2007-04-20 23:08:07 +0100 (Fri, 20 Apr 2007)
New Revision: 1522
Modified:
box/chris/merge/lib/server/WinNamedPipeStream.cpp
Log:
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])
Modified: box/chris/merge/lib/server/WinNamedPipeStream.cpp
===================================================================
--- box/chris/merge/lib/server/WinNamedPipeStream.cpp 2007-04-20 22:04:39 UTC (rev 1521)
+++ box/chris/merge/lib/server/WinNamedPipeStream.cpp 2007-04-20 22:08:07 UTC (rev 1522)
@@ -373,9 +373,26 @@
&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 @@
::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;
More information about the Boxbackup-commit
mailing list