Browse Source

refine timeout

pull/196/merge
Max Lv 10 years ago
parent
commit
888c2438c3
6 changed files with 7 additions and 6 deletions
  1. 1
      src/jconf.h
  2. 4
      src/local.c
  3. 2
      src/redir.c
  4. 2
      src/server.c
  5. 2
      src/tunnel.c
  6. 2
      src/udprelay.c

1
src/jconf.h

@ -25,6 +25,7 @@
#define MAX_REMOTE_NUM 10 #define MAX_REMOTE_NUM 10
#define MAX_CONF_SIZE 16 * 1024 #define MAX_CONF_SIZE 16 * 1024
#define DNS_THREAD_NUM 4 #define DNS_THREAD_NUM 4
#define MAX_CONNECT_TIMEOUT 10
typedef struct { typedef struct {
char *host; char *host;

4
src/local.c

@ -688,9 +688,9 @@ static struct remote * new_remote(int fd, int timeout)
remote->fd = fd; remote->fd = fd;
ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ); ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE); ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(5,
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT,
timeout), 0); timeout), 0);
ev_timer_init(&remote->recv_ctx->watcher, remote_timeout_cb, min(10,
ev_timer_init(&remote->recv_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT,
timeout), timeout); timeout), timeout);
remote->recv_ctx->remote = remote; remote->recv_ctx->remote = remote;
remote->send_ctx->remote = remote; remote->send_ctx->remote = remote;

2
src/redir.c

@ -471,7 +471,7 @@ static struct remote * new_remote(int fd, int timeout)
remote->fd = fd; remote->fd = fd;
ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ); ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE); ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(5, timeout), 0);
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT, timeout), 0);
remote->recv_ctx->remote = remote; remote->recv_ctx->remote = remote;
remote->recv_ctx->connected = 0; remote->recv_ctx->connected = 0;
remote->send_ctx->remote = remote; remote->send_ctx->remote = remote;

2
src/server.c

@ -803,7 +803,7 @@ static struct server * new_server(int fd, struct listen_ctx *listener)
ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ); ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ);
ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE); ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE);
ev_timer_init(&server->recv_ctx->watcher, server_timeout_cb, ev_timer_init(&server->recv_ctx->watcher, server_timeout_cb,
min(10, listener->timeout), listener->timeout);
min(MAX_CONNECT_TIMEOUT, listener->timeout), listener->timeout);
server->recv_ctx->server = server; server->recv_ctx->server = server;
server->recv_ctx->connected = 0; server->recv_ctx->connected = 0;
server->send_ctx->server = server; server->send_ctx->server = server;

2
src/tunnel.c

@ -466,7 +466,7 @@ static struct remote * new_remote(int fd, int timeout)
remote->fd = fd; remote->fd = fd;
ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ); ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE); ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(5,
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb, min(MAX_CONNECT_TIMEOUT,
timeout), 0); timeout), 0);
remote->recv_ctx->remote = remote; remote->recv_ctx->remote = remote;
remote->recv_ctx->connected = 0; remote->recv_ctx->connected = 0;

2
src/udprelay.c

@ -914,7 +914,7 @@ int init_udprelay(const char *server_host, const char *server_port,
setnonblocking(serverfd); setnonblocking(serverfd);
server_ctx = new_server_ctx(serverfd); server_ctx = new_server_ctx(serverfd);
server_ctx->timeout = min(timeout, 5);
server_ctx->timeout = min(timeout, MAX_CONNECT_TIMEOUT);
server_ctx->method = method; server_ctx->method = method;
server_ctx->iface = iface; server_ctx->iface = iface;
server_ctx->conn_cache = conn_cache; server_ctx->conn_cache = conn_cache;

Loading…
Cancel
Save