]> git.lyx.org Git - lyx.git/blobdiff - src/Server.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / Server.cpp
index 08867d837c354d781fe9cbe55f0b205414e0f052..33c32ea19ceac317ebd26010e91b85c78fecd087 100644 (file)
@@ -319,8 +319,8 @@ bool LyXComm::pipeServer()
                                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;
@@ -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();
        }
 }