mirror of
https://github.com/darkk/redsocks.git
synced 2025-08-30 05:35:30 +00:00
Replace wm_read/wm_write manipulations with call to bufferevent_setwatermark
bufferevent_setwatermark() has some meaningful code to run on high-watermark changes, avoiding this code may lead to stuck connections.
This commit is contained in:
parent
d2165a4ff0
commit
afd298f6ce
@ -357,8 +357,7 @@ static void httpr_relay_write_cb(struct bufferevent *buffev, void *_arg)
|
||||
|
||||
client->state = httpr_request_sent;
|
||||
|
||||
buffev->wm_read.low = 1;
|
||||
buffev->wm_read.high = HTTP_HEAD_WM_HIGH;
|
||||
bufferevent_setwatermark(buffev, EV_READ, 1, HTTP_HEAD_WM_HIGH);
|
||||
bufferevent_enable(buffev, EV_READ);
|
||||
}
|
||||
}
|
||||
|
15
redsocks.c
15
redsocks.c
@ -318,14 +318,10 @@ void redsocks_start_relay(redsocks_client *client)
|
||||
|
||||
client->state = pump_active;
|
||||
|
||||
client->relay->wm_read.low = 0;
|
||||
client->relay->wm_write.low = 0;
|
||||
client->client->wm_read.low = 0;
|
||||
client->client->wm_write.low = 0;
|
||||
client->relay->wm_read.high = REDSOCKS_RELAY_HALFBUFF;
|
||||
client->relay->wm_write.high = REDSOCKS_RELAY_HALFBUFF;
|
||||
client->client->wm_read.high = REDSOCKS_RELAY_HALFBUFF;
|
||||
client->client->wm_write.high = REDSOCKS_RELAY_HALFBUFF;
|
||||
// wm_write.high is respected by libevent-2.0.22 only for ssl and filters,
|
||||
// so it's implemented in redsocks callbacks. wm_read.high works as expected.
|
||||
bufferevent_setwatermark(client->client, EV_READ|EV_WRITE, 0, REDSOCKS_RELAY_HALFBUFF);
|
||||
bufferevent_setwatermark(client->relay, EV_READ|EV_WRITE, 0, REDSOCKS_RELAY_HALFBUFF);
|
||||
|
||||
client->client->readcb = redsocks_relay_clientreadcb;
|
||||
client->client->writecb = redsocks_relay_clientwritecb;
|
||||
@ -548,8 +544,7 @@ int redsocks_write_helper_ex_plain(
|
||||
|
||||
if (client)
|
||||
client->state = state;
|
||||
buffev->wm_read.low = wm_low;
|
||||
buffev->wm_read.high = wm_high;
|
||||
bufferevent_setwatermark(buffev, EV_READ, wm_low, wm_high);
|
||||
bufferevent_enable(buffev, EV_READ);
|
||||
drop = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user