MEDIUM: tree-wide: Use unsafe conn-stream API when it is relevant

The unsafe conn-stream API (__cs_*) is now used when we are sure the good
endpoint or application is attached to the conn-stream. This avoids compiler
warnings about possible null derefs. It also simplify the code and clear up
any ambiguity about manipulated entities.
This commit is contained in:
Christopher Faulet 2022-02-28 09:09:05 +01:00
parent e645d88c6b
commit 693b23bb10
13 changed files with 85 additions and 104 deletions

View File

@ -55,18 +55,16 @@ void si_sync_send(struct stream_interface *si);
/* returns the channel which receives data from this stream interface (input channel) */
static inline struct channel *si_ic(struct stream_interface *si)
{
struct stream *strm = cs_strm(si->cs);
struct stream *strm = __cs_strm(si->cs);
ALREADY_CHECKED(strm);
return ((si->flags & SI_FL_ISBACK) ? &(strm->res) : &(strm->req));
}
/* returns the channel which feeds data to this stream interface (output channel) */
static inline struct channel *si_oc(struct stream_interface *si)
{
struct stream *strm = cs_strm(si->cs);
struct stream *strm = __cs_strm(si->cs);
ALREADY_CHECKED(strm);
return ((si->flags & SI_FL_ISBACK) ? &(strm->req) : &(strm->res));
}
@ -85,27 +83,22 @@ static inline struct buffer *si_ob(struct stream_interface *si)
/* returns the stream associated to a stream interface */
static inline struct stream *si_strm(struct stream_interface *si)
{
struct stream *strm = cs_strm(si->cs);
ALREADY_CHECKED(strm);
return strm;
return __cs_strm(si->cs);
}
/* returns the task associated to this stream interface */
static inline struct task *si_task(struct stream_interface *si)
{
struct stream *strm = cs_strm(si->cs);
struct stream *strm = __cs_strm(si->cs);
ALREADY_CHECKED(strm);
return strm->task;
}
/* returns the stream interface on the other side. Used during forwarding. */
static inline struct stream_interface *si_opposite(struct stream_interface *si)
{
struct stream *strm = cs_strm(si->cs);
struct stream *strm = __cs_strm(si->cs);
ALREADY_CHECKED(strm);
return ((si->flags & SI_FL_ISBACK) ? strm->csf->si : strm->csb->si);
}
@ -161,8 +154,8 @@ static inline void si_applet_release(struct stream_interface *si)
{
struct appctx *appctx;
appctx = cs_appctx(si->cs);
if (appctx && appctx->applet->release && !si_state_in(si->state, SI_SB_DIS|SI_SB_CLO))
appctx = __cs_appctx(si->cs);
if (appctx->applet->release && !si_state_in(si->state, SI_SB_DIS|SI_SB_CLO))
appctx->applet->release(appctx);
}

View File

