Skip to content

Commit

Permalink
evcom upgrade - ignore sigpipe. remove error output.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 22, 2009
1 parent a73998d commit a8813fc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions deps/evcom/evcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <errno.h>
#include <string.h> /* memset */

#include <signal.h>

#include <netinet/tcp.h> /* TCP_NODELAY */
#include <sys/types.h>
#include <sys/socket.h> /* shutdown */
Expand Down Expand Up @@ -135,6 +137,14 @@ evcom_buf_new (const char *base, size_t len)
return buf;
}

void evcom_ignore_sigpipe (void)
{
struct sigaction sa;
bzero(&sa, sizeof(sa));
sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, NULL);
}

static int
close_asap (evcom_descriptor *d)
{
Expand Down
3 changes: 3 additions & 0 deletions deps/evcom/evcom.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ typedef struct evcom_server {
(*on_connection)(struct evcom_server *, struct sockaddr *remote_addr);
} evcom_server;

/* Highly recommended to ignore SIGPIPE! */
void evcom_ignore_sigpipe (void);

void evcom_reader_init (evcom_reader*);
void evcom_reader_set (evcom_reader*, int fd);
void evcom_reader_attach (EV_P_ evcom_reader*);
Expand Down
2 changes: 2 additions & 0 deletions deps/evcom/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,8 @@ main (void)
fprintf(stderr, "sizeof(evcom_reader): %d\n", (int)sizeof(evcom_reader));
fprintf(stderr, "sizeof(evcom_writer): %d\n", (int)sizeof(evcom_writer));

evcom_ignore_sigpipe();

#if EVCOM_HAVE_GNUTLS
gnutls_global_init();

Expand Down
4 changes: 0 additions & 4 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ class Connection : public EventEmitter {

connection->OnClose();

if (s->errorno) {
printf("socket died: %s\n", strerror(s->errorno));
}

assert(connection->attached_);

connection->Detach();
Expand Down
1 change: 1 addition & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ ParseArgs (int *argc, char **argv)
int
main (int argc, char *argv[])
{
evcom_ignore_sigpipe();
ev_default_loop(EVFLAG_AUTO); // initialize the default ev loop.

// start eio thread pool
Expand Down

0 comments on commit a8813fc

Please sign in to comment.