]> git.lyx.org Git - lyx.git/blobdiff - src/ServerSocket.cpp
Disable CheckTeX while buffer is processed
[lyx.git] / src / ServerSocket.cpp
index 3d73a67ed6d955c08318323357856f5ec10aa8f9..fd903ce18fa4f69898da1516ae4d2acb5b2b2602 100644 (file)
 #include "support/debug.h"
 #include "support/environment.h"
 #include "support/FileName.h"
+#include "support/lassert.h"
 #include "support/socktools.h"
 
-#include "support/bind.h"
+#include <boost/assert.hpp>
 
 #include <cerrno>
+#include <cstring>
 #include <ostream>
 
 #if defined (_WIN32)
 # include <io.h>
 #endif
 
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
 using namespace std;
 using namespace lyx::support;
 
@@ -97,6 +103,11 @@ string const ServerSocket::address() const
 // is OK and if the number of clients does not exceed MAX_CLIENTS
 void ServerSocket::serverCallback()
 {
+       if (clients.size() >= MAX_CLIENTS) {
+               writeln("BYE:Too many clients connected");
+               return;
+       }
+
        int const client_fd = socktools::accept(fd_);
 
        if (fd_ == -1) {
@@ -104,14 +115,8 @@ void ServerSocket::serverCallback()
                return;
        }
 
-       if (clients.size() >= MAX_CLIENTS) {
-               writeln("BYE:Too many clients connected");
-               return;
-       }
-
        // Register the new client.
-       clients[client_fd] =
-               shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
+       clients[client_fd] = make_shared<LyXDataSocket>(client_fd);
        theApp()->registerSocketCallback(
                client_fd,
                bind(&ServerSocket::dataCallback,
@@ -129,11 +134,11 @@ void ServerSocket::dataCallback(int fd)
                return;
        shared_ptr<LyXDataSocket> client = it->second;
        string line;
-       size_t pos;
        bool saidbye = false;
        while (!saidbye && client->readln(line)) {
                // The protocol must be programmed here
                // Split the key and the data
+               size_t pos;
                if ((pos = line.find(':')) == string::npos) {
                        client->writeln("ERROR:" + line + ":malformed message");
                        continue;