mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: filters: Forward data only if the last filter forwards something
In flt_tcp_payload() and flt_http_payload(), if the last filter does not forwarding anything, nothing is forwarded, not even the already filtered data. For now, this patch is useless because the last filter is always sync with the stream's offset. But it will be mandatory for a bugfix.
This commit is contained in:
parent
727a3f1ca3
commit
71179a3ea9
@ -611,7 +611,7 @@ flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len)
|
|||||||
struct filter *filter;
|
struct filter *filter;
|
||||||
unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn);
|
unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn);
|
||||||
unsigned int out = co_data(msg->chn);
|
unsigned int out = co_data(msg->chn);
|
||||||
int ret = len - out;
|
int ret = 0, data = len - out;
|
||||||
|
|
||||||
DBG_TRACE_ENTER(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s, s->txn, msg);
|
DBG_TRACE_ENTER(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s, s->txn, msg);
|
||||||
list_for_each_entry(filter, &strm_flt(s)->filters, list) {
|
list_for_each_entry(filter, &strm_flt(s)->filters, list) {
|
||||||
@ -623,14 +623,19 @@ flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len)
|
|||||||
unsigned int offset = *flt_off - *strm_off;
|
unsigned int offset = *flt_off - *strm_off;
|
||||||
|
|
||||||
DBG_TRACE_DEVEL(FLT_ID(filter), STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
|
DBG_TRACE_DEVEL(FLT_ID(filter), STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
|
||||||
ret = FLT_OPS(filter)->http_payload(s, filter, msg, out + offset, ret - offset);
|
ret = FLT_OPS(filter)->http_payload(s, filter, msg, out + offset, data - offset);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
*flt_off += ret;
|
*flt_off += ret;
|
||||||
ret += offset;
|
data = ret + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*strm_off += ret;
|
|
||||||
|
/* Only forward data if the last filter decides to forward something */
|
||||||
|
if (ret > 0) {
|
||||||
|
ret = data;
|
||||||
|
*strm_off += ret;
|
||||||
|
}
|
||||||
end:
|
end:
|
||||||
DBG_TRACE_LEAVE(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
|
DBG_TRACE_LEAVE(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
|
||||||
return ret;
|
return ret;
|
||||||
@ -861,7 +866,7 @@ flt_tcp_payload(struct stream *s, struct channel *chn, unsigned int len)
|
|||||||
struct filter *filter;
|
struct filter *filter;
|
||||||
unsigned long long *strm_off = &FLT_STRM_OFF(s, chn);
|
unsigned long long *strm_off = &FLT_STRM_OFF(s, chn);
|
||||||
unsigned int out = co_data(chn);
|
unsigned int out = co_data(chn);
|
||||||
int ret = len - out;
|
int ret = 0, data = len - out;
|
||||||
|
|
||||||
DBG_TRACE_ENTER(STRM_EV_TCP_ANA|STRM_EV_FLT_ANA, s);
|
DBG_TRACE_ENTER(STRM_EV_TCP_ANA|STRM_EV_FLT_ANA, s);
|
||||||
list_for_each_entry(filter, &strm_flt(s)->filters, list) {
|
list_for_each_entry(filter, &strm_flt(s)->filters, list) {
|
||||||
@ -873,14 +878,19 @@ flt_tcp_payload(struct stream *s, struct channel *chn, unsigned int len)
|
|||||||
unsigned int offset = *flt_off - *strm_off;
|
unsigned int offset = *flt_off - *strm_off;
|
||||||
|
|
||||||
DBG_TRACE_DEVEL(FLT_ID(filter), STRM_EV_TCP_ANA|STRM_EV_FLT_ANA, s);
|
DBG_TRACE_DEVEL(FLT_ID(filter), STRM_EV_TCP_ANA|STRM_EV_FLT_ANA, s);
|
||||||
ret = FLT_OPS(filter)->tcp_payload(s, filter, chn, out + offset, ret - offset);
|
ret = FLT_OPS(filter)->tcp_payload(s, filter, chn, out + offset, data - offset);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
*flt_off += ret;
|
*flt_off += ret;
|
||||||
ret += offset;
|
data = ret + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*strm_off += ret;
|
|
||||||
|
/* Only forward data if the last filter decides to forward something */
|
||||||
|
if (ret > 0) {
|
||||||
|
ret = data;
|
||||||
|
*strm_off += ret;
|
||||||
|
}
|
||||||
end:
|
end:
|
||||||
DBG_TRACE_LEAVE(STRM_EV_TCP_ANA|STRM_EV_FLT_ANA, s);
|
DBG_TRACE_LEAVE(STRM_EV_TCP_ANA|STRM_EV_FLT_ANA, s);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user