On Tue, Dec 9, 2014 at 11:03 PM, Yann Ylavic <[email protected]> wrote:
> On Tue, Dec 9, 2014 at 10:56 PM, Yann Ylavic <[email protected]> wrote:
>> +static apr_status_t crypto_in_filter(ap_filter_t *f, apr_bucket_brigade *bb,
>> + ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
>> +{
> []
>> + /* if our buffer is empty, read off the network until the buffer is
>> full */
>> + if (APR_BRIGADE_EMPTY(ctx->bb)) {
> []
>> + while (!ctx->seen_eos && ctx->remaining > 0) {
>> + const char *data;
>> + apr_size_t size = 0;
>> +
>
> Also I think we should :
> apr_brigade_cleanup(ctx->tmp);
> here.
Hmm, no, this one seems not necessary.
>
>> + rv = ap_get_brigade(f->next, ctx->tmp, mode, block,
>> ctx->remaining);
>> +
But if you want to keep the following apr_bucket_read() nonblocking,
you could do :
if (APR_BRIGADE_EMPTY(ctx->tmp) {
rv = ap_get_brigade(f->next, ctx->tmp, mode, block, ctx->remaining);
}
and then below :
rv = apr_bucket_read(e, &data, &size, block);
if (APR_STATUS_IS_EAGAIN(rv)) {
if (APR_BRIGADE_EMPTY(ctx->bb) {
return rv;
}
break:
}
if (APR_SUCCESS != rv) {
return rv;
}
do_crypto(f, (unsigned char *) data, size, 0);
...