From 7dba8ea2ddac0d97b457a68f8e0f07219809d565 Mon Sep 17 00:00:00 2001 From: Mihir Lad Date: Mon, 20 Jul 2020 00:38:56 -0400 Subject: [PATCH] dwm: Recovery from main socket disconnection Catch ClosedSocketErrors and attempt reconnection. --- src/modules/dwm.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/dwm.cpp b/src/modules/dwm.cpp index 4592254e..81dcdb86 100644 --- a/src/modules/dwm.cpp +++ b/src/modules/dwm.cpp @@ -177,6 +177,9 @@ namespace modules { try { m_ipc->run_command(ev_name, stoul(cmd)); 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) { throw module_error(err.what()); } @@ -254,6 +257,9 @@ namespace modules { if (client_id != 0) { try { 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) { throw module_error(err.what()); }