Commit e1f10adf authored by Simon Morlat's avatar Simon Morlat
Browse files

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){
static void belle_sip_channel_handle_error(belle_sip_channel_t *obj){
if (obj->state!=BELLE_SIP_CHANNEL_READY){
/* Previous connection attempts were failed (channel could not get ready).*/
if (obj->state!=BELLE_SIP_CHANNEL_READY || obj->soft_error){
/* 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.*/
if (obj->current_peer && obj->current_peer->ai_next){ /*obj->current_peer may be null in case of dns error*/
......@@ -880,6 +881,12 @@ int belle_sip_channel_notify_timeout(belle_sip_channel_t *obj){
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;
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));
......@@ -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 about_to_be_closed;
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)
......@@ -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) */
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);
......@@ -457,8 +457,13 @@ void belle_sip_client_transaction_notify_response(belle_sip_client_transaction_t
/*check that 200Ok for INVITEs have been acknowledged by listener*/
if (dialog && strcmp(method,"INVITE")==0)
if (dialog && strcmp(method,"INVITE")==0){
/*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){
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