@ -1019,7 +1019,7 @@ int httpchk_build_status_header(struct server *s, struct buffer *buf)
static int wake_srv_chk(struct conn_stream *cs)
{
struct connection *conn;
struct check *check = cs_check(cs);
struct check *check = __cs_check(cs);
struct email_alertq *q = container_of(check, typeof(*q), check);
int ret = 0;

View File

@ -2684,8 +2684,7 @@ __LJMP static int hlua_socket_connect_yield(struct lua_State *L, int status, lua
return 2;
}
appctx = cs_appctx(s->csf);
ALREADY_CHECKED(appctx);
appctx = __cs_appctx(s->csf);
/* Check for connection established. */
if (appctx->ctx.hlua_cosocket.connected) {

View File

@ -3878,12 +3878,10 @@ static int http_handle_stats(struct stream *s, struct channel *req)
struct http_msg *msg = &txn->req;
struct uri_auth *uri_auth = s->be->uri_auth;
const char *h, *lookup, *end;
struct appctx *appctx;
struct appctx *appctx = __cs_appctx(s->csb);
struct htx *htx;
struct htx_sl *sl;
appctx = cs_appctx(s->csb);
ALREADY_CHECKED(appctx);
memset(&appctx->ctx.stats, 0, sizeof(appctx->ctx.stats));
appctx->st1 = appctx->st2 = 0;
appctx->ctx.stats.st_code = STAT_STATUS_INIT;
@ -5004,7 +5002,7 @@ static void http_debug_stline(const char *dir, struct stream *s, const struct ht
chunk_printf(&trash, "%08x:%s.%s[%04x:%04x]: ", s->uniq_id, s->be->id,
dir,
objt_conn(sess->origin) ? (unsigned short)__objt_conn(sess->origin)->handle.fd : -1,
cs_conn(s->csb) ? (unsigned short)(cs_conn(s->csb))->handle.fd : -1);
cs_conn(s->csb) ? (unsigned short)(__cs_conn(s->csb))->handle.fd : -1);
max = HTX_SL_P1_LEN(sl);
UBOUND(max, trash.size - trash.data - 3);
@ -5035,7 +5033,7 @@ static void http_debug_hdr(const char *dir, struct stream *s, const struct ist n
chunk_printf(&trash, "%08x:%s.%s[%04x:%04x]: ", s->uniq_id, s->be->id,
dir,
objt_conn(sess->origin) ? (unsigned short)__objt_conn(sess->origin)->handle.fd : -1,
cs_conn(s->csb) ? (unsigned short)(cs_conn(s->csb))->handle.fd : -1);
cs_conn(s->csb) ? (unsigned short)(__cs_conn(s->csb))->handle.fd : -1);
max = n.len;
UBOUND(max, trash.size - trash.data - 3);

View File

@ -3314,9 +3314,9 @@ static void fcgi_strm_capture_bad_message(struct fcgi_conn *fconn, struct fcgi_s
if (fstrm->cs && cs_strm(fstrm->cs)) {
if (sess == NULL)
sess = cs_strm(fstrm->cs)->sess;
sess = __cs_strm(fstrm->cs)->sess;
if (!(h1m->flags & H1_MF_RESP))
other_end = cs_strm(fstrm->cs)->be;
other_end = __cs_strm(fstrm->cs)->be;
else
other_end = sess->fe;
} else

View File

@ -1353,9 +1353,9 @@ static void h1_capture_bad_message(struct h1c *h1c, struct h1s *h1s,
if ((h1c->flags & H1C_F_ST_ATTACHED) && cs_strm(h1s->cs)) {
if (sess == NULL)
sess = cs_strm(h1s->cs)->sess;
sess = __cs_strm(h1s->cs)->sess;
if (!(h1m->flags & H1_MF_RESP))
other_end = cs_strm(h1s->cs)->be;
other_end = __cs_strm(h1s->cs)->be;
else
other_end = sess->fe;
} else

View File

@ -406,7 +406,7 @@ static void mux_pt_destroy_meth(void *ctx)
*/
static void mux_pt_detach(struct conn_stream *cs)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
struct mux_pt_ctx *ctx;
ALREADY_CHECKED(conn);
@ -444,7 +444,7 @@ static int mux_pt_avail_streams(struct connection *conn)
static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
TRACE_ENTER(PT_EV_STRM_SHUT, conn, cs);
@ -464,7 +464,7 @@ static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
TRACE_ENTER(PT_EV_STRM_SHUT, conn, cs);
@ -496,7 +496,7 @@ static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
*/
static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
size_t ret = 0;
TRACE_ENTER(PT_EV_RX_DATA, conn, cs, buf, (size_t[]){count});
@ -525,7 +525,7 @@ static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t
/* Called from the upper layer, to send data */
static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
size_t ret;
TRACE_ENTER(PT_EV_TX_DATA, conn, cs, buf, (size_t[]){count});
@ -546,7 +546,7 @@ static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t
*/
static int mux_pt_subscribe(struct conn_stream *cs, int event_type, struct wait_event *es)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
TRACE_POINT(PT_EV_RX_DATA|PT_EV_TX_DATA, conn, cs, 0, (size_t[]){event_type});
return conn->xprt->subscribe(conn, conn->xprt_ctx, event_type, es);
@ -558,7 +558,7 @@ static int mux_pt_subscribe(struct conn_stream *cs, int event_type, struct wait_
*/
static int mux_pt_unsubscribe(struct conn_stream *cs, int event_type, struct wait_event *es)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
TRACE_POINT(PT_EV_RX_DATA|PT_EV_TX_DATA, conn, cs, 0, (size_t[]){event_type});
return conn->xprt->unsubscribe(conn, conn->xprt_ctx, event_type, es);
@ -568,7 +568,7 @@ static int mux_pt_unsubscribe(struct conn_stream *cs, int event_type, struct wai
/* Send and get, using splicing */
static int mux_pt_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int count)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
int ret;
TRACE_ENTER(PT_EV_RX_DATA, conn, cs, 0, (size_t[]){count});
@ -589,7 +589,7 @@ static int mux_pt_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned i
static int mux_pt_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
int ret;
TRACE_ENTER(PT_EV_TX_DATA, conn, cs, 0, (size_t[]){pipe->data});

View File

@ -2612,8 +2612,8 @@ static void dump_server_addr(const struct sockaddr_storage *addr, char *addr_str
*/
static int dump_servers_state(struct stream_interface *si)
{
struct appctx *appctx = cs_appctx(si->cs);
struct proxy *px;
struct appctx *appctx = __cs_appctx(si->cs);
struct proxy *px = appctx->ctx.cli.p0;
struct server *srv;
char srv_addr[INET6_ADDRSTRLEN + 1];
char srv_agent_addr[INET6_ADDRSTRLEN + 1];
@ -2622,9 +2622,6 @@ static int dump_servers_state(struct stream_interface *si)
int bk_f_forced_id, srv_f_forced_id;
char *srvrecord;
ALREADY_CHECKED(appctx);
px = appctx->ctx.cli.p0;
if (!appctx->ctx.cli.p1)
appctx->ctx.cli.p1 = px->srv;

View File

@ -2586,7 +2586,7 @@ static int stats_dump_resolv_to_buffer(struct stream_interface *si,
struct field *stats, size_t stats_count,
struct list *stat_modules)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct channel *rep = si_ic(si);
struct stats_module *mod;
size_t idx = 0;
@ -2620,7 +2620,7 @@ int stats_dump_resolvers(struct stream_interface *si,
struct field *stats, size_t stats_count,
struct list *stat_modules)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct channel *rep = si_ic(si);
struct resolvers *resolver = appctx->ctx.stats.obj1;
struct dns_nameserver *ns = appctx->ctx.stats.obj2;

View File

@ -1812,7 +1812,7 @@ int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len,
*/
static int stats_dump_fe_stats(struct stream_interface *si, struct proxy *px)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct field *stats = stat_l[STATS_DOMAIN_PROXY];
struct stats_module *mod;
size_t stats_count = ST_F_TOTAL_FIELDS;
@ -1979,13 +1979,11 @@ int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags,
*/
static int stats_dump_li_stats(struct stream_interface *si, struct proxy *px, struct listener *l)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct field *stats = stat_l[STATS_DOMAIN_PROXY];
struct stats_module *mod;
size_t stats_count = ST_F_TOTAL_FIELDS;
ALREADY_CHECKED(appctx);
memset(stats, 0, sizeof(struct field) * stat_count[STATS_DOMAIN_PROXY]);
if (!stats_fill_li_stats(px, l, appctx->ctx.stats.flags, stats,
@ -2492,13 +2490,11 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
*/
static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, struct server *sv)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct stats_module *mod;
struct field *stats = stat_l[STATS_DOMAIN_PROXY];
size_t stats_count = ST_F_TOTAL_FIELDS;
ALREADY_CHECKED(appctx);
memset(stats, 0, sizeof(struct field) * stat_count[STATS_DOMAIN_PROXY]);
if (!stats_fill_sv_stats(px, sv, appctx->ctx.stats.flags, stats,
@ -2819,7 +2815,7 @@ int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int le
*/
static int stats_dump_be_stats(struct stream_interface *si, struct proxy *px)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct field *stats = stat_l[STATS_DOMAIN_PROXY];
struct stats_module *mod;
size_t stats_count = ST_F_TOTAL_FIELDS;
@ -2860,7 +2856,7 @@ static int stats_dump_be_stats(struct stream_interface *si, struct proxy *px)
*/
static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
char scope_txt[STAT_SCOPE_TXT_MAXLEN + sizeof STAT_SCOPE_PATTERN];
struct stats_module *mod;
int stats_module_len = 0;
@ -2969,7 +2965,8 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px
*/
static void stats_dump_html_px_end(struct stream_interface *si, struct proxy *px)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
chunk_appendf(&trash, "</table>");
if ((px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN)) {
@ -3011,7 +3008,7 @@ static void stats_dump_html_px_end(struct stream_interface *si, struct proxy *px
int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
struct proxy *px, struct uri_auth *uri)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct stream *s = si_strm(si);
struct channel *rep = si_ic(si);
struct server *sv, *svs; /* server and server-state, server-state=server or server->track */
@ -3384,7 +3381,7 @@ static void stats_dump_html_head(struct appctx *appctx, struct uri_auth *uri)
*/
static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *uri)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
unsigned int up = (now.tv_sec - start_date.tv_sec);
char scope_txt[STAT_SCOPE_TXT_MAXLEN + sizeof STAT_SCOPE_PATTERN];
const char *scope_ptr = stats_scope_ptr(appctx, si);
@ -3666,7 +3663,7 @@ static int stats_dump_proxies(struct stream_interface *si,
struct htx *htx,
struct uri_auth *uri)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct channel *rep = si_ic(si);
struct proxy *px;
@ -3713,7 +3710,7 @@ static int stats_dump_proxies(struct stream_interface *si,
static int stats_dump_stat_to_buffer(struct stream_interface *si, struct htx *htx,
struct uri_auth *uri)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct channel *rep = si_ic(si);
enum stats_domain domain = appctx->ctx.stats.domain;
@ -3815,7 +3812,7 @@ static int stats_dump_stat_to_buffer(struct stream_interface *si, struct htx *ht
static int stats_process_http_post(struct stream_interface *si)
{
struct stream *s = si_strm(si);
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct proxy *px = NULL;
struct server *sv = NULL;
@ -4151,7 +4148,7 @@ static int stats_send_http_headers(struct stream_interface *si, struct htx *htx)
{
struct stream *s = si_strm(si);
struct uri_auth *uri = s->be->uri_auth;
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct htx_sl *sl;
unsigned int flags;
@ -4205,12 +4202,10 @@ static int stats_send_http_redirect(struct stream_interface *si, struct htx *htx
char scope_txt[STAT_SCOPE_TXT_MAXLEN + sizeof STAT_SCOPE_PATTERN];
struct stream *s = si_strm(si);
struct uri_auth *uri = s->be->uri_auth;
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct htx_sl *sl;
unsigned int flags;
ALREADY_CHECKED(appctx);
/* scope_txt = search pattern + search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
scope_txt[0] = 0;
if (appctx->ctx.stats.scope_len) {
@ -4522,9 +4517,7 @@ int stats_fill_info(struct field *info, int len, uint flags)
*/
static int stats_dump_info_to_buffer(struct stream_interface *si)
{
struct appctx *appctx = cs_appctx(si->cs);
ALREADY_CHECKED(appctx);
struct appctx *appctx = __cs_appctx(si->cs);
if (!stats_fill_info(info, INF_TOTAL_FIELDS, appctx->ctx.stats.flags))
return 0;

View File

@ -275,11 +275,10 @@ static void strm_trace(enum trace_level level, uint64_t mask, const struct trace
*/
int stream_upgrade_from_cs(struct conn_stream *cs, struct buffer *input)
{
struct stream *s = cs_strm(cs);
if (cs_conn_mux(cs)) {
const struct mux_ops *mux = DISGUISE(cs_conn_mux(cs));
struct stream *s = __cs_strm(cs);
const struct mux_ops *mux = cs_conn_mux(cs);
if (mux) {
if (mux->flags & MX_FL_HTX)
s->flags |= SF_HTX;
}
@ -989,7 +988,7 @@ enum act_return process_use_service(struct act_rule *rule, struct proxy *px,
appctx->rule = rule;
}
else
appctx = cs_appctx(s->csb);
appctx = __cs_appctx(s->csb);
/* Stops the applet scheduling, in case of the init function miss
* some data.
@ -2140,10 +2139,10 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (!(req->flags & (CF_KERN_SPLICING|CF_SHUTR)) &&
req->to_forward &&
(global.tune.options & GTUNE_USE_SPLICE) &&
(cs_conn(si_f->cs) && cs_conn(si_f->cs)->xprt && cs_conn(si_f->cs)->xprt->rcv_pipe &&
cs_conn(si_f->cs)->mux && cs_conn(si_f->cs)->mux->rcv_pipe) &&
(cs_conn(si_b->cs) && cs_conn(si_b->cs)->xprt && cs_conn(si_b->cs)->xprt->snd_pipe &&
cs_conn(si_b->cs)->mux && cs_conn(si_b->cs)->mux->snd_pipe) &&
(cs_conn(si_f->cs) && __cs_conn(si_f->cs)->xprt && __cs_conn(si_f->cs)->xprt->rcv_pipe &&
__cs_conn(si_f->cs)->mux && __cs_conn(si_f->cs)->mux->rcv_pipe) &&
(cs_conn(si_b->cs) && __cs_conn(si_b->cs)->xprt && __cs_conn(si_b->cs)->xprt->snd_pipe &&
__cs_conn(si_b->cs)->mux && __cs_conn(si_b->cs)->mux->snd_pipe) &&
(pipes_used < global.maxpipes) &&
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_REQ) ||
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_AUT) &&
@ -2333,10 +2332,10 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (!(res->flags & (CF_KERN_SPLICING|CF_SHUTR)) &&
res->to_forward &&
(global.tune.options & GTUNE_USE_SPLICE) &&
(cs_conn(si_f->cs) && cs_conn(si_f->cs)->xprt && cs_conn(si_f->cs)->xprt->snd_pipe &&
cs_conn(si_f->cs)->mux && cs_conn(si_f->cs)->mux->snd_pipe) &&
(cs_conn(si_b->cs) && cs_conn(si_b->cs)->xprt && cs_conn(si_b->cs)->xprt->rcv_pipe &&
cs_conn(si_b->cs)->mux && cs_conn(si_b->cs)->mux->rcv_pipe) &&
(cs_conn(si_f->cs) && __cs_conn(si_f->cs)->xprt && __cs_conn(si_f->cs)->xprt->snd_pipe &&
__cs_conn(si_f->cs)->mux && __cs_conn(si_f->cs)->mux->snd_pipe) &&
(cs_conn(si_b->cs) && __cs_conn(si_b->cs)->xprt && __cs_conn(si_b->cs)->xprt->rcv_pipe &&
__cs_conn(si_b->cs)->mux && __cs_conn(si_b->cs)->mux->rcv_pipe) &&
(pipes_used < global.maxpipes) &&
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_RTR) ||
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_AUT) &&
@ -2413,8 +2412,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
si_b->prev_state == SI_ST_EST) {
chunk_printf(&trash, "%08x:%s.srvcls[%04x:%04x]\n",
s->uniq_id, s->be->id,
cs_conn(si_f->cs) ? (unsigned short)cs_conn(si_f->cs)->handle.fd : -1,
cs_conn(si_b->cs) ? (unsigned short)cs_conn(si_b->cs)->handle.fd : -1);
cs_conn(si_f->cs) ? (unsigned short)__cs_conn(si_f->cs)->handle.fd : -1,
cs_conn(si_b->cs) ? (unsigned short)__cs_conn(si_b->cs)->handle.fd : -1);
DISGUISE(write(1, trash.area, trash.data));
}
@ -2422,8 +2421,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
si_f->prev_state == SI_ST_EST) {
chunk_printf(&trash, "%08x:%s.clicls[%04x:%04x]\n",
s->uniq_id, s->be->id,
cs_conn(si_f->cs) ? (unsigned short)cs_conn(si_f->cs)->handle.fd : -1,
cs_conn(si_b->cs) ? (unsigned short)cs_conn(si_b->cs)->handle.fd : -1);
cs_conn(si_f->cs) ? (unsigned short)__cs_conn(si_f->cs)->handle.fd : -1,
cs_conn(si_b->cs) ? (unsigned short)__cs_conn(si_b->cs)->handle.fd : -1);
DISGUISE(write(1, trash.area, trash.data));
}
}
@ -2490,8 +2489,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
chunk_printf(&trash, "%08x:%s.closed[%04x:%04x]\n",
s->uniq_id, s->be->id,
cs_conn(si_f->cs) ? (unsigned short)cs_conn(si_f->cs)->handle.fd : -1,
cs_conn(si_b->cs) ? (unsigned short)cs_conn(si_b->cs)->handle.fd : -1);
cs_conn(si_f->cs) ? (unsigned short)__cs_conn(si_f->cs)->handle.fd : -1,
cs_conn(si_b->cs) ? (unsigned short)__cs_conn(si_b->cs)->handle.fd : -1);
DISGUISE(write(1, trash.area, trash.data));
}
@ -3093,7 +3092,7 @@ void list_services(FILE *out)
*/
static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct stream *strm)
{
struct appctx *appctx = cs_appctx(si->cs);
struct appctx *appctx = __cs_appctx(si->cs);
struct tm tm;
extern const char *monthname[12];
char pn[INET6_ADDRSTRLEN];
@ -3101,8 +3100,6 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
struct connection *conn;
struct appctx *tmpctx;
ALREADY_CHECKED(appctx);
chunk_reset(&trash);
if (appctx->ctx.sess.section > 0 && appctx->ctx.sess.uid != strm->uniq_id) {

View File

@ -387,12 +387,10 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
*/
if (cs && cs->data_cb == &si_conn_cb) {
struct stream *strm = cs_strm(cs);
ret = make_proxy_line(trash.area, trash.size,
objt_server(conn->target),
cs_conn(si_opposite(cs_si(cs))->cs),
strm);
cs_strm(cs));
}
else {
/* The target server expects a LOCAL line to be sent first. Retrieving
@ -595,7 +593,7 @@ static void stream_int_notify(struct stream_interface *si)
*/
static int si_cs_process(struct conn_stream *cs)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
struct stream_interface *si = cs_si(cs);
struct channel *ic = si_ic(si);
struct channel *oc = si_oc(si);
@ -683,14 +681,12 @@ static int si_cs_process(struct conn_stream *cs)
*/
int si_cs_send(struct conn_stream *cs)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
struct stream_interface *si = cs_si(cs);
struct channel *oc = si_oc(si);
int ret;
int did_send = 0;
BUG_ON(!conn);
if (conn->flags & CO_FL_ERROR || cs->flags & (CS_FL_ERROR|CS_FL_ERR_PENDING)) {
/* We're probably there because the tasklet was woken up,
* but process_stream() ran before, detected there were an
@ -998,12 +994,12 @@ void si_update_both(struct stream_interface *si_f, struct stream_interface *si_b
if (cs_appctx(si_f->cs) &&
((si_rx_endp_ready(si_f) && !si_rx_blocked(si_f)) ||
(si_tx_endp_ready(si_f) && !si_tx_blocked(si_f))))
appctx_wakeup(cs_appctx(si_f->cs));
appctx_wakeup(__cs_appctx(si_f->cs));
if (cs_appctx(si_b->cs) &&
((si_rx_endp_ready(si_b) && !si_rx_blocked(si_b)) ||
(si_tx_endp_ready(si_b) && !si_tx_blocked(si_b))))
appctx_wakeup(cs_appctx(si_b->cs));
appctx_wakeup(__cs_appctx(si_b->cs));
}
/*
@ -1251,15 +1247,13 @@ static void stream_int_chk_snd_conn(struct stream_interface *si)
*/
int si_cs_recv(struct conn_stream *cs)
{
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
struct stream_interface *si = cs_si(cs);
struct channel *ic = si_ic(si);
int ret, max, cur_read = 0;
int read_poll = MAX_READ_POLL_LOOPS;
int flags = 0;
BUG_ON(!conn);
/* If not established yet, do nothing. */
if (si->state != SI_ST_EST)
return 0;
@ -1638,6 +1632,8 @@ void si_applet_wake_cb(struct stream_interface *si)
{
struct channel *ic = si_ic(si);
BUG_ON(cs_appctx(si->cs));
/* If the applet wants to write and the channel is closed, it's a
* broken pipe and it must be reported.
*/
@ -1661,7 +1657,7 @@ void si_applet_wake_cb(struct stream_interface *si)
*/
if ((si_rx_endp_ready(si) && !si_rx_blocked(si)) ||
(si_tx_endp_ready(si) && !si_tx_blocked(si)))
appctx_wakeup(cs_appctx(si->cs));
appctx_wakeup(__cs_appctx(si->cs));
}
/*
@ -1676,6 +1672,8 @@ static void stream_int_shutr_applet(struct stream_interface *si)
{
struct channel *ic = si_ic(si);
BUG_ON(cs_appctx(si->cs));
si_rx_shut_blk(si);
if (ic->flags & CF_SHUTR)
return;
@ -1710,6 +1708,8 @@ static void stream_int_shutw_applet(struct stream_interface *si)
struct channel *ic = si_ic(si);
struct channel *oc = si_oc(si);
BUG_ON(cs_appctx(si->cs));
oc->flags &= ~CF_SHUTW_NOW;
if (oc->flags & CF_SHUTW)
return;
@ -1723,7 +1723,7 @@ static void stream_int_shutw_applet(struct stream_interface *si)
}
/* on shutw we always wake the applet up */
appctx_wakeup(cs_appctx(si->cs));
appctx_wakeup(__cs_appctx(si->cs));
switch (si->state) {
case SI_ST_RDY:
@ -1761,13 +1761,15 @@ static void stream_int_chk_rcv_applet(struct stream_interface *si)
{
struct channel *ic = si_ic(si);
BUG_ON(cs_appctx(si->cs));
DPRINTF(stderr, "%s: si=%p, si->state=%d ic->flags=%08x oc->flags=%08x\n",
__FUNCTION__,
si, si->state, ic->flags, si_oc(si)->flags);
if (!ic->pipe) {
/* (re)start reading */
appctx_wakeup(cs_appctx(si->cs));
appctx_wakeup(__cs_appctx(si->cs));
}
}
@ -1776,6 +1778,8 @@ static void stream_int_chk_snd_applet(struct stream_interface *si)
{
struct channel *oc = si_oc(si);
BUG_ON(cs_appctx(si->cs));
DPRINTF(stderr, "%s: si=%p, si->state=%d ic->flags=%08x oc->flags=%08x\n",
__FUNCTION__,
si, si->state, si_ic(si)->flags, oc->flags);
@ -1793,7 +1797,7 @@ static void stream_int_chk_snd_applet(struct stream_interface *si)
if (!channel_is_empty(oc)) {
/* (re)start sending */
appctx_wakeup(cs_appctx(si->cs));
appctx_wakeup(__cs_appctx(si->cs));
}
}

View File

@ -1323,7 +1323,7 @@ enum tcpcheck_eval_ret tcpcheck_eval_send(struct check *check, struct tcpcheck_r
enum tcpcheck_eval_ret ret = TCPCHK_EVAL_CONTINUE;
struct tcpcheck_send *send = &rule->send;
struct conn_stream *cs = check->cs;
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
struct buffer *tmp = NULL;
struct htx *htx = NULL;
int connection_hdr = 0;
@ -1533,7 +1533,7 @@ enum tcpcheck_eval_ret tcpcheck_eval_send(struct check *check, struct tcpcheck_r
enum tcpcheck_eval_ret tcpcheck_eval_recv(struct check *check, struct tcpcheck_rule *rule)
{
struct conn_stream *cs = check->cs;
struct connection *conn = cs_conn(cs);
struct connection *conn = __cs_conn(cs);
enum tcpcheck_eval_ret ret = TCPCHK_EVAL_CONTINUE;
size_t max, read, cur_read = 0;
int is_empty;