diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 92017616d..224bd73ee 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -375,8 +375,8 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even ms_error("Unhandled event response [%p]",event); } } - } + static void process_timeout(void *user_ctx, const belle_sip_timeout_event_t *event) { belle_sip_client_transaction_t* client_transaction = belle_sip_timeout_event_get_client_transaction(event); SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction)); @@ -386,6 +386,7 @@ static void process_timeout(void *user_ctx, const belle_sip_timeout_event_t *eve ms_error("Unhandled event timeout [%p]",event); } } + static void process_transaction_terminated(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) { belle_sip_client_transaction_t* client_transaction = belle_sip_transaction_terminated_event_get_client_transaction(event); belle_sip_server_transaction_t* server_transaction = belle_sip_transaction_terminated_event_get_server_transaction(event); @@ -404,7 +405,6 @@ static void process_transaction_terminated(void *user_ctx, const belle_sip_trans ms_message("Unhandled transaction terminated [%p]",trans); } if (op) sal_op_unref(op); /*because every transaction ref op*/ - } diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 4d61feca9..76b7069b3 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -27,16 +27,11 @@ static void call_set_released(SalOp* op){ op->state=SalOpStateTerminated; op->base.root->callbacks.call_released(op); op->call_released=TRUE; + /*be aware that the following line may destroy the op*/ + set_or_update_dialog(op,NULL); } } -/*used when the SalOp was ref'd by the dialog, in which case we rely only on the dialog terminated notification*/ -static void call_set_released_and_unref(SalOp* op) { - call_set_released(op); - sal_op_unref(op); -} - - static void call_set_error(SalOp* op,belle_sip_response_t* response){ sal_op_set_error_info_from_response(op,response); op->base.root->callbacks.call_failure(op); @@ -142,7 +137,7 @@ static void process_dialog_terminated(void *ctx, const belle_sip_dialog_terminat break; } belle_sip_main_loop_do_later(belle_sip_stack_get_main_loop(op->base.root->stack) - ,(belle_sip_callback_t) call_set_released_and_unref + ,(belle_sip_callback_t) call_set_released , op); } else { ms_error("dialog unknown for op "); diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index e2678dde0..1a49cd65c 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -573,16 +573,17 @@ static belle_sip_dialog_t *link_op_with_dialog(SalOp *op, belle_sip_dialog_t* di } void set_or_update_dialog(SalOp* op, belle_sip_dialog_t* dialog) { - if (dialog==NULL) return; ms_message("op [%p] : set_or_update_dialog() current=[%p] new=[%p]",op,op->dialog,dialog); - if (dialog && op->dialog!=dialog){ + sal_op_ref(op); + if (op->dialog!=dialog){ if (op->dialog){ /*FIXME: shouldn't we delete unconfirmed dialogs ?*/ unlink_op_with_dialog(op,op->dialog); op->dialog=NULL; } - op->dialog=link_op_with_dialog(op,dialog); + if (dialog) op->dialog=link_op_with_dialog(op,dialog); } + sal_op_unref(op); } /*return reffed op*/ SalOp* sal_op_ref(SalOp* op) { @@ -607,6 +608,13 @@ int sal_op_send_and_create_refresher(SalOp* op,belle_sip_request_t* req, int exp belle_sip_object_unref(op->refresher); } if ((op->refresher = belle_sip_client_transaction_create_refresher(op->pending_client_trans))) { + /*since refresher acquires the transaction, we should remove our context from the transaction, because we won't be notified + * that it is terminated anymore.*/ + sal_op_unref(op);/*loose the reference that was given to the transaction when creating it*/ + /* Note that the refresher will replace our data with belle_sip_transaction_set_application_data(). + Something in the design is not very good here, it makes things complicated to the belle-sip user. + Possible ideas to improve things: refresher shall not use belle_sip_transaction_set_application_data() internally, refresher should let the first transaction + notify the user as a normal transaction*/ belle_sip_refresher_set_listener(op->refresher,listener,op); belle_sip_refresher_set_retry_after(op->refresher,op->base.root->refresher_retry_after); belle_sip_refresher_enable_manual_mode(op->refresher,op->manual_refresher); diff --git a/coreapi/help/filetransfer.c b/coreapi/help/filetransfer.c index 9bbbcddeb..ece07d6c2 100644 --- a/coreapi/help/filetransfer.c +++ b/coreapi/help/filetransfer.c @@ -62,7 +62,7 @@ static void file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMess } /** * function invoked when a file transfer is received. - * */ + **/ static void file_transfer_received(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, const char* buff, size_t size){ int file=-1; if (!linphone_chat_message_get_user_data(message)) { @@ -81,7 +81,9 @@ static void file_transfer_received(LinphoneCore *lc, LinphoneChatMessage *messag close(file); running=FALSE; } else { /* store content on a file*/ - write(file,buff,size); + if (write(file,buff,size)==-1){ + ms_warning("file_transfer_received() write failed: %s",strerror(errno)); + } } } } diff --git a/mediastreamer2 b/mediastreamer2 index c41b1f952..8b80c5023 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit c41b1f95201c74809fdf35bca0d5a81a3de4c21f +Subproject commit 8b80c5023cabeb400826104b5641a9a6917ab4cf diff --git a/tester/call_tester.c b/tester/call_tester.c index 7418cbba0..40fbf37b8 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -239,13 +239,19 @@ bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr){ return call_with_params(caller_mgr,callee_mgr,NULL,NULL); } +static void end_call(LinphoneCoreManager *m1, LinphoneCoreManager *m2){ + linphone_core_terminate_all_calls(m1->lc); + CU_ASSERT_TRUE(wait_for(m1->lc,m2->lc,&m1->stat.number_of_LinphoneCallEnd,1)); + CU_ASSERT_TRUE(wait_for(m1->lc,m2->lc,&m2->stat.number_of_LinphoneCallEnd,1)); +} + static void simple_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); CU_ASSERT_TRUE(call(pauline,marie)); liblinphone_tester_check_rtcp(marie,pauline); - + end_call(marie,pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } diff --git a/tester/message_tester.c b/tester/message_tester.c index ec3cc8a36..151505c59 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -76,7 +76,9 @@ void file_transfer_received(LinphoneCore *lc, LinphoneChatMessage *message, cons counters->number_of_LinphoneMessageExtBodyReceived++; close(file); } else { /* store content on a file*/ - write(file,buff,size); + if (write(file,buff,size)==-1){ + ms_error("file_transfer_received(): write() failed: %s",strerror(errno)); + } } } }