Browse files

evcom upgrade - ignore sigpipe. remove error output.

  • Loading branch information...
1 parent a73998d commit a8813fcdf570843d428da9d08c806d28ee600300 @ry ry committed Aug 22, 2009
Showing with 16 additions and 4 deletions.
  1. +10 −0 deps/evcom/evcom.c
  2. +3 −0 deps/evcom/evcom.h
  3. +2 −0 deps/evcom/test/test.c
  4. +0 −4 src/net.h
  5. +1 −0 src/node.cc
View
10 deps/evcom/evcom.c
@@ -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 */
@@ -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)
{
View
3 deps/evcom/evcom.h
@@ -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*);
View
2 deps/evcom/test/test.c
@@ -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();
View
4 src/net.h
@@ -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();
View
1 src/node.cc
@@ -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

0 comments on commit a8813fc

Please sign in to comment.