]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: add new function si_detach_endpoint()
authorWilly Tarreau <w@1wt.eu>
Tue, 4 Aug 2015 18:44:05 +0000 (20:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Aug 2015 19:54:25 +0000 (21:54 +0200)
This function only detaches the endpoint from the stream-int and
optionally returns the original pointer. This will be needed to
steal idle connections from other connections.

include/proto/stream_interface.h

index 449d5e6bc8ebb85ba1dd9493fb35d9b148204aa9..6e4cfe878a888c7691c81c75d8b960ef1175ea78 100644 (file)
@@ -129,6 +129,19 @@ static inline void si_set_state(struct stream_interface *si, int state)
        si->state = si->prev_state = state;
 }
 
+/* only detaches the endpoint from the SI, which means that it's set to
+ * NULL and that ->ops is mapped to si_embedded_ops. The previous endpoint
+ * is returned.
+ */
+static inline enum obj_type *si_detach_endpoint(struct stream_interface *si)
+{
+       enum obj_type *prev = si->end;
+
+       si->end = NULL;
+       si->ops = &si_embedded_ops;
+       return prev;
+}
+
 /* Release the endpoint if it's a connection or an applet, then nullify it.
  * Note: released connections are closed then freed.
  */
@@ -149,8 +162,7 @@ static inline void si_release_endpoint(struct stream_interface *si)
                        appctx->applet->release(appctx);
                appctx_free(appctx); /* we share the connection pool */
        }
-       si->end = NULL;
-       si->ops = &si_embedded_ops;
+       si_detach_endpoint(si);
 }
 
 /* Turn a possibly existing connection endpoint of stream interface <si> to