noip.c (unix_socket_status): Refactor status-file parsing.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 9 Jun 2018 14:52:12 +0000 (15:52 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 9 Jun 2018 14:58:23 +0000 (15:58 +0100)
Remove the early exit: we always process all of the entries now.  The
socket is `STALE' if we can't find any entries.

noip.c

diff --git a/noip.c b/noip.c
index 68b4978..9dfc6c3 100644 (file)
--- a/noip.c
+++ b/noip.c
@@ -704,15 +704,17 @@ static int unix_socket_status(struct sockaddr_un *sun, int quickp)
     goto done;
   if (!fgets(buf, sizeof(buf), fp)) goto done; /* skip header */
   len = strlen(sun->sun_path);
+  rc = 0;
   while (fgets(buf, sizeof(buf), fp)) {
     n = strlen(buf);
     if (n >= len + 2 && buf[n - len - 2] == ' ' && buf[n - 1] == '\n' &&
-       memcmp(buf + n - len - 1, sun->sun_path, len) == 0)
-      goto done;
+       memcmp(buf + n - len - 1, sun->sun_path, len) == 0) {
+      rc |= USED;
+    }
   }
   if (ferror(fp))
     goto done;
-  rc = STALE;
+  if (!rc) rc = STALE;
 done:
   if (fp) fclose(fp);