From 75a98f8ecc69b947639874ff9799cef15f81a183 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 4 May 2014 17:25:32 +0800 Subject: [PATCH] clean up --- src/local.c | 26 ++++++++++++++------------ src/server.c | 17 +++++++++-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/local.c b/src/local.c index 60a87e47..76411b47 100644 --- a/src/local.c +++ b/src/local.c @@ -616,7 +616,7 @@ static void remote_send_cb (EV_P_ ev_io *w, int revents) else { // not connected - ERROR("getpeername"); + ERROR("fast_open_getpeername"); close_and_free_remote(EV_A_ remote); close_and_free_server(EV_A_ server); return; @@ -628,7 +628,7 @@ static void remote_send_cb (EV_P_ ev_io *w, int revents) struct sockaddr_storage addr; socklen_t len = sizeof addr; int r = getpeername(remote->fd, (struct sockaddr*)&addr, &len); - if (r == 0) + if (r == 0) { remote_send_ctx->connected = 1; ev_io_stop(EV_A_ &remote_send_ctx->io); @@ -851,7 +851,7 @@ static void accept_cb (EV_P_ ev_io *w, int revents) if (verbose) { LOGD("connect to %s:%s", listener->remote_addr[index].host, - listener->remote_addr[index].port); + listener->remote_addr[index].port); } int err = getaddrinfo(listener->remote_addr[index].host, listener->remote_addr[index].port, @@ -886,7 +886,8 @@ static void accept_cb (EV_P_ ev_io *w, int revents) struct remote *remote = new_remote(sockfd, listener->timeout); server->remote = remote; remote->server = server; - if (!fast_open) { + if (!fast_open) + { connect(sockfd, remote_res->ai_addr, remote_res->ai_addrlen); // listen to remote connected event ev_io_start(EV_A_ &remote->send_ctx->io); @@ -919,7 +920,8 @@ int main (int argc, char **argv) char *remote_port = NULL; int option_index = 0; - static struct option long_options[] = { + static struct option long_options[] = + { {"fast-open", no_argument, 0, 0 }, {0, 0, 0, 0 } }; @@ -932,16 +934,16 @@ int main (int argc, char **argv) switch (c) { case 0: - if (option_index == 0) - { + if (option_index == 0) + { #ifdef TCP_FASTOPEN - fast_open = 1; - LOGD("using tcp fast open"); + fast_open = 1; + LOGD("using tcp fast open"); #else - LOGE("tcp fast open is not supported by this environment"); + LOGE("tcp fast open is not supported by this environment"); #endif - } - break; + } + break; case 's': remote_addr[remote_num].host = optarg; remote_addr[remote_num++].port = NULL; diff --git a/src/server.c b/src/server.c index 8dbe103a..2597f8e0 100644 --- a/src/server.c +++ b/src/server.c @@ -938,7 +938,8 @@ int main (int argc, char **argv) int dns_thread_num = DNS_THREAD_NUM; int option_index = 0; - static struct option long_options[] = { + static struct option long_options[] = + { {"fast-open", no_argument, 0, 0 }, {0, 0, 0, 0 } }; @@ -951,16 +952,16 @@ int main (int argc, char **argv) switch (c) { case 0: - if (option_index == 0) - { + if (option_index == 0) + { #ifdef TCP_FASTOPEN - fast_open = 1; - LOGD("using tcp fast open"); + fast_open = 1; + LOGD("using tcp fast open"); #else - LOGE("tcp fast open is not supported by this environment"); + LOGE("tcp fast open is not supported by this environment"); #endif - } - break; + } + break; case 's': server_host[server_num++] = optarg; break;