File tree 5 files changed +16
-4
lines changed
5 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 32
32
#include <errno.h>
33
33
#include <string.h> /* memset */
34
34
35
+ #include <signal.h>
36
+
35
37
#include <netinet/tcp.h> /* TCP_NODELAY */
36
38
#include <sys/types.h>
37
39
#include <sys/socket.h> /* shutdown */
@@ -135,6 +137,14 @@ evcom_buf_new (const char *base, size_t len)
135
137
return buf ;
136
138
}
137
139
140
+ void evcom_ignore_sigpipe (void )
141
+ {
142
+ struct sigaction sa ;
143
+ bzero (& sa , sizeof (sa ));
144
+ sa .sa_handler = SIG_IGN ;
145
+ sigaction (SIGPIPE , & sa , NULL );
146
+ }
147
+
138
148
static int
139
149
close_asap (evcom_descriptor * d )
140
150
{
Original file line number Diff line number Diff line change @@ -159,6 +159,9 @@ typedef struct evcom_server {
159
159
(* on_connection )(struct evcom_server * , struct sockaddr * remote_addr );
160
160
} evcom_server ;
161
161
162
+ /* Highly recommended to ignore SIGPIPE! */
163
+ void evcom_ignore_sigpipe (void );
164
+
162
165
void evcom_reader_init (evcom_reader * );
163
166
void evcom_reader_set (evcom_reader * , int fd );
164
167
void evcom_reader_attach (EV_P_ evcom_reader * );
Original file line number Diff line number Diff line change @@ -776,6 +776,8 @@ main (void)
776
776
fprintf (stderr , "sizeof(evcom_reader): %d\n" , (int )sizeof (evcom_reader ));
777
777
fprintf (stderr , "sizeof(evcom_writer): %d\n" , (int )sizeof (evcom_writer ));
778
778
779
+ evcom_ignore_sigpipe ();
780
+
779
781
#if EVCOM_HAVE_GNUTLS
780
782
gnutls_global_init ();
781
783
Original file line number Diff line number Diff line change @@ -95,10 +95,6 @@ class Connection : public EventEmitter {
95
95
96
96
connection->OnClose ();
97
97
98
- if (s->errorno ) {
99
- printf (" socket died: %s\n " , strerror (s->errorno ));
100
- }
101
-
102
98
assert (connection->attached_ );
103
99
104
100
connection->Detach ();
Original file line number Diff line number Diff line change @@ -318,6 +318,7 @@ ParseArgs (int *argc, char **argv)
318
318
int
319
319
main (int argc, char *argv[])
320
320
{
321
+ evcom_ignore_sigpipe ();
321
322
ev_default_loop (EVFLAG_AUTO); // initialize the default ev loop.
322
323
323
324
// start eio thread pool
You can’t perform that action at this time.
0 commit comments