]> git.lyx.org Git - lyx.git/blobdiff - src/ServerSocket.cpp
Document the export tests and other tests
[lyx.git] / src / ServerSocket.cpp
index 4c34212cb52b597f55e7793974392299abca0053..fb6e3bf75c6abe24c62e7c7b05ad683041b6df74 100644 (file)
@@ -41,7 +41,6 @@ using namespace std;
 using namespace lyx::support;
 
 
-
 namespace lyx {
 
 // Address is the unix address for the socket.
@@ -98,6 +97,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) {
@@ -105,11 +109,6 @@ 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));
@@ -130,11 +129,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;