From e2f34732c2ee1dd461ea3f4f76c2ad024cf82744 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 5 Jan 2014 16:21:21 +0900 Subject: [PATCH] force to Werror --- src/Makefile.am | 2 +- src/Makefile.in | 4 ++-- src/include.h | 2 +- src/udprelay.c | 23 ++++++++++++++--------- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 915210e9..bda7c4d4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = -g -O2 -Wall -fno-strict-aliasing +AM_CFLAGS = -g -O2 -Wall -Wno-deprecated -Werror -fno-strict-aliasing AM_CFLAGS += -I$(top_builddir)/libev AM_CFLAGS += -I$(top_builddir)/libasyncns diff --git a/src/Makefile.in b/src/Makefile.in index d9e6b04a..6062cb31 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -248,8 +248,8 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CFLAGS = -g -O2 -Wall -fno-strict-aliasing -I$(top_builddir)/libev \ - -I$(top_builddir)/libasyncns +AM_CFLAGS = -g -O2 -Wall -Wno-deprecated -Werror -fno-strict-aliasing \ + -I$(top_builddir)/libev -I$(top_builddir)/libasyncns AM_LDFLAGS = -static SS_COMMON_LIBS = $(top_builddir)/libev/libev.la $(INET_NTOP_LIB) ss_local_SOURCES = utils.c jconf.c json.c encrypt.c udprelay.c cache.c \ diff --git a/src/include.h b/src/include.h index 51387efd..5c9089bf 100644 --- a/src/include.h +++ b/src/include.h @@ -8,6 +8,6 @@ int udprelay_init(const char *server_host, const char *server_port, #ifdef UDPRELAY_REMOTE asyncns_t *asyncns, #endif - int method, int timeout, const char *interface_name); + int method, int timeout, const char *interface); #endif // _INCLUDE_H diff --git a/src/udprelay.c b/src/udprelay.c index d6b17eb7..0d5783ee 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -52,7 +52,6 @@ #define BUF_SIZE MAX_UDP_PACKET_SIZE extern int verbose; -static const char *iface; #ifndef __MINGW32__ static int setnonblocking(int fd) @@ -379,17 +378,17 @@ static void query_resolve_cb(EV_P_ ev_timer *watcher, int revents) rp = result; } - int opt = 1; - int remotefd = create_remote_socket(rp->ai_family == AF_INET6); if (remotefd != -1) { setnonblocking(remotefd); #ifdef SO_NOSIGPIPE + int opt = 1; setsockopt(remotefd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt)); #endif #ifdef SET_INTERFACE - if (iface) setinterface(remotefd, iface); + if (query_ctx->server_ctx->iface) + setinterface(remotefd, query_ctx->server_ctx->iface); #endif struct remote_ctx *remote_ctx = new_remote(remotefd, query_ctx->server_ctx); @@ -653,6 +652,15 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) } setnonblocking(remotefd); +#ifdef SO_NOSIGPIPE + int opt = 1; + setsockopt(remotefd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt)); +#endif +#ifdef SET_INTERFACE + if (server_ctx->iface) + setinterface(remotefd, server_ctx->iface); +#endif + // Init remote_ctx remote_ctx = new_remote(remotefd, server_ctx); remote_ctx->src_addr = src_addr; @@ -749,12 +757,9 @@ int udprelay_init(const char *server_host, const char *server_port, #ifdef UDPRELAY_REMOTE asyncns_t *asyncns, #endif - int method, int timeout, const char *interface_name) + int method, int timeout, const char *interface) { - - iface = interface_name; - // Inilitialize ev loop struct ev_loop *loop = EV_DEFAULT; @@ -776,7 +781,7 @@ int udprelay_init(const char *server_host, const char *server_port, struct server_ctx *server_ctx = new_server_ctx(serverfd); server_ctx->timeout = timeout; server_ctx->method = method; - server_ctx->iface = iface; + server_ctx->iface = interface; server_ctx->conn_cache = conn_cache; #ifdef UDPRELAY_LOCAL server_ctx->remote_host = remote_host;