Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gwproxy/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static void process_queue_entry(struct gwp_dns_ctx *ctx)
* clone() for each entry if we can process them in the current
* thread.
*/
if ((ctx->nr_entries + 16) > ctx->nr_sleeping)
if (ctx->nr_entries > (ctx->nr_sleeping + 16))
process_queue_entry_batch(ctx);
else
process_queue_entry_single(ctx);
Expand Down
18 changes: 10 additions & 8 deletions src/gwproxy/gwproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2789,11 +2789,10 @@ static int handle_socks5_data(struct gwp_wrk *w, struct gwp_conn_pair *gcp)
out = gcp->target.buf + gcp->target.len;
out_len = gcp->target.cap - gcp->target.len;
r = gwp_socks5_conn_handle_data(sc, in, &in_len, out, &out_len);
if (r)
return (r == -EAGAIN) ? 0 : r;

gwp_conn_buf_advance(&gcp->client, in_len);
gcp->target.len += out_len;
if (r)
return (r == -EAGAIN) ? 0 : r;

if (sc->state == GWP_SOCKS5_ST_CMD_CONNECT) {
r = socks5_prepare_target_addr(w, gcp);
Expand Down Expand Up @@ -2839,12 +2838,15 @@ static int handle_ev_client_socks5(struct gwp_wrk *w,
return sr;
}

r = handle_socks5_data(w, gcp);
if (gcp->target.len) {
r = handle_socks5_pollout(w, gcp);
if (r && r != -EAGAIN)
return r;
if (gcp->conn_state == CONN_STATE_SOCKS5_DATA) {
r = handle_socks5_data(w, gcp);
if (gcp->target.len) {
r = handle_socks5_pollout(w, gcp);
if (r && r != -EAGAIN)
return r;
}
}

return r;
}

Expand Down
4 changes: 4 additions & 0 deletions src/gwproxy/socks5.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,9 @@ int gwp_socks5_conn_handle_data(struct gwp_socks5_conn *conn,
case GWP_SOCKS5_ST_CMD:
r = handle_state_cmd(&arg);
break;
case GWP_SOCKS5_ST_CMD_CONNECT:
r = 0;
goto out;
default:
return -EINVAL;
}
Expand All @@ -900,6 +903,7 @@ int gwp_socks5_conn_handle_data(struct gwp_socks5_conn *conn,
if (r && r != -EAGAIN && r != -ENOBUFS)
conn->state = GWP_SOCKS5_ST_ERR;

out:
if (r == -ENOBUFS) {
/*
* If we run out of output buffer space, don't change
Expand Down