QCoreApplication::postEvent(this,
static_cast<QEvent *>(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;
// 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;
}
}
-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)) {
<< "\nLyXComm: Resetting connection" << endl;
ReleaseMutex(outbuf_mutex_);
closeConnection();
- if (!checkStopServer())
- openConnection();
+ openConnection();
}
}