Skip to content

Commit 29a1867

Browse files
authored
Call onStopped on Stop() too (sebi2k1#78)
1 parent 8360454 commit 29a1867

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/rawchannel.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,8 @@ class RawChannel : public Nan::ObjectWrap
286286

287287
CHECK_CONDITION(hw->m_Thread, "Channel not started");
288288

289-
hw->stopThread();
289+
hw->async_channel_stopped();
290290

291-
uv_close((uv_handle_t *)&hw->m_AsyncReceiverReady, NULL);
292-
uv_close((uv_handle_t *)&hw->m_AsyncChannelStopped, NULL);
293-
hw->Unref();
294291
info.GetReturnValue().Set(info.This());
295292
}
296293

tests/test-raw_basic.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ exports['channel_error'] = function(test) {
3434
channel.start();
3535
}
3636

37+
exports['channel_stopped'] = function(test) {
38+
var channel = can.createRawChannel("vcan0");
39+
var stop_called = false;
40+
41+
channel.addListener("onStopped", function() {
42+
stop_called = true
43+
});
44+
45+
channel.start();
46+
47+
setTimeout(function() { channel.stop(); }, 100);
48+
49+
setTimeout(function() {
50+
test.ok(stop_called)
51+
test.done()
52+
}, 100);
53+
}
54+
3755
// Send 100 messages from c2 to c1
3856
exports['rxtx_test'] = function(test) {
3957
var c1 = can.createRawChannelWithOptions("vcan0", { timestamps: true });

0 commit comments

Comments
 (0)