Commit 93c1b874 authored by jehan's avatar jehan

don't refresh if peration in progress

parent fcf65cfa
......@@ -32,13 +32,24 @@ typedef enum belle_sip_transaction_state{
BELLE_SIP_BEGIN_DECLS
const char *belle_sip_transaction_state_to_string(belle_sip_transaction_state_t state);
BELLESIP_EXPORT const char *belle_sip_transaction_state_to_string(const belle_sip_transaction_state_t state);
/*
* Transient state are:
* <br> BELLE_SIP_TRANSACTION_INIT,
* <br> BELLE_SIP_TRANSACTION_CALLING,
* <br> BELLE_SIP_TRANSACTION_PROCEEDING,
* <br> BELLE_SIP_TRANSACTION_TRYING,
* @param state
* @return 0 if not transient
* */
BELLESIP_EXPORT int belle_sip_transaction_state_is_transient(const belle_sip_transaction_state_t state);
BELLESIP_EXPORT void *belle_sip_transaction_get_application_data(const belle_sip_transaction_t *t);
BELLESIP_EXPORT void belle_sip_transaction_set_application_data(belle_sip_transaction_t *t, void *data);
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);
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_response_t *belle_sip_transaction_get_response(const belle_sip_transaction_t *t);
BELLESIP_EXPORT belle_sip_dialog_t* belle_sip_transaction_get_dialog(const belle_sip_transaction_t *t);
......
......@@ -155,6 +155,10 @@ int belle_sip_refresher_refresh(belle_sip_refresher_t* refresher,int expires) {
belle_sip_uri_t* preset_route=refresher->transaction->preset_route;
belle_sip_provider_t* prov=refresher->transaction->base.provider;
belle_sip_header_contact_t* contact;
if (belle_sip_transaction_state_is_transient(belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(refresher->transaction)))) {
belle_sip_warning("Cannot refresh [%p] because operation in progress",refresher);
return -1;
}
/*first remove timer if any*/
belle_sip_refresher_stop(refresher);
refresher->expires=expires;
......
......@@ -82,7 +82,18 @@ const char *belle_sip_transaction_get_branch_id(const belle_sip_transaction_t *t
belle_sip_transaction_state_t belle_sip_transaction_get_state(const belle_sip_transaction_t *t){
return t->state;
}
int belle_sip_transaction_state_is_transient(const belle_sip_transaction_state_t state) {
switch(state){
case BELLE_SIP_TRANSACTION_INIT:
case BELLE_SIP_TRANSACTION_TRYING:
case BELLE_SIP_TRANSACTION_CALLING:
case BELLE_SIP_TRANSACTION_PROCEEDING:
return 1;
default:
return 0;
}
}
void belle_sip_transaction_terminate(belle_sip_transaction_t *t){
t->state=BELLE_SIP_TRANSACTION_TERMINATED;
BELLE_SIP_OBJECT_VPTR(t,belle_sip_transaction_t)->on_terminate(t);
......@@ -454,7 +465,7 @@ belle_sip_request_t* belle_sip_client_transaction_create_authenticated_request(b
belle_sip_header_cseq_set_seq_number(cseq,belle_sip_header_cseq_get_seq_number(cseq)+1);
if (belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(t)) != BELLE_SIP_TRANSACTION_COMPLETED
&& belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(t)) != BELLE_SIP_TRANSACTION_TERMINATED) {
belle_sip_error("Invalid state [%s] for transaction [%p], should be BELLE_SIP_TRANSACTION_COMPLETED|BELLE_SIP_TRANSACTION_TERMINATED"
belle_sip_error("Invalid state [%s] for transaction [%p], should be BELLE_SIP_TRANSACTION_COMPLETED | BELLE_SIP_TRANSACTION_TERMINATED"
,belle_sip_transaction_state_to_string(belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(t)))
,t);
return NULL;
......
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