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

@ -335,13 +335,25 @@ bool RemoteUI::is_key_available()
Key RemoteUI::get_key()
{
Key key = read<Key>(m_socket_watcher.fd());
if (key.modifiers == resize_modifier)
try
{
m_dimensions = { (int)(key.key >> 16), (int)(key.key & 0xFFFF) };
return Key::Invalid;
Key key = read<Key>(m_socket_watcher.fd());
if (key.modifiers == resize_modifier)
{
m_dimensions = { (int)(key.key >> 16), (int)(key.key & 0xFFFF) };
return Key::Invalid;
}
return key;
}
catch (peer_disconnected&)
{
throw client_removed{};
}
catch (socket_error&)
{
write_debug("ungraceful deconnection detected");
throw client_removed{};
}
return key;
}
DisplayCoord RemoteUI::dimensions()