diff options
author | Robin Jarry <robin@jarry.cc> | 2024-02-19 21:26:11 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-02-22 22:29:10 +0100 |
commit | ff77c7a52d78a487ea7775515aab4db399371075 (patch) | |
tree | d32245452005a3b3c7c3ceb0c99d8d70f99980c5 /main.go | |
parent | 73daa9fbd046471dd2afc2f7b454317597b7ab03 (diff) | |
download | aerc-ff77c7a52d78a487ea7775515aab4db399371075.tar.gz |
ipc: fix deadlock when aerc is not running
Defer the execution of failed IPC commands *after* the IPC socket has
been unblocked.
Fixes: fd4dd4240885 ("ipc: wait for app to be ready before accepting commands")
Fixes: https://todo.sr.ht/~rjarry/aerc/229
Changelog-fixed: Deadlock when running `aerc mailto:foo@bar.com`
without another instance of aerc already running.
Reported-by: Skejg <grolleman@zoho.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -164,7 +164,6 @@ func main() { if err == nil { return // other aerc instance takes over } - fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v\n", err) // continue with setting up a new aerc instance and retry after init retryExec = true } @@ -211,7 +210,11 @@ func main() { // set the aerc version so that we can use it in the template funcs templates.SetVersion(Version) - if retryExec { + enableIpc := func() { + startupDone() + if !retryExec { + return + } // retry execution err := ipc.ConnectAndExec(opts.Command) if err != nil { @@ -220,7 +223,7 @@ func main() { if err != nil { log.Warnf("failed to close backends: %v", err) } - return + os.Exit(1) } } @@ -253,7 +256,7 @@ loop: // it will be ready. And in some cases, it may never be. // At least, we can be confident that accepting IPC // commands will not crash the whole process. - once.Do(startupDone) + once.Do(enableIpc) case callback := <-ui.Callbacks: callback() case <-ui.Redraw: |