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

Side by Side Diff: src/shared/Communication.cpp

Issue 10891004: Use a named mutex to avoid race conditions (Closed)
Patch Set: Created June 7, 2013, 8:05 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/engine/main.cpp ('K') | « src/shared/Communication.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <Windows.h> 1 #include <Windows.h>
2 #include <Lmcons.h> 2 #include <Lmcons.h>
3 #include <Sddl.h> 3 #include <Sddl.h>
4 4
5 #include "Communication.h" 5 #include "Communication.h"
6 6
7 namespace 7 namespace
8 { 8 {
9 const int bufferSize = 1024; 9 const int bufferSize = 1024;
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return Communication::InputBuffer(stream.str()); 123 return Communication::InputBuffer(stream.str());
124 } 124 }
125 125
126 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message) 126 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message)
127 { 127 {
128 DWORD bytesWritten; 128 DWORD bytesWritten;
129 std::string data = message.Get(); 129 std::string data = message.Get();
130 if (!WriteFile(pipe, data.c_str(), data.length(), &bytesWritten, 0)) 130 if (!WriteFile(pipe, data.c_str(), data.length(), &bytesWritten, 0))
131 throw std::runtime_error("Failed to write to pipe"); 131 throw std::runtime_error("Failed to write to pipe");
132 } 132 }
133
134 bool Communication::PipeExists(const std::wstring& name)
135 {
136 return WaitNamedPipe(name.c_str(), 100) || GetLastError() == ERROR_SEM_TIMEOUT ;
137 }
OLDNEW
« src/engine/main.cpp ('K') | « src/shared/Communication.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld