]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: frontend: make ->accept only return +/-1
authorWilly Tarreau <w@1wt.eu>
Sun, 5 Apr 2015 09:52:08 +0000 (11:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Apr 2015 09:37:34 +0000 (11:37 +0200)
This function was specified as being able to return 3 states, which had
repercussions to the stream accept function. It was used at the time
when the frontend would do the monitoring itself. This is not the case
anymore, so let's simplify this.

src/frontend.c
src/stream.c

index 4ef39d06c2a60075275942dacf835025e3e1c23f..a4941d3a59ddc504e654a9c3409bdf775b15eaf2 100644 (file)
@@ -48,8 +48,7 @@
 
 /* Finish a stream accept() for a proxy (TCP or HTTP). It returns a negative
  * value in case of a critical failure which must cause the listener to be
- * disabled, a positive value in case of success, or zero if it is a success
- * but the stream must be closed ASAP (eg: monitoring). It only supports
+ * disabled, a positive or null value in case of success. It only supports
  * streams with a connection in si[0].
  */
 int frontend_accept(struct stream *s)
index 256b28341d72e919ffa3c70371faf9159cd972dc..1bcd2eb90b10f54669cc53e7bdcf8f6e7aaaa28c 100644 (file)
@@ -213,16 +213,8 @@ int stream_accept_session(struct session *sess, struct task *t)
        else if (appctx)
                s->si[0].flags |= SI_FL_WAIT_DATA;
 
-       /* FIXME: we shouldn't restrict ourselves to connections but for now
-        * the only ->accept() only works with sessions.
-        */
-       if (conn && p->accept && (ret = p->accept(s)) <= 0) {
-               /* Either we had an unrecoverable error (<0) or work is
-                * finished (=0, eg: monitoring), in both situations,
-                * we can release everything and close.
-                */
-               goto out_free_strm;
-       }
+       if (conn && p->accept && p->accept(s) < 0)
+               goto out_fail_accept;
 
        if (conn) {
                /* if logs require transport layer information, note it on the connection */
@@ -241,7 +233,7 @@ int stream_accept_session(struct session *sess, struct task *t)
        return 1;
 
        /* Error unrolling */
- out_free_strm:
+ out_fail_accept:
        LIST_DEL(&s->list);
        pool_free2(pool2_stream, s);
  out_return: