node: wait for event loop to stop before freeing objects

This prevents segfaults during shutdown.
This commit is contained in:
link2xt
2022-06-13 17:23:13 +00:00
parent 82454243fa
commit d2d788662a
2 changed files with 11 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
### Fixes
- set a default error if NDN does not provide an error
- python: avoid exceptions when messages/contacts/chats are compared with `None`
- node: wait for the event loop to stop before destroying contexts #3431
### API-Changes
- python: added `Message.get_status_updates()` #3416

View File

@@ -371,6 +371,11 @@ NAPI_METHOD(dcn_context_unref) {
TRACE("Unrefing dc_context");
dcn_context->gc = 1;
dc_stop_io(dcn_context->dc_context);
if (dcn_context->event_handler_thread != 0) {
uv_thread_join(&dcn_context->event_handler_thread);
dcn_context->event_handler_thread = 0;
}
dc_context_unref(dcn_context->dc_context);
dcn_context->dc_context = NULL;
@@ -2922,6 +2927,11 @@ NAPI_METHOD(dcn_accounts_unref) {
TRACE("Unrefing dc_accounts");
dcn_accounts->gc = 1;
dc_accounts_stop_io(dcn_accounts->dc_accounts);
if (dcn_accounts->event_handler_thread != 0) {
uv_thread_join(&dcn_accounts->event_handler_thread);
dcn_accounts->event_handler_thread = 0;
}
dc_accounts_unref(dcn_accounts->dc_accounts);
dcn_accounts->dc_accounts = NULL;