mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 20:41:27 -04:00
Move SSL rate-limit enforcement into bytes_to_read()
This commit is contained in:
parent
a186e73200
commit
96c562fa49
@ -711,6 +711,10 @@ bytes_to_read(struct bufferevent_openssl *bev)
|
|||||||
{
|
{
|
||||||
struct evbuffer *input = bev->bev.bev.input;
|
struct evbuffer *input = bev->bev.bev.input;
|
||||||
struct event_watermark *wm = &bev->bev.bev.wm_read;
|
struct event_watermark *wm = &bev->bev.bev.wm_read;
|
||||||
|
int result = READ_DEFAULT;
|
||||||
|
ev_ssize_t limit;
|
||||||
|
/* XXX 99% of this is generic code that nearly all bufferevents will
|
||||||
|
* want. */
|
||||||
|
|
||||||
if (bev->write_blocked_on_read) {
|
if (bev->write_blocked_on_read) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -729,10 +733,18 @@ bytes_to_read(struct bufferevent_openssl *bev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wm->high - evbuffer_get_length(input);
|
result = wm->high - evbuffer_get_length(input);
|
||||||
|
} else {
|
||||||
|
result = READ_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return READ_DEFAULT;
|
/* Respect the rate limit */
|
||||||
|
limit = _bufferevent_get_read_max(&bev->bev);
|
||||||
|
if (result > limit) {
|
||||||
|
result = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user