Commit 141af7de authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Fix threading issues in the Python module.

Reinitialize log serialization only when all the linphone cores have been destroyed.
parent 3a39a1da
...@@ -1523,6 +1523,24 @@ void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState ...@@ -1523,6 +1523,24 @@ void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState
linphone_core_start(lc); linphone_core_start(lc);
} }
static int linphone_core_serialization_ref = 0;
static void linphone_core_activate_log_serialization_if_needed(void) {
if (liblinphone_serialize_logs == TRUE) {
linphone_core_serialization_ref++;
if (linphone_core_serialization_ref == 1)
ortp_set_log_thread_id(ortp_thread_self());
}
}
static void linphone_core_deactivate_log_serialization_if_needed(void) {
if (liblinphone_serialize_logs == TRUE) {
--linphone_core_serialization_ref;
if (linphone_core_serialization_ref == 0)
ortp_set_log_thread_id(0);
}
}
static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtable, LpConfig *config, void * userdata) static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtable, LpConfig *config, void * userdata)
{ {
const char *remote_provisioning_uri = NULL; const char *remote_provisioning_uri = NULL;
...@@ -1539,9 +1557,7 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab ...@@ -1539,9 +1557,7 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab
linphone_core_set_state(lc,LinphoneGlobalStartup,"Starting up"); linphone_core_set_state(lc,LinphoneGlobalStartup,"Starting up");
ortp_init(); ortp_init();
if (liblinphone_serialize_logs == TRUE) { linphone_core_activate_log_serialization_if_needed();
ortp_set_log_thread_id(ortp_thread_self());
}
lc->dyn_pt=96; lc->dyn_pt=96;
lc->default_profile=rtp_profile_new("default profile"); lc->default_profile=rtp_profile_new("default profile");
linphone_core_assign_payload_type(lc,&payload_type_pcmu8000,0,NULL); linphone_core_assign_payload_type(lc,&payload_type_pcmu8000,0,NULL);
...@@ -6279,9 +6295,7 @@ static void linphone_core_uninit(LinphoneCore *lc) ...@@ -6279,9 +6295,7 @@ static void linphone_core_uninit(LinphoneCore *lc)
linphone_core_message_storage_close(lc); linphone_core_message_storage_close(lc);
ms_exit(); ms_exit();
linphone_core_set_state(lc,LinphoneGlobalOff,"Off"); linphone_core_set_state(lc,LinphoneGlobalOff,"Off");
if (liblinphone_serialize_logs == TRUE) { linphone_core_deactivate_log_serialization_if_needed();
ortp_set_log_thread_id(0);
}
ms_list_free_with_data(lc->vtables,(void (*)(void *))linphone_core_v_table_destroy); ms_list_free_with_data(lc->vtables,(void (*)(void *))linphone_core_v_table_destroy);
} }
......
...@@ -285,6 +285,7 @@ PyMODINIT_FUNC initlinphone(void) { ...@@ -285,6 +285,7 @@ PyMODINIT_FUNC initlinphone(void) {
PyObject *menum; PyObject *menum;
PyDateTime_IMPORT; PyDateTime_IMPORT;
PyEval_InitThreads();
pylinphone_init_logging(); pylinphone_init_logging();
{{#classes}} {{#classes}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment