Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/shared/Communication.cpp

Issue 10902015: Don't spawn a new engine if the pipe is busy (Closed)
Patch Set: Created June 6, 2013, 10:35 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/shared/Communication.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/shared/Communication.cpp
===================================================================
--- a/src/shared/Communication.cpp
+++ b/src/shared/Communication.cpp
@@ -48,6 +48,11 @@
{
}
+Communication::PipeBusyError::PipeBusyError()
+ : std::runtime_error("Timeout while trying to connect to a named pipe, pipe is busy")
+{
+}
+
Communication::Pipe::Pipe(const std::wstring& pipeName, Communication::Pipe::Mode mode)
{
pipe = INVALID_HANDLE_VALUE;
@@ -71,8 +76,14 @@
}
else
{
- if (WaitNamedPipeW(pipeName.c_str(), 5000))
+ pipe = CreateFileW(pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
+ if (pipe == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PIPE_BUSY)
+ {
+ if (!WaitNamedPipeW(pipeName.c_str(), 5000))
+ throw PipeBusyError();
+
pipe = CreateFileW(pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
+ }
}
if (pipe == INVALID_HANDLE_VALUE)
« no previous file with comments | « src/shared/Communication.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld