Commit 580310fc authored by jehan's avatar jehan

implement io error handling for list subscription

parent 3aed512e
...@@ -1303,7 +1303,7 @@ static void subscribe_response(SalOp *op, SalSubscribeStatus status){ ...@@ -1303,7 +1303,7 @@ static void subscribe_response(SalOp *op, SalSubscribeStatus status){
}else if (status==SalSubscribePending){ }else if (status==SalSubscribePending){
linphone_event_set_state(lev,LinphoneSubscriptionPending); linphone_event_set_state(lev,LinphoneSubscriptionPending);
}else{ }else{
if (lev->subscription_state==LinphoneSubscriptionActive && ei->reason==SalReasonIOError){ if (lev->subscription_state==LinphoneSubscriptionActive && (ei->reason==SalReasonIOError || ei->reason == SalReasonNoMatch)){
linphone_event_set_state(lev,LinphoneSubscriptionOutgoingProgress); linphone_event_set_state(lev,LinphoneSubscriptionOutgoingProgress);
} }
else linphone_event_set_state(lev,LinphoneSubscriptionError); else linphone_event_set_state(lev,LinphoneSubscriptionError);
......
...@@ -489,7 +489,7 @@ void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneE ...@@ -489,7 +489,7 @@ void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneE
, lev , lev
, list); , list);
if (state == LinphoneSubscriptionOutgoingProgress) { if (state == LinphoneSubscriptionOutgoingProgress && linphone_event_get_reason(lev) == LinphoneReasonNoMatch) {
ms_message("Resseting version count for friend list [%p]",list); ms_message("Resseting version count for friend list [%p]",list);
list->expected_notification_version = 0; list->expected_notification_version = 0;
} }
......
...@@ -820,7 +820,7 @@ static void test_presence_list_subscription_expire_for_unknown(void) { ...@@ -820,7 +820,7 @@ static void test_presence_list_subscription_expire_for_unknown(void) {
linphone_core_manager_destroy(laure); linphone_core_manager_destroy(laure);
} }
static void test_presence_list_subscribe_dialog_expire(void) { static void test_presence_list_subscribe_with_error(bool_t io_error) {
LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc"); LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
const char *rls_uri = "sip:rls@sip.example.org"; const char *rls_uri = "sip:rls@sip.example.org";
...@@ -866,17 +866,21 @@ static void test_presence_list_subscribe_dialog_expire(void) { ...@@ -866,17 +866,21 @@ static void test_presence_list_subscribe_dialog_expire(void) {
BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d"); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d");
BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_NotifyPresenceReceived, 2, 5000)); BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_NotifyPresenceReceived, 2, 5000));
ms_message("Simulating in/out packets losses"); if (io_error) {
sal_set_send_error(laure->lc->sal,1500); /*make sure no refresh is sent, trash the message without generating error*/ ms_message("Simulating socket error");
sal_set_recv_error(laure->lc->sal, 1500); /*make sure server notify to close the dialog is also ignored*/ sal_set_recv_error(laure->lc->sal, -1);
wait_for_list(lcs, &dummy, 1, 1000); /* just time for socket to be closed */
wait_for_list(lcs, &dummy, 1, 3000); /* Wait a little bit for the subscribe to happen */
} else {
ms_message("Simulating in/out packets losses");
sal_set_send_error(laure->lc->sal,1500); /*make sure no refresh is sent, trash the message without generating error*/
sal_set_recv_error(laure->lc->sal, 1500); /*make sure server notify to close the dialog is also ignored*/
wait_for_list(lcs, &dummy, 1, 3000); /* Wait a little bit for the subscribe to happen */
}
/*restart normal behavior*/ /*restart normal behavior*/
sal_set_send_error(laure->lc->sal,0); sal_set_send_error(laure->lc->sal,0);
sal_set_recv_error(laure->lc->sal, 1); sal_set_recv_error(laure->lc->sal, 1);
linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityAway, NULL)); linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityAway, NULL));
BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_NotifyPresenceReceived, 3, 5000)); BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_NotifyPresenceReceived, 3, 5000));
...@@ -887,7 +891,13 @@ static void test_presence_list_subscribe_dialog_expire(void) { ...@@ -887,7 +891,13 @@ static void test_presence_list_subscribe_dialog_expire(void) {
linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline);
} }
static void test_presence_list_subscribe_dialog_expire(void) {
test_presence_list_subscribe_with_error(FALSE);
}
static void test_presence_list_subscribe_io_error(void) {
test_presence_list_subscribe_with_error(TRUE);
}
test_t presence_tests[] = { test_t presence_tests[] = {
TEST_NO_TAG("Simple Subscribe", simple_subscribe), TEST_NO_TAG("Simple Subscribe", simple_subscribe),
...@@ -904,7 +914,8 @@ test_t presence_tests[] = { ...@@ -904,7 +914,8 @@ test_t presence_tests[] = {
TEST_NO_TAG("Forked subscribe with late publish", test_forked_subscribe_notify_publish), TEST_NO_TAG("Forked subscribe with late publish", test_forked_subscribe_notify_publish),
TEST_NO_TAG("Presence list", test_presence_list), TEST_NO_TAG("Presence list", test_presence_list),
TEST_NO_TAG("Presence list, subscription expiration for unknown contact",test_presence_list_subscription_expire_for_unknown), TEST_NO_TAG("Presence list, subscription expiration for unknown contact",test_presence_list_subscription_expire_for_unknown),
TEST_NO_TAG("Presence list, silent subscription expiration", test_presence_list_subscribe_dialog_expire) TEST_NO_TAG("Presence list, silent subscription expiration", test_presence_list_subscribe_dialog_expire),
TEST_NO_TAG("Presence list, io error",test_presence_list_subscribe_io_error)
}; };
test_suite_t presence_test_suite = {"Presence", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, test_suite_t presence_test_suite = {"Presence", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
......
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