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);