Try to fix crash on looking up endpoint of a disconnected socket.
authorCarl Hetherington <cth@carlh.net>
Tue, 5 Nov 2013 23:48:54 +0000 (23:48 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 5 Nov 2013 23:48:54 +0000 (23:48 +0000)
src/lib/server.cc

index 5db6540647f3bc4f894ddc69f83715f666b3d5c6..69ca5b39aefe88c2f9c3ec14aaf622d69705daf6 100644 (file)
@@ -149,17 +149,18 @@ Server::worker_thread ()
                lock.unlock ();
 
                int frame = -1;
+               string ip;
 
                struct timeval start;
                gettimeofday (&start, 0);
                
                try {
                        frame = process (socket);
+                       ip = socket->socket().remote_endpoint().address().to_string();
                } catch (std::exception& e) {
                        _log->log (String::compose ("Error: %1", e.what()));
                }
 
-               string const ip = socket->socket().remote_endpoint().address().to_string();
                socket.reset ();
                
                lock.lock ();