avoid protect socket every time

This commit is contained in:
Max Lv
2015-07-31 18:50:30 +08:00
parent 7260153439
commit aaf7284234
2 changed files with 11 additions and 10 deletions
-1
View File
@@ -616,7 +616,6 @@ static void accept_cb(EV_P_ ev_io *w, int revents)
}
#endif
setsockopt(remotefd, SOL_TCP, TCP_NODELAY, &opt, sizeof(opt));
#ifdef SO_NOSIGPIPE
setsockopt(remotefd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
+11 -9
View File
@@ -1042,6 +1042,16 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
}
#endif
#ifdef ANDROID
if (vpn) {
if (protect_socket(remotefd) == -1) {
ERROR("protect_socket");
close(remotefd);
goto CLEAN_UP;
}
}
#endif
// Init remote_ctx
remote_ctx = new_remote(remotefd, server_ctx);
remote_ctx->src_addr = src_addr;
@@ -1055,6 +1065,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
// Start remote io
ev_io_start(EV_A_ & remote_ctx->io);
ev_timer_start(EV_A_ & remote_ctx->watcher);
}
if (offset > 0) {
@@ -1064,15 +1075,6 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
buf = ss_encrypt_all(BUF_SIZE, buf, &buf_len, server_ctx->method);
#ifdef ANDROID
if (vpn) {
if (protect_socket(remote_ctx->fd) == -1) {
ERROR("protect_socket");
close_and_free_remote(EV_A_ remote_ctx);
goto CLEAN_UP;
}
}
#endif
int s = sendto(remote_ctx->fd, buf, buf_len, 0, remote_addr, remote_addr_len);
if (s == -1) {