MINOR: filters: Remove unused or useless stuff and do small optimizations
This commit is contained in:
parent
da02e17d42
commit
3e7bc67722
@ -34,6 +34,10 @@
|
|||||||
#define CHN_IDX(chn) (((chn)->flags & CF_ISRESP) == CF_ISRESP)
|
#define CHN_IDX(chn) (((chn)->flags & CF_ISRESP) == CF_ISRESP)
|
||||||
#define FLT_NXT(flt, chn) ((flt)->next[CHN_IDX(chn)])
|
#define FLT_NXT(flt, chn) ((flt)->next[CHN_IDX(chn)])
|
||||||
#define FLT_FWD(flt, chn) ((flt)->fwd[CHN_IDX(chn)])
|
#define FLT_FWD(flt, chn) ((flt)->fwd[CHN_IDX(chn)])
|
||||||
|
#define flt_req_nxt(flt) ((flt)->next[0])
|
||||||
|
#define flt_rsp_nxt(flt) ((flt)->next[1])
|
||||||
|
#define flt_req_fwd(flt) ((flt)->fwd[0])
|
||||||
|
#define flt_rsp_fwd(flt) ((flt)->fwd[1])
|
||||||
|
|
||||||
#define HAS_FILTERS(strm) ((strm)->strm_flt.flags & STRM_FLT_FL_HAS_FILTERS)
|
#define HAS_FILTERS(strm) ((strm)->strm_flt.flags & STRM_FLT_FL_HAS_FILTERS)
|
||||||
|
|
||||||
@ -181,7 +185,8 @@ flt_change_next_size(struct filter *filter, struct channel *chn, int len)
|
|||||||
list_for_each_entry(f, &strm_flt(s)->filters, list) {
|
list_for_each_entry(f, &strm_flt(s)->filters, list) {
|
||||||
if (f == filter)
|
if (f == filter)
|
||||||
break;
|
break;
|
||||||
FLT_NXT(f, chn) += len;
|
if (IS_DATA_FILTER(filter, chn))
|
||||||
|
FLT_NXT(f, chn) += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,9 +210,11 @@ flt_change_forward_size(struct filter *filter, struct channel *chn, int len)
|
|||||||
list_for_each_entry(f, &strm_flt(s)->filters, list) {
|
list_for_each_entry(f, &strm_flt(s)->filters, list) {
|
||||||
if (f == filter)
|
if (f == filter)
|
||||||
before = 0;
|
before = 0;
|
||||||
if (before)
|
if (IS_DATA_FILTER(filter, chn)) {
|
||||||
FLT_FWD(f, chn) += len;
|
if (before)
|
||||||
FLT_NXT(f, chn) += len;
|
FLT_FWD(f, chn) += len;
|
||||||
|
FLT_NXT(f, chn) += len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,17 +55,6 @@ struct flt_kw_list {
|
|||||||
struct flt_kw kw[VAR_ARRAY];
|
struct flt_kw kw[VAR_ARRAY];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Filter flags set for a specific filter on channel
|
|
||||||
*
|
|
||||||
* - FILTER_FL_FORWARD_DATA : When this flag is set, the rest of the data is
|
|
||||||
* directly forwarded. For chunk-encoded HTTP
|
|
||||||
* messages, this flag is reseted between each
|
|
||||||
* chunks.
|
|
||||||
*/
|
|
||||||
#define FILTER_FL_FORWARD_DATA 0x00000001
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callbacks available on a filter:
|
* Callbacks available on a filter:
|
||||||
*
|
*
|
||||||
|
@ -154,35 +154,36 @@ static int
|
|||||||
comp_http_data(struct stream *s, struct filter *filter, struct http_msg *msg)
|
comp_http_data(struct stream *s, struct filter *filter, struct http_msg *msg)
|
||||||
{
|
{
|
||||||
struct comp_state *st = filter->ctx;
|
struct comp_state *st = filter->ctx;
|
||||||
|
struct buffer *buf = msg->chn->buf;
|
||||||
|
unsigned int *nxt = &flt_rsp_nxt(filter);
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!(msg->chn->flags & CF_ISRESP) || !st->comp_algo)
|
len = MIN(msg->chunk_len + msg->next, buf->i) - *nxt;
|
||||||
return 1;
|
|
||||||
|
|
||||||
len = MIN(msg->chunk_len + msg->next, msg->chn->buf->i) - FLT_NXT(filter, msg->chn);
|
|
||||||
if (!len)
|
if (!len)
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
if (!st->initialized) {
|
if (!st->initialized) {
|
||||||
b_adv(msg->chn->buf, FLT_FWD(filter, msg->chn) + st->sov);
|
unsigned int fwd = flt_rsp_fwd(filter) + st->sov;
|
||||||
ret = http_compression_buffer_init(msg->chn->buf, tmpbuf);
|
|
||||||
b_rew(msg->chn->buf, FLT_FWD(filter, msg->chn) + st->sov);
|
b_adv(buf, fwd);
|
||||||
|
ret = http_compression_buffer_init(buf, tmpbuf);
|
||||||
|
b_rew(buf, fwd);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
msg->chn->flags |= CF_WAKE_WRITE;
|
msg->chn->flags |= CF_WAKE_WRITE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b_adv(msg->chn->buf, FLT_NXT(filter, msg->chn));
|
b_adv(buf, *nxt);
|
||||||
ret = http_compression_buffer_add_data(st, msg->chn->buf, tmpbuf, len);
|
ret = http_compression_buffer_add_data(st, buf, tmpbuf, len);
|
||||||
b_rew(msg->chn->buf, FLT_NXT(filter, msg->chn));
|
b_rew(buf, *nxt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
st->initialized = 1;
|
st->initialized = 1;
|
||||||
msg->next += ret;
|
msg->next += ret;
|
||||||
msg->chunk_len -= ret;
|
msg->chunk_len -= ret;
|
||||||
FLT_NXT(filter, msg->chn) = msg->next;
|
*nxt = msg->next;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,15 +542,13 @@ http_compression_buffer_add_data(struct comp_state *st, struct buffer *in,
|
|||||||
int block1, block2;
|
int block1, block2;
|
||||||
|
|
||||||
if (!sz)
|
if (!sz)
|
||||||
return 0;
|
goto end;
|
||||||
|
|
||||||
/* select the smallest size between the announced chunk size, the input
|
/* select the smallest size between the announced chunk size, the input
|
||||||
* data, and the available output buffer size. The compressors are
|
* data, and the available output buffer size. The compressors are
|
||||||
* assumed to be able to process all the bytes we pass to them at
|
* assumed to be able to process all the bytes we pass to them at
|
||||||
* once. */
|
* once. */
|
||||||
data_process_len = sz;
|
data_process_len = MIN(out->size - buffer_len(out), sz);
|
||||||
data_process_len = MIN(out->size - buffer_len(out), data_process_len);
|
|
||||||
|
|
||||||
|
|
||||||
block1 = data_process_len;
|
block1 = data_process_len;
|
||||||
if (block1 > bi_contig_data(in))
|
if (block1 > bi_contig_data(in))
|
||||||
@ -558,11 +557,14 @@ http_compression_buffer_add_data(struct comp_state *st, struct buffer *in,
|
|||||||
|
|
||||||
/* compressors return < 0 upon error or the amount of bytes read */
|
/* compressors return < 0 upon error or the amount of bytes read */
|
||||||
consumed_data = st->comp_algo->add_data(st->comp_ctx, bi_ptr(in), block1, out);
|
consumed_data = st->comp_algo->add_data(st->comp_ctx, bi_ptr(in), block1, out);
|
||||||
if (consumed_data >= 0 && block2 > 0) {
|
if (consumed_data != block1 || !block2)
|
||||||
consumed_data = st->comp_algo->add_data(st->comp_ctx, in->data, block2, out);
|
goto end;
|
||||||
if (consumed_data >= 0)
|
consumed_data = st->comp_algo->add_data(st->comp_ctx, in->data, block2, out);
|
||||||
consumed_data += block1;
|
if (consumed_data < 0)
|
||||||
}
|
goto end;
|
||||||
|
consumed_data += block1;
|
||||||
|
|
||||||
|
end:
|
||||||
return consumed_data;
|
return consumed_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user