]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: listener: support rebinding during resume()
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Jul 2014 19:06:24 +0000 (21:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 7 Jul 2014 23:13:35 +0000 (01:13 +0200)
When a listener resumes operations, supporting a full rebind makes it
possible to perform a full stop as a pause(). This will be used for
pausing abstract namespace unix sockets.

src/listener.c

index 67f8ca7d4342064812b64369de4457b5e97546ea..11df69fd17e3fcc7915999bb47f1ffa098af953d 100644 (file)
@@ -120,10 +120,26 @@ int pause_listener(struct listener *l)
  * may replace enable_listener(). The resulting state will either be LI_READY
  * or LI_FULL. 0 is returned in case of failure to resume (eg: dead socket).
  * Listeners bound to a different process are not woken up unless we're in
- * foreground mode.
+ * foreground mode. If the listener was only in the assigned state, it's totally
+ * rebound. This can happen if a pause() has completely stopped it. If the
+ * resume fails, 0 is returned and an error might be displayed.
  */
 int resume_listener(struct listener *l)
 {
+       if (l->state == LI_ASSIGNED) {
+               char msg[100];
+               int err;
+
+               err = l->proto->bind(l, msg, sizeof(msg));
+               if (err & ERR_ALERT)
+                       Alert("Resuming listener: %s\n", msg);
+               else if (err & ERR_WARN)
+                       Warning("Resuming listener: %s\n", msg);
+
+               if (err & (ERR_FATAL | ERR_ABORT))
+                       return 0;
+       }
+
        if (l->state < LI_PAUSED)
                return 0;