~rjarry/aerc-devel

aerc: Shutdown if socket communication fails v1 APPLIED

Adnan Maolood: 1
 aerc: Shutdown if socket communication fails

 1 files changed, 13 insertions(+), 10 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rjarry/aerc-devel/patches/28631/mbox | git am -3
Learn more about email & git

[PATCH] aerc: Shutdown if socket communication fails Export this patch

When provided with a mailto argument, aerc tries to connect to an
existing instance via a unix socket. If that fails, it starts up a new
instance and tries again. However, if that fails again (e.g. if the
unix server could not be started) then the new instance will remain open
without any indication that an error occured. Instead, shutdown the new
instance so the user can see the error message.
---
To test this, you can create the 'aerc.sock' file before aerc runs so
that the unix server will fail to start.
 aerc.go | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/aerc.go b/aerc.go
index b3338ba..696562d 100644
--- a/aerc.go
+++ b/aerc.go
@@ -123,7 +123,7 @@ func main() {
			return
		}
	}
	initDone := make(chan struct{})
	retryExec := false
	args := os.Args[optind:]
	if len(args) > 1 {
		usage()
@@ -134,15 +134,9 @@ func main() {
		if err == nil {
			return // other aerc instance takes over
		}
		fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v", err)
		fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v\n", err)
		// continue with setting up a new aerc instance and retry after init
		go func(msg string) {
			<-initDone
			err := lib.ConnectAndExec(msg)
			if err != nil {
				fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v", err)
			}
		}(arg)
		retryExec = true
	}

	var (
@@ -203,7 +197,16 @@ func main() {
	// set the aerc version so that we can use it in the template funcs
	templates.SetVersion(Version)

	close(initDone)
	if retryExec {
		// retry execution
		arg := args[0]
		err := lib.ConnectAndExec(arg)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v\n", err)
			aerc.CloseBackends()
			return
		}
	}

	if isatty.IsTerminal(os.Stderr.Fd()) {
		setWindowTitle()
-- 
2.34.1
Adnan Maolood, Jan 23, 2022 at 03:35: