commit 1b77ad485132dd80c7671fc8119cc0c6dc00d6e1 from: Omar Polo date: Fri Jul 08 16:52:47 2022 UTC don't loop indefinitely in ctl_connect if the server fails to start for wathever reason, we end up looping in ctl_connect indefinitely as we try to spawn the deamon (that dies) and try to connect to it. Add an arbitrary maximum number of retries before giving up. Reported by sikmir in the GitHub issue #1, thanks! commit - 17ef54d6ac6c34b0b1370c1c57836322702783e1 commit + 1b77ad485132dd80c7671fc8119cc0c6dc00d6e1 blob - 03560a00c389f5fc885cbf19f5057827019f020a blob + 20c6f9bfe65edbb6d0a7c4813b069a2ac910bb53 --- ctl.c +++ ctl.c @@ -736,6 +736,7 @@ ctl_connect(void) struct sockaddr_un sa; size_t size; int fd, lockfd = -1, locked = 0, spawned = 0; + int attempt = 0; char *lockfile = NULL; memset(&sa, 0, sizeof(sa)); @@ -754,6 +755,8 @@ retry: log_debug("connection failed: %s", strerror(errno)); if (errno != ECONNREFUSED && errno != ENOENT) goto failed; + if (attempt++ == 100) + goto failed; close(fd); if (!locked) {