dwm: Recovery from main socket disconnection

Catch ClosedSocketErrors and attempt reconnection.
This commit is contained in:
Mihir Lad 2020-07-20 00:38:56 -04:00
parent a30a9b1e1b
commit 7dba8ea2dd

View File

@ -177,6 +177,9 @@ namespace modules {
try { try {
m_ipc->run_command(ev_name, stoul(cmd)); m_ipc->run_command(ev_name, stoul(cmd));
return true; return true;
} catch (const dwmipc::SocketClosedError& err) {
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
reconnect_dwm();
} catch (const dwmipc::IPCError& err) { } catch (const dwmipc::IPCError& err) {
throw module_error(err.what()); throw module_error(err.what());
} }
@ -254,6 +257,9 @@ namespace modules {
if (client_id != 0) { if (client_id != 0) {
try { try {
new_title = m_ipc->get_client(client_id)->name; new_title = m_ipc->get_client(client_id)->name;
} catch (const dwmipc::SocketClosedError& err) {
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
reconnect_dwm();
} catch (const dwmipc::IPCError& err) { } catch (const dwmipc::IPCError& err) {
throw module_error(err.what()); throw module_error(err.what());
} }