]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: session: register a data->wake callback to process errors
authorWilly Tarreau <w@1wt.eu>
Wed, 3 Oct 2012 19:17:23 +0000 (21:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 4 Oct 2012 20:26:10 +0000 (22:26 +0200)
The connection layer will soon call ->wake() only when errors happen, and
not ->init(). So make the session layer use this callback to detect errors
and abort connections.

src/session.c

index a32ec6b09d738307a6383be020addd9a37877ccb..b5dfd2bb9275eba7388f8ebdf049940df3fba6ec 100644 (file)
@@ -51,6 +51,7 @@ struct pool_head *pool2_session;
 struct list sessions;
 
 static int conn_session_complete(struct connection *conn);
+static int conn_session_update(struct connection *conn);
 static struct task *expire_mini_session(struct task *t);
 int session_complete(struct session *s);
 
@@ -58,7 +59,7 @@ int session_complete(struct session *s);
 struct data_cb sess_conn_cb = {
        .recv = NULL,
        .send = NULL,
-       .wake = NULL,
+       .wake = conn_session_update,
        .init = conn_session_complete,
 };
 
@@ -281,6 +282,18 @@ static int conn_session_complete(struct connection *conn)
        return -1;
 }
 
+/* Update an embryonic session status. The connection is killed in case of
+ * error, and <0 will be returned. Otherwise it does nothing.
+ */
+static int conn_session_update(struct connection *conn)
+{
+       if (conn->flags & CO_FL_ERROR) {
+               kill_mini_session(conn->owner);
+               return -1;
+       }
+       return 0;
+}
+
 /* Manages embryonic sessions timeout. It is only called when the timeout
  * strikes and performs the required cleanup.
  */