ev_unref() the signal handlers.

That means even if they are Attached(), libev will still exit if there is
nothing else to do.
pull/22966/head
Ryan Dahl 2009-10-07 01:35:21 +02:00
parent f068251494
commit 1817d4b062
1 changed files with 6 additions and 1 deletions

View File

@ -33,7 +33,10 @@ void SignalHandler::OnSignal(EV_P_ ev_signal *watcher, int revents) {
}
SignalHandler::~SignalHandler() {
ev_signal_stop(EV_DEFAULT_UC_ &watcher_);
if (watcher_.active) {
ev_unref(EV_DEFAULT_UC);
ev_signal_stop(EV_DEFAULT_UC_ &watcher_);
}
}
Handle<Value> SignalHandler::New(const Arguments& args) {
@ -51,6 +54,7 @@ Handle<Value> SignalHandler::New(const Arguments& args) {
ev_signal_init(&handler->watcher_, SignalHandler::OnSignal, sig);
handler->watcher_.data = handler;
ev_signal_start(EV_DEFAULT_UC_ &handler->watcher_);
ev_unref(EV_DEFAULT_UC);
handler->Attach();
@ -61,6 +65,7 @@ Handle<Value> SignalHandler::Stop(const Arguments& args) {
HandleScope scope;
SignalHandler *handler = ObjectWrap::Unwrap<SignalHandler>(args.Holder());
ev_ref(EV_DEFAULT_UC);
ev_signal_stop(EV_DEFAULT_UC_ &handler->watcher_);
handler->Detach();
return Undefined();