Commit d9849d09 authored by Simon Morlat's avatar Simon Morlat

improvements of the dialog's request queue in order to allow urgent request to...

improvements of the dialog's request queue in order to allow urgent request to be submitted before processing of the queue.
parent 7045b21f
...@@ -49,6 +49,7 @@ BELLESIP_EXPORT void *belle_sip_transaction_get_application_data(const belle_sip ...@@ -49,6 +49,7 @@ BELLESIP_EXPORT void *belle_sip_transaction_get_application_data(const belle_sip
BELLESIP_EXPORT void belle_sip_transaction_set_application_data(belle_sip_transaction_t *t, void *data); BELLESIP_EXPORT void belle_sip_transaction_set_application_data(belle_sip_transaction_t *t, void *data);
BELLESIP_EXPORT const char *belle_sip_transaction_get_branch_id(const belle_sip_transaction_t *t); BELLESIP_EXPORT const char *belle_sip_transaction_get_branch_id(const belle_sip_transaction_t *t);
BELLESIP_EXPORT belle_sip_transaction_state_t belle_sip_transaction_get_state(const belle_sip_transaction_t *t); BELLESIP_EXPORT belle_sip_transaction_state_t belle_sip_transaction_get_state(const belle_sip_transaction_t *t);
BELLESIP_EXPORT const char *belle_sip_transaction_get_method(const belle_sip_transaction_t *t);
BELLESIP_EXPORT void belle_sip_transaction_terminate(belle_sip_transaction_t *t); BELLESIP_EXPORT void belle_sip_transaction_terminate(belle_sip_transaction_t *t);
BELLESIP_EXPORT belle_sip_request_t *belle_sip_transaction_get_request(const belle_sip_transaction_t *t); BELLESIP_EXPORT belle_sip_request_t *belle_sip_transaction_get_request(const belle_sip_transaction_t *t);
BELLESIP_EXPORT belle_sip_response_t *belle_sip_transaction_get_response(const belle_sip_transaction_t *t); BELLESIP_EXPORT belle_sip_response_t *belle_sip_transaction_get_response(const belle_sip_transaction_t *t);
......
...@@ -555,7 +555,7 @@ belle_sip_request_t *belle_sip_dialog_create_request(belle_sip_dialog_t *obj, co ...@@ -555,7 +555,7 @@ belle_sip_request_t *belle_sip_dialog_create_request(belle_sip_dialog_t *obj, co
} }
if (strcmp(method,"BYE")!=0 && obj->last_transaction && belle_sip_transaction_state_is_transient(belle_sip_transaction_get_state(obj->last_transaction))){ if (strcmp(method,"BYE")!=0 && obj->last_transaction && belle_sip_transaction_state_is_transient(belle_sip_transaction_get_state(obj->last_transaction))){
/*don't prevent to send a BYE in any case */ /*don't prevent to send a BYE in any case */
belle_sip_error("belle_sip_dialog_create_request(): cannot create [%s] request from dialog [%p] while pending transaction in state [%s]",method,obj,belle_sip_transaction_state_to_string(belle_sip_transaction_get_state(obj->last_transaction))); belle_sip_error("belle_sip_dialog_create_request(): cannot create [%s] request from dialog [%p] while pending [%s] transaction in state [%s]",method,obj,belle_sip_transaction_get_method(obj->last_transaction), belle_sip_transaction_state_to_string(belle_sip_transaction_get_state(obj->last_transaction)));
return NULL; return NULL;
} }
belle_sip_dialog_update_local_cseq(obj,method); belle_sip_dialog_update_local_cseq(obj,method);
...@@ -860,10 +860,10 @@ void belle_sip_dialog_queue_client_transaction(belle_sip_dialog_t *dialog, belle ...@@ -860,10 +860,10 @@ void belle_sip_dialog_queue_client_transaction(belle_sip_dialog_t *dialog, belle
dialog->queued_ct=belle_sip_list_append(dialog->queued_ct, belle_sip_object_ref(tr)); dialog->queued_ct=belle_sip_list_append(dialog->queued_ct, belle_sip_object_ref(tr));
} }
void belle_sip_dialog_process_queue(belle_sip_dialog_t* dialog){ static void _belle_sip_dialog_process_queue(belle_sip_dialog_t* dialog){
belle_sip_client_transaction_t *tr=NULL; belle_sip_client_transaction_t *tr=NULL;
if (belle_sip_dialog_request_pending(dialog) || dialog->needs_ack) return; if (dialog->state==BELLE_SIP_DIALOG_TERMINATED || belle_sip_dialog_request_pending(dialog) || dialog->needs_ack) goto end;
dialog->queued_ct=belle_sip_list_pop_front(dialog->queued_ct,(void**)&tr); dialog->queued_ct=belle_sip_list_pop_front(dialog->queued_ct,(void**)&tr);
if (tr){ if (tr){
...@@ -871,6 +871,16 @@ void belle_sip_dialog_process_queue(belle_sip_dialog_t* dialog){ ...@@ -871,6 +871,16 @@ void belle_sip_dialog_process_queue(belle_sip_dialog_t* dialog){
belle_sip_client_transaction_send_request(tr); belle_sip_client_transaction_send_request(tr);
belle_sip_object_unref(tr); belle_sip_object_unref(tr);
} }
end:
belle_sip_object_unref(dialog);
}
void belle_sip_dialog_process_queue(belle_sip_dialog_t* dialog){
/*process queue does not process synchronously.
* This is to let the application handle responses and eventually submit new requests without being blocked.
* Typically when a reINVITE is challenged, we want a chance to re-submit an authenticated request before processing
* queued requests*/
belle_sip_main_loop_do_later(dialog->provider->stack->ml,(belle_sip_callback_t)_belle_sip_dialog_process_queue,belle_sip_object_ref(dialog));
} }
void belle_sip_dialog_update_request(belle_sip_dialog_t *dialog, belle_sip_request_t *req){ void belle_sip_dialog_update_request(belle_sip_dialog_t *dialog, belle_sip_request_t *req){
......
...@@ -50,6 +50,11 @@ void belle_sip_transaction_set_state(belle_sip_transaction_t *t, belle_sip_trans ...@@ -50,6 +50,11 @@ void belle_sip_transaction_set_state(belle_sip_transaction_t *t, belle_sip_trans
belle_sip_transaction_state_to_string(state)); belle_sip_transaction_state_to_string(state));
t->state=state; t->state=state;
} }
BELLESIP_EXPORT const char *belle_sip_transaction_get_method(const belle_sip_transaction_t *t){
return belle_sip_request_get_method(t->request);
}
static void belle_sip_transaction_init(belle_sip_transaction_t *t, belle_sip_provider_t *prov, belle_sip_request_t *req){ static void belle_sip_transaction_init(belle_sip_transaction_t *t, belle_sip_provider_t *prov, belle_sip_request_t *req){
t->request=(belle_sip_request_t*)belle_sip_object_ref(req); t->request=(belle_sip_request_t*)belle_sip_object_ref(req);
t->provider=prov; t->provider=prov;
...@@ -432,7 +437,7 @@ void belle_sip_client_transaction_notify_response(belle_sip_client_transaction_t ...@@ -432,7 +437,7 @@ void belle_sip_client_transaction_notify_response(belle_sip_client_transaction_t
if (dialog && belle_sip_dialog_update(dialog,BELLE_SIP_TRANSACTION(t),FALSE)) { if (dialog && belle_sip_dialog_update(dialog,BELLE_SIP_TRANSACTION(t),FALSE)) {
/* retransmition, just return*/ /* retransmition, just return*/
belle_sip_message("[%p] is a200 ok retransmition on dialog [%p], skiping",resp,dialog); belle_sip_message("[%p] is a 200 ok retransmition on dialog [%p], skiping",resp,dialog);
return; return;
} }
......
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