0
0
mirror of https://github.com/darkk/redsocks.git synced 2025-08-30 13:45: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:
Leonid Evdokimov 2016-03-18 11:00:29 +03:00
parent d2165a4ff0
commit afd298f6ce
2 changed files with 6 additions and 12 deletions

View File

@ -357,8 +357,7 @@ static void httpr_relay_write_cb(struct bufferevent *buffev, void *_arg)
client->state = httpr_request_sent; client->state = httpr_request_sent;
buffev->wm_read.low = 1; bufferevent_setwatermark(buffev, EV_READ, 1, HTTP_HEAD_WM_HIGH);
buffev->wm_read.high = HTTP_HEAD_WM_HIGH;
bufferevent_enable(buffev, EV_READ); bufferevent_enable(buffev, EV_READ);
} }
} }

View File

@ -318,14 +318,10 @@ void redsocks_start_relay(redsocks_client *client)
client->state = pump_active; client->state = pump_active;
client->relay->wm_read.low = 0; // wm_write.high is respected by libevent-2.0.22 only for ssl and filters,
client->relay->wm_write.low = 0; // so it's implemented in redsocks callbacks. wm_read.high works as expected.
client->client->wm_read.low = 0; bufferevent_setwatermark(client->client, EV_READ|EV_WRITE, 0, REDSOCKS_RELAY_HALFBUFF);
client->client->wm_write.low = 0; bufferevent_setwatermark(client->relay, EV_READ|EV_WRITE, 0, REDSOCKS_RELAY_HALFBUFF);
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;
client->client->readcb = redsocks_relay_clientreadcb; client->client->readcb = redsocks_relay_clientreadcb;
client->client->writecb = redsocks_relay_clientwritecb; client->client->writecb = redsocks_relay_clientwritecb;
@ -548,8 +544,7 @@ int redsocks_write_helper_ex_plain(
if (client) if (client)
client->state = state; client->state = state;
buffev->wm_read.low = wm_low; bufferevent_setwatermark(buffev, EV_READ, wm_low, wm_high);
buffev->wm_read.high = wm_high;
bufferevent_enable(buffev, EV_READ); bufferevent_enable(buffev, EV_READ);
drop = 0; drop = 0;