]> git.lyx.org Git - lyx.git/blobdiff - src/ServerSocket.cpp
Update previews on preference change (#9507)
[lyx.git] / src / ServerSocket.cpp
index 7b9d6df5af71c81d885c36c29045127a2964ae47..3535ee4560a94c309ebed3ab80ff58a41f72d9c3 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));
@@ -125,8 +124,10 @@ void ServerSocket::serverCallback()
 // if the connection has been closed
 void ServerSocket::dataCallback(int fd)
 {
-       shared_ptr<LyXDataSocket> client = clients[fd];
-
+       map<int, shared_ptr<LyXDataSocket> >::const_iterator it = clients.find(fd);
+       if (it == clients.end())
+               return;
+       shared_ptr<LyXDataSocket> client = it->second;
        string line;
        size_t pos;
        bool saidbye = false;