MINOR: connection: update rhttp flags usage

Change the flags used for reversed connection :
* CO_FL_REVERSED is now put after reversal for passive connect. For
  active connect, it is delayed when accept is completed after reversal.
* CO_FL_ACT_REVERSING replace the old CO_FL_REVERSED. It is put only for
  active connect on reversal and removes once accept is done.

This allows to identify a connection as reversed during its whole
lifetime. This should be useful to extend reverse connect.
This commit is contained in:
Amaury Denoyelle 2023-11-16 17:13:28 +01:00
parent 691f4cf449
commit 8cc3fc73f1
4 changed files with 10 additions and 6 deletions

View File

@ -85,7 +85,8 @@ enum {
CO_FL_IDLE_LIST = 0x00000002, /* 2 = in idle_list, 3 = invalid */
CO_FL_LIST_MASK = 0x00000003, /* Is the connection in any server-managed list ? */
CO_FL_REVERSED = 0x00000004, /* connection has been reversed but not yet accepted */
CO_FL_REVERSED = 0x00000004, /* connection has been reversed to backend / reversed and accepted on frontend */
CO_FL_ACT_REVERSING = 0x00000008, /* connection has been reversed to frontend but not yet accepted */
/* unused : 0x00000008 */
/* unused : 0x00000010 */

View File

@ -703,7 +703,7 @@ static inline int conn_is_reverse(const struct connection *conn)
static inline int conn_reverse_in_preconnect(const struct connection *conn)
{
return conn_is_back(conn) ? !!(conn->reverse.target) :
!!(conn->flags & CO_FL_REVERSED);
!!(conn->flags & CO_FL_ACT_REVERSING);
}
/* Initialize <conn> as a reverse connection to <target>. */

View File

@ -2670,6 +2670,8 @@ int conn_reverse(struct connection *conn)
sess->origin = NULL;
session_free(sess);
conn_set_owner(conn, NULL, NULL);
conn->flags |= CO_FL_REVERSED;
}
else {
/* Wake up receiver to proceed to connection accept. */
@ -2678,7 +2680,7 @@ int conn_reverse(struct connection *conn)
conn_backend_deinit(conn);
conn->target = &l->obj_type;
conn->flags |= CO_FL_REVERSED;
conn->flags |= CO_FL_ACT_REVERSING;
task_wakeup(l->rx.reverse_connect.task, TASK_WOKEN_ANY);
}

View File

@ -183,7 +183,7 @@ struct task *rev_process(struct task *task, void *ctx, unsigned int state)
}
else {
/* Spurrious receiver task woken up despite pend_conn not ready/on error. */
BUG_ON(!(conn->flags & CO_FL_REVERSED));
BUG_ON(!(conn->flags & CO_FL_ACT_REVERSING));
/* A connection is ready to be accepted. */
listener_accept(l);
@ -349,8 +349,9 @@ struct connection *rev_accept_conn(struct listener *l, int *status)
}
/* listener_accept() must not be called if no pending connection is not yet reversed. */
BUG_ON(!(conn->flags & CO_FL_REVERSED));
conn->flags &= ~CO_FL_REVERSED;
BUG_ON(!(conn->flags & CO_FL_ACT_REVERSING));
conn->flags &= ~CO_FL_ACT_REVERSING;
conn->flags |= CO_FL_REVERSED;
conn->mux->ctl(conn, MUX_REVERSE_CONN, NULL);
l->rx.reverse_connect.pend_conn = NULL;