X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FServer.cpp;h=33c32ea19ceac317ebd26010e91b85c78fecd087;hb=2098f1d8c20d51e63e670bcdc9da8996068975bf;hp=08867d837c354d781fe9cbe55f0b205414e0f052;hpb=9919ec3625edb268bf63a91b37c1220bd16c9b02;p=lyx.git diff --git a/src/Server.cpp b/src/Server.cpp index 08867d837c..33c32ea19c 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -319,8 +319,8 @@ bool LyXComm::pipeServer() QCoreApplication::postEvent(this, static_cast(event)); // Wait for completion - while (pipe_[i].nbytes && !checkStopServer()) - Sleep(100); + while (pipe_[i].nbytes && !checkStopServer(100)) + ; pipe_[i].pending_io = false; pipe_[i].state = READING_STATE; continue; @@ -354,7 +354,7 @@ bool LyXComm::pipeServer() // We get here when a reader is started // well before a reply is ready, so delay // a bit in order to not burden the cpu. - Sleep(100); + checkStopServer(100); pipe_[i].pending_io = true; continue; } @@ -406,15 +406,17 @@ bool LyXComm::event(QEvent * e) } -bool LyXComm::checkStopServer() +bool LyXComm::checkStopServer(DWORD timeout) { - return WaitForSingleObject(stopserver_, 0) == WAIT_OBJECT_0; + return WaitForSingleObject(stopserver_, timeout) == WAIT_OBJECT_0; } bool LyXComm::startPipe(DWORD index) { pipe_[index].pending_io = false; + pipe_[index].overlap.Offset = 0; + pipe_[index].overlap.OffsetHigh = 0; // Overlapped ConnectNamedPipe should return zero. if (ConnectNamedPipe(pipe_[index].handle, &pipe_[index].overlap)) { @@ -664,8 +666,7 @@ void LyXComm::send(string const & msg) << "\nLyXComm: Resetting connection" << endl; ReleaseMutex(outbuf_mutex_); closeConnection(); - if (!checkStopServer()) - openConnection(); + openConnection(); } }