Commit e1f10adf authored by Simon Morlat's avatar Simon Morlat

make belle-sip channel to enter retry state when a REGISTER transaction gets a...

make belle-sip channel to enter retry state when a REGISTER transaction gets a 500 Server Internal Error
parent 1ffd8905
...@@ -849,8 +849,9 @@ static void channel_connect_next(belle_sip_channel_t *obj){ ...@@ -849,8 +849,9 @@ static void channel_connect_next(belle_sip_channel_t *obj){
} }
static void belle_sip_channel_handle_error(belle_sip_channel_t *obj){ static void belle_sip_channel_handle_error(belle_sip_channel_t *obj){
if (obj->state!=BELLE_SIP_CHANNEL_READY){ if (obj->state!=BELLE_SIP_CHANNEL_READY || obj->soft_error){
/* Previous connection attempts were failed (channel could not get ready).*/ /* Previous connection attempts were failed (channel could not get ready) OR soft error reported*/
obj->soft_error = FALSE;
/* See if you can retry on an alternate ip address.*/ /* See if you can retry on an alternate ip address.*/
if (obj->current_peer && obj->current_peer->ai_next){ /*obj->current_peer may be null in case of dns error*/ if (obj->current_peer && obj->current_peer->ai_next){ /*obj->current_peer may be null in case of dns error*/
obj->current_peer=obj->current_peer->ai_next; obj->current_peer=obj->current_peer->ai_next;
...@@ -880,6 +881,12 @@ int belle_sip_channel_notify_timeout(belle_sip_channel_t *obj){ ...@@ -880,6 +881,12 @@ int belle_sip_channel_notify_timeout(belle_sip_channel_t *obj){
return FALSE; return FALSE;
} }
void belle_sip_channel_notify_server_error(belle_sip_channel_t *obj){
belle_sip_message("channel[%p]: this server is encountering internal errors, moving to error state to eventually connect to another IP.", obj);
obj->soft_error = TRUE;
channel_set_state(obj,BELLE_SIP_CHANNEL_ERROR);
}
void channel_set_state(belle_sip_channel_t *obj, belle_sip_channel_state_t state) { void channel_set_state(belle_sip_channel_t *obj, belle_sip_channel_state_t state) {
belle_sip_message("channel %p: state %s",obj,belle_sip_channel_state_to_string(state)); belle_sip_message("channel %p: state %s",obj,belle_sip_channel_state_to_string(state));
......
...@@ -120,6 +120,7 @@ struct belle_sip_channel{ ...@@ -120,6 +120,7 @@ struct belle_sip_channel{
unsigned char has_name; /*set when the name of the peer is known, which is not the case of inboud connections*/ unsigned char has_name; /*set when the name of the peer is known, which is not the case of inboud connections*/
unsigned char about_to_be_closed; unsigned char about_to_be_closed;
unsigned char srv_overrides_port; /*set when this channel was connected to destination port provided by SRV resolution*/ unsigned char srv_overrides_port; /*set when this channel was connected to destination port provided by SRV resolution*/
unsigned char soft_error; /*set when this channel enters ERROR state because of error detected in upper layer */
}; };
#define BELLE_SIP_CHANNEL(obj) BELLE_SIP_CAST(obj,belle_sip_channel_t) #define BELLE_SIP_CHANNEL(obj) BELLE_SIP_CAST(obj,belle_sip_channel_t)
...@@ -193,6 +194,9 @@ void belle_sip_channel_force_close(belle_sip_channel_t *obj); ...@@ -193,6 +194,9 @@ void belle_sip_channel_force_close(belle_sip_channel_t *obj);
Returns TRUE if the channel enters error state, 0 otherwise (channel is given a second chance) */ Returns TRUE if the channel enters error state, 0 otherwise (channel is given a second chance) */
int belle_sip_channel_notify_timeout(belle_sip_channel_t *obj); int belle_sip_channel_notify_timeout(belle_sip_channel_t *obj);
/*Used by transaction layer to report a server having internal errors, so that we can retry with another IP (in case of DNS SRV)*/
void belle_sip_channel_notify_server_error(belle_sip_channel_t *obj);
BELLE_SIP_END_DECLS BELLE_SIP_END_DECLS
......
...@@ -457,8 +457,13 @@ void belle_sip_client_transaction_notify_response(belle_sip_client_transaction_t ...@@ -457,8 +457,13 @@ void belle_sip_client_transaction_notify_response(belle_sip_client_transaction_t
event.response=(belle_sip_response_t*)resp; event.response=(belle_sip_response_t*)resp;
BELLE_SIP_PROVIDER_INVOKE_LISTENERS_FOR_TRANSACTION(((belle_sip_transaction_t*)t),process_response_event,&event); BELLE_SIP_PROVIDER_INVOKE_LISTENERS_FOR_TRANSACTION(((belle_sip_transaction_t*)t),process_response_event,&event);
/*check that 200Ok for INVITEs have been acknowledged by listener*/ /*check that 200Ok for INVITEs have been acknowledged by listener*/
if (dialog && strcmp(method,"INVITE")==0) if (dialog && strcmp(method,"INVITE")==0){
belle_sip_dialog_check_ack_sent(dialog); belle_sip_dialog_check_ack_sent(dialog);
}
/*report a server having internal errors for REGISTER to the channel, in order to go to a fallback IP*/
if (status_code == 500 && strcmp(method,"REGISTER") == 0){
belle_sip_channel_notify_server_error(base->channel);
}
} }
......
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