Adjust evbuffer max read for bufferevents

This commit is contained in:
Azat Khuzhin 2019-03-16 17:32:17 +03:00
parent 8c2001e92a
commit 5357c3d62a
No known key found for this signature in database
GPG Key ID: B86086848EF8686D
2 changed files with 8 additions and 1 deletions

View File

@ -855,14 +855,16 @@ int
bufferevent_set_max_single_read(struct bufferevent *bev, size_t size)
{
struct bufferevent_private *bevp;
int ret = 0;
BEV_LOCK(bev);
bevp = BEV_UPCAST(bev);
if (size == 0 || size > EV_SSIZE_MAX)
bevp->max_single_read = MAX_SINGLE_READ_DEFAULT;
else
bevp->max_single_read = size;
ret = evbuffer_set_max_read(bev->input, bevp->max_single_read);
BEV_UNLOCK(bev);
return 0;
return ret;
}
int
@ -1085,5 +1087,8 @@ bufferevent_ratelim_init_(struct bufferevent_private *bev)
bev->max_single_read = MAX_SINGLE_READ_DEFAULT;
bev->max_single_write = MAX_SINGLE_WRITE_DEFAULT;
if (evbuffer_set_max_read(bev->bev.input, bev->max_single_read))
return -1;
return 0;
}

View File

@ -890,6 +890,8 @@ int bufferevent_remove_from_rate_limit_group(struct bufferevent *bev);
Set to 0 for a reasonable default.
Return 0 on success and -1 on failure.
@see evbuffer_set_max_read()
*/
EVENT2_EXPORT_SYMBOL
int bufferevent_set_max_single_read(struct bufferevent *bev, size_t size);