From 5d0c839324c510c976059e58f98199d4bc1d9842 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 12 Jan 2013 22:01:08 +0800 Subject: [PATCH] ignore all SIGPIPE --- local.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/local.c b/local.c index f6a9528d..c0ee5c95 100755 --- a/local.c +++ b/local.c @@ -25,10 +25,6 @@ #include "config.h" #endif -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL SO_NOSIGPIPE -#endif - #ifndef EAGAIN #define EAGAIN EWOULDBLOCK #endif @@ -170,7 +166,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { response.ver = SVERSION; response.method = 0; char *send_buf = (char *)&response; - send(server->fd, send_buf, sizeof(response), MSG_NOSIGNAL); + send(server->fd, send_buf, sizeof(response), 0); server->stage = 1; return; } else if (server->stage == 1) { @@ -184,7 +180,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { response.rsv = 0; response.atyp = 1; char *send_buf = (char *)&response; - send(server->fd, send_buf, 4, MSG_NOSIGNAL); + send(server->fd, send_buf, 4, 0); close_and_free_remote(EV_A_ remote); close_and_free_server(EV_A_ server); return; @@ -238,7 +234,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { = (unsigned short) htons(atoi(_remote_port)); int reply_size = 4 + sizeof(struct in_addr) + sizeof(unsigned short); - int r = send(server->fd, server->buf, reply_size, MSG_NOSIGNAL); + int r = send(server->fd, server->buf, reply_size, 0); if (r < reply_size) { LOGE("header not complete sent\n"); close_and_free_remote(EV_A_ remote); @@ -346,7 +342,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { } } decrypt_ctx(server->buf, r, server->d_ctx); - int w = send(server->fd, server->buf, r, MSG_NOSIGNAL); + int w = send(server->fd, server->buf, r, 0); if(w == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { // no data, wait for send @@ -693,6 +689,8 @@ int main (int argc, char **argv) close(STDERR_FILENO); } + signal(SIGPIPE, SIG_IGN); + // init global variables _server = strdup(server); _remote_port = strdup(remote_port);