Remove session socket on error signal
This commit is contained in:
parent
bbf48e1d39
commit
a6d14cecbe
|
@ -203,6 +203,8 @@ void signal_handler(int signal)
|
||||||
case SIGTERM: text = "SIGTERM"; break;
|
case SIGTERM: text = "SIGTERM"; break;
|
||||||
}
|
}
|
||||||
on_assert_failed(text);
|
on_assert_failed(text);
|
||||||
|
if (Server::has_instance())
|
||||||
|
Server::instance().close_session();
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -541,10 +541,16 @@ Server::Server(String session_name)
|
||||||
m_listener.reset(new FDWatcher{listen_sock, accepter});
|
m_listener.reset(new FDWatcher{listen_sock, accepter});
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::~Server()
|
void Server::close_session()
|
||||||
{
|
{
|
||||||
unlink(("/tmp/kak-" + m_session).c_str());
|
unlink(("/tmp/kak-" + m_session).c_str());
|
||||||
close(m_listener->fd());
|
close(m_listener->fd());
|
||||||
|
m_listener.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Server::~Server()
|
||||||
|
{
|
||||||
|
close_session();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ struct Server : public Singleton<Server>
|
||||||
~Server();
|
~Server();
|
||||||
const String& session() const { return m_session; }
|
const String& session() const { return m_session; }
|
||||||
|
|
||||||
|
void close_session();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_session;
|
String m_session;
|
||||||
std::unique_ptr<FDWatcher> m_listener;
|
std::unique_ptr<FDWatcher> m_listener;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user