CLEANUP: stream: don't set ->target to the incoming connection anymore

Now that we have sess->origin to carry that information along, we don't
need to put that into strm->target anymore, so we remove one dependence
on the stream in embryonic connections.
This commit is contained in:
Willy Tarreau 2015-04-04 14:28:46 +02:00
parent d0d8da989b
commit 1f52bb27ec
2 changed files with 8 additions and 22 deletions

View File

@ -112,7 +112,7 @@ struct strm_logs {
struct stream { struct stream {
int flags; /* some flags describing the stream */ int flags; /* some flags describing the stream */
unsigned int uniq_id; /* unique ID used for the traces */ unsigned int uniq_id; /* unique ID used for the traces */
enum obj_type *target; /* target to use for this stream ; for mini-sess: incoming connection */ enum obj_type *target; /* target to use for this stream */
struct channel req; /* request channel */ struct channel req; /* request channel */
struct channel res; /* response channel */ struct channel res; /* response channel */

View File

@ -128,14 +128,6 @@ int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
s->si[0].flags = SI_FL_NONE; s->si[0].flags = SI_FL_NONE;
s->si[1].flags = SI_FL_ISBACK; s->si[1].flags = SI_FL_ISBACK;
/* On a mini-session, the connection is directly attached to the
* stream's target so that we don't need to initialize the stream
* interfaces. Another benefit is that it's easy to detect a mini-
* stream in dumps using this : it's the only one which has a
* connection in s->target.
*/
s->target = &cli_conn->obj_type;
s->logs.accept_date = date; /* user-visible date for logging */ s->logs.accept_date = date; /* user-visible date for logging */
s->logs.tv_accept = now; /* corrected date for internal use */ s->logs.tv_accept = now; /* corrected date for internal use */
s->uniq_id = global.req_count++; s->uniq_id = global.req_count++;
@ -268,7 +260,7 @@ int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
/* prepare the trash with a log prefix for stream <s>. It only works with /* prepare the trash with a log prefix for stream <s>. It only works with
* embryonic streams based on a real connection. This function requires that * embryonic streams based on a real connection. This function requires that
* at s->target still points to the incoming connection. * at sess->origin points to the incoming connection.
*/ */
static void prepare_mini_sess_log_prefix(struct stream *s) static void prepare_mini_sess_log_prefix(struct stream *s)
{ {
@ -277,7 +269,7 @@ static void prepare_mini_sess_log_prefix(struct stream *s)
int ret; int ret;
char *end; char *end;
struct session *sess = s->sess; struct session *sess = s->sess;
struct connection *cli_conn = __objt_conn(s->target); struct connection *cli_conn = __objt_conn(sess->origin);
ret = addr_to_str(&cli_conn->addr.from, pn, sizeof(pn)); ret = addr_to_str(&cli_conn->addr.from, pn, sizeof(pn));
if (ret <= 0) if (ret <= 0)
@ -299,13 +291,13 @@ static void prepare_mini_sess_log_prefix(struct stream *s)
/* This function kills an existing embryonic stream. It stops the connection's /* This function kills an existing embryonic stream. It stops the connection's
* transport layer, releases assigned resources, resumes the listener if it was * transport layer, releases assigned resources, resumes the listener if it was
* disabled and finally kills the file descriptor. This function requires that * disabled and finally kills the file descriptor. This function requires that
* at s->target still points to the incoming connection. * at sess->origin points to the incoming connection.
*/ */
static void kill_mini_session(struct stream *s) static void kill_mini_session(struct stream *s)
{ {
int level = LOG_INFO; int level = LOG_INFO;
struct session *sess = s->sess; struct session *sess = s->sess;
struct connection *conn = __objt_conn(s->target); struct connection *conn = __objt_conn(sess->origin);
unsigned int log = s->logs.logwait; unsigned int log = s->logs.logwait;
const char *err_msg; const char *err_msg;
@ -417,8 +409,7 @@ static struct task *expire_mini_session(struct task *t)
* success, 0 if the connection can be ignored, or a negative value upon * success, 0 if the connection can be ignored, or a negative value upon
* critical failure. The accepted file descriptor is closed if we return <= 0. * critical failure. The accepted file descriptor is closed if we return <= 0.
* The client-side end point is assumed to be a connection, whose pointer is * The client-side end point is assumed to be a connection, whose pointer is
* taken from s->target which is assumed to be valid. If the function fails, * taken from sess->origin which is assumed to be valid.
* it restores s->target.
*/ */
int stream_complete(struct stream *s) int stream_complete(struct stream *s)
{ {
@ -426,7 +417,7 @@ int stream_complete(struct stream *s)
struct listener *l = sess->listener; struct listener *l = sess->listener;
struct proxy *p = sess->fe; struct proxy *p = sess->fe;
struct task *t = s->task; struct task *t = s->task;
struct connection *conn = __objt_conn(s->target); struct connection *conn = __objt_conn(sess->origin);
int ret; int ret;
int i; int i;
@ -477,11 +468,7 @@ int stream_complete(struct stream *s)
si_reset(&s->si[0]); si_reset(&s->si[0]);
si_set_state(&s->si[0], SI_ST_EST); si_set_state(&s->si[0], SI_ST_EST);
/* attach the incoming connection to the stream interface now. /* attach the incoming connection to the stream interface now. */
* We must do that *before* clearing ->target because we need
* to keep a pointer to the connection in case we have to call
* kill_mini_session().
*/
si_attach_conn(&s->si[0], conn); si_attach_conn(&s->si[0], conn);
if (likely(sess->fe->options2 & PR_O2_INDEPSTR)) if (likely(sess->fe->options2 & PR_O2_INDEPSTR))
@ -565,7 +552,6 @@ int stream_complete(struct stream *s)
* because kill_mini_session() will need it. * because kill_mini_session() will need it.
*/ */
LIST_DEL(&s->list); LIST_DEL(&s->list);
s->target = &conn->obj_type;
return ret; return ret;
} }