handle client disconnection without crashing

This commit is contained in:
Maxime Coste 2013-08-28 19:19:54 +01:00
parent ef01cf71ff
commit 1d790541f5

View File

@ -334,6 +334,8 @@ bool RemoteUI::is_key_available()
} }
Key RemoteUI::get_key() Key RemoteUI::get_key()
{
try
{ {
Key key = read<Key>(m_socket_watcher.fd()); Key key = read<Key>(m_socket_watcher.fd());
if (key.modifiers == resize_modifier) if (key.modifiers == resize_modifier)
@ -343,6 +345,16 @@ Key RemoteUI::get_key()
} }
return key; return key;
} }
catch (peer_disconnected&)
{
throw client_removed{};
}
catch (socket_error&)
{
write_debug("ungraceful deconnection detected");
throw client_removed{};
}
}
DisplayCoord RemoteUI::dimensions() DisplayCoord RemoteUI::dimensions()
{ {