Commit ea4d5f0d authored by Simon Morlat's avatar Simon Morlat

fix tests

parent 30f238b9
......@@ -120,6 +120,8 @@ BELLESIP_EXPORT int belle_sip_dialog_request_pending(const belle_sip_dialog_t *d
BELLESIP_EXPORT int belle_sip_dialog_pending_trans_checking_enabled( const belle_sip_dialog_t *dialog) ;
BELLESIP_EXPORT int belle_sip_dialog_enable_pending_trans_checking(belle_sip_dialog_t *dialog, int value) ;
BELLESIP_EXPORT int belle_sip_dialog_expired(const belle_sip_dialog_t *dialog);
BELLE_SIP_END_DECLS
#endif
......
......@@ -193,13 +193,17 @@ static int belle_sip_dialog_init_as_uac(belle_sip_dialog_t *obj, belle_sip_reque
return 0;
}
static int belle_sip_dialog_expired(belle_sip_dialog_t *dialog){
static int belle_sip_dialog_on_expired(belle_sip_dialog_t *dialog){
belle_sip_message("Dialog [%p] expired", dialog);
dialog->is_expired = TRUE;
belle_sip_dialog_delete(dialog);
return BELLE_SIP_STOP;
}
int belle_sip_dialog_expired(const belle_sip_dialog_t *dialog){
return dialog->is_expired;
}
/*returns BELLE_SIP_STOP if the dialog is to be terminated, BELLE_SIP_CONTINUE otherwise*/
static int belle_sip_dialog_schedule_expiration(belle_sip_dialog_t *dialog, belle_sip_message_t *request){
belle_sip_header_expires_t *expires = belle_sip_message_get_header_by_type(request, belle_sip_header_expires_t);
......@@ -215,7 +219,7 @@ static int belle_sip_dialog_schedule_expiration(belle_sip_dialog_t *dialog, bell
belle_sip_message("belle_sip_dialog_schedule_expiration() dialog=%p expires_value=%i", dialog, expires_value);
if (expires_value == 0) return BELLE_SIP_STOP;
dialog->expiration_timer = belle_sip_main_loop_create_timeout(dialog->provider->stack->ml,
(belle_sip_source_func_t) belle_sip_dialog_expired,
(belle_sip_source_func_t) belle_sip_dialog_on_expired,
dialog,
expires_value * 1000,
"Dialog expiration");
......
......@@ -103,13 +103,16 @@ static void process_dialog_terminated(belle_sip_listener_t *user_ctx, const bell
if (refresher && refresher->transaction && dialog != belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(refresher->transaction)))
return; /*not for me*/
/*
if (refresher->state == started) {
belle_sip_warning("Refresher [%p] still started but receiving unexpected dialog deleted event on [%p], retrying",refresher,dialog);
retry_later_on_io_error(refresher);
if (belle_sip_dialog_expired(dialog) && refresher->state == started) {
/* We notify the app that the dialog is expired due to failure to refresh the subscription on time.
* However the transaction to renew the dialog is either pending or already failed, and has scheduled a retry already,
* so there is no need to reschedule a retry here.*/
belle_sip_warning("Refresher [%p] still started but expired, retrying",refresher);
if (refresher->listener) refresher->listener(refresher,refresher->user_data,481, "dialod terminated", TRUE);
}
*/
}
static void process_io_error(belle_sip_listener_t *user_ctx, const belle_sip_io_error_event_t *event){
......@@ -337,6 +340,7 @@ static void process_response_event(belle_sip_listener_t *user_ctx, const belle_s
/*irrecoverable errors, probably no need to retry later*/
will_retry = FALSE;
break;
case 481:
case 503:
if (refresher->target_expires>0) {
if (refresher->dialog) retry_later_on_io_error(refresher);
......
......@@ -584,11 +584,12 @@ static void subscribe_base(int with_resource_lists) {
BC_ASSERT_LOWER_STRICT(end-begin,5000,unsigned long long,"%llu");
belle_sip_message("simulating dialog error and recovery");
belle_sip_stack_set_send_error(client->stack, 1500);
belle_sip_stack_set_send_error(client->stack, 1);
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.fourHundredEightyOne,1,4000));
/*let the transaction timeout*/
wait_for(server->stack,client->stack, &dummy, 1, 32000);
belle_sip_stack_set_send_error(client->stack, 0);
wait_for(server->stack,client->stack, &dummy, 1, 1000);
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,4,4000));
BC_ASSERT_EQUAL(client->stat.dialogTerminated, 0, int, "%i");
......@@ -618,7 +619,8 @@ static void subscribe_base(int with_resource_lists) {
belle_sip_refresher_refresh(refresher, 0);
belle_sip_refresher_stop(refresher);
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&server->stat.dialogTerminated,1,4000));
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&server->stat.dialogTerminated,3,4000));
belle_sip_object_unref(refresher);
if (with_resource_lists) {
......@@ -869,7 +871,7 @@ test_t refresher_tests[] = {
{ "REGISTER Expires in Contact digest auth", register_expires_in_contact_header_digest_auth },
{ "REGISTER with failure", register_with_failure },
{ "REGISTER with early refresher",register_early_refresher},
TEST_ONE_TAG("SUBSCRIBE", subscribe_test, "LeaksMemory"),
TEST_NO_TAG("SUBSCRIBE", subscribe_test),
TEST_ONE_TAG("SUBSCRIBE of list" , subscribe_list_test, "LeaksMemory"),
{ "PUBLISH", simple_publish },
{ "PUBLISH with early refresher", simple_publish_with_early_refresher },
......
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