socket: use existing socket if it is connected
When using ephemeral aerc sessions – for example while writing patches for it – the mailto: functionality breaks if the socket is removed. Try to send a ping (an empty message) to the socket and remove it, if the send fails or no noop reply is received. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
parent
c947811e9f
commit
37c1db2ab2
1 changed files with 4 additions and 2 deletions
|
@ -24,8 +24,10 @@ type AercServer struct {
|
||||||
|
|
||||||
func StartServer() (*AercServer, error) {
|
func StartServer() (*AercServer, error) {
|
||||||
sockpath := path.Join(xdg.RuntimeDir(), "aerc.sock")
|
sockpath := path.Join(xdg.RuntimeDir(), "aerc.sock")
|
||||||
// remove the socket if it already exists
|
// remove the socket if it is not connected to a session
|
||||||
os.Remove(sockpath)
|
if err := ConnectAndExec(""); err != nil {
|
||||||
|
os.Remove(sockpath)
|
||||||
|
}
|
||||||
logging.Infof("Starting Unix server: %s", sockpath)
|
logging.Infof("Starting Unix server: %s", sockpath)
|
||||||
l, err := net.Listen("unix", sockpath)
|
l, err := net.Listen("unix", sockpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue