Skip to content

Commit

Permalink
Fix #1008
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Dec 27, 2016
1 parent 8e52029 commit 32f52da
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
10 changes: 7 additions & 3 deletions src/local.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
ERROR("remote_recv_cb_send");
close_and_free_remote(EV_A_ remote);
close_and_free_server(EV_A_ server);
return;
}
} else if (s < (int)(server->buf->len)) {
server->buf->len -= s;
Expand All @@ -865,9 +866,12 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
}

// Disable TCP_NODELAY after the first response are sent
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
if (!remote->recv_ctx->connected) {
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
remote->recv_ctx->connected = 1;
}
}

static void
Expand Down
10 changes: 7 additions & 3 deletions src/redir.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
ERROR("send");
close_and_free_remote(EV_A_ remote);
close_and_free_server(EV_A_ server);
return;
}
} else if (s < server->buf->len) {
server->buf->len -= s;
Expand All @@ -401,9 +402,12 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
}

// Disable TCP_NODELAY after the first response are sent
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
if (!remote->recv_ctx->connected) {
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
remote->recv_ctx->connected = 1;
}
}

static void
Expand Down
10 changes: 7 additions & 3 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
ERROR("remote_recv_send");
close_and_free_remote(EV_A_ remote);
close_and_free_server(EV_A_ server);
return;
}
} else if (s < server->buf->len) {
server->buf->len -= s;
Expand All @@ -1209,9 +1210,12 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
}

// Disable TCP_NODELAY after the first response are sent
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
if (!remote->recv_ctx->connected) {
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
remote->recv_ctx->connected = 1;
}
}

static void
Expand Down
12 changes: 8 additions & 4 deletions src/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
ERROR("send");
close_and_free_remote(EV_A_ remote);
close_and_free_server(EV_A_ server);
return;
}
} else if (s < server->buf->len) {
server->buf->len -= s;
Expand All @@ -358,10 +359,13 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
ev_io_start(EV_A_ & server->send_ctx->io);
}

// Disable TCP_NODELAY after the first response are sent
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
if (!remote->recv_ctx->connected) {
// Disable TCP_NODELAY after the first response are sent
int opt = 0;
setsockopt(server->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
setsockopt(remote->fd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
remote->recv_ctx->connected = 1;
}
}

static void
Expand Down

0 comments on commit 32f52da

Please sign in to comment.