Skip to content

Commit

Permalink
Ignore SIGPIPE, still causing crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed May 10, 2013
1 parent 8f67dbf commit fe95d0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ httpuv 1.0.6.2
* When onHeaders() callback returned a body, httpuv was not properly
short-circuiting the request.

* Ignore SIGPIPE permanently. This was still causing crashes under heavy
real-world traffic.


httpuv 1.0.6.1
------------------------------------------------------------------------
Expand All @@ -28,4 +31,4 @@ httpuv 1.0.6
httpuv 1.0.5
------------------------------------------------------------------------

* Initial release.
* Initial release.
22 changes: 1 addition & 21 deletions src/httpuv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,26 +375,6 @@ void stop_loop_timer_cb(uv_timer_t* handle, int status) {
uv_stop(handle->loop);
}

#ifndef _WIN32
// Linux uses sighandler_t and Mac uses sig_t, so define our own
typedef void (*signal_handler_t)(int);

class IgnoreSignal {
int _signum;
signal_handler_t _origHandler;

public:
IgnoreSignal(int signum) : _signum(signum) {
_origHandler = signal(signum, SIG_IGN);
}

virtual ~IgnoreSignal() {
if (_origHandler != SIG_ERR)
signal(_signum, _origHandler);
}
};
#endif

// Run the libuv default loop for roughly timeoutMillis, then stop
// [[Rcpp::export]]
bool run(uint32_t timeoutMillis) {
Expand All @@ -421,7 +401,7 @@ bool run(uint32_t timeoutMillis) {
// Must ignore SIGPIPE when libuv code is running, otherwise unexpectedly
// closing connections kill us
#ifndef _WIN32
IgnoreSignal(SIGPIPE);
signal(SIGPIPE, SIG_IGN);
#endif
return uv_run(uv_default_loop(), UV_RUN_ONCE);
}

0 comments on commit fe95d0d

Please sign in to comment.