Commit a5569489 authored by Simon Morlat's avatar Simon Morlat

add new debug traces

parent 81b4695a
......@@ -342,7 +342,7 @@ void belle_sip_main_loop_cancel_source(belle_sip_main_loop_t *ml, unsigned long
void belle_sip_main_loop_iterate(belle_sip_main_loop_t *ml){
size_t pfd_size = ml->nsources * sizeof(belle_sip_pollfd_t);
belle_sip_pollfd_t *pfd=(belle_sip_pollfd_t*)alloca(pfd_size);
belle_sip_pollfd_t *pfd=(belle_sip_pollfd_t*)belle_sip_malloc0(pfd_size);
int i=0;
belle_sip_source_t *s;
belle_sip_list_t *elem,*next;
......@@ -360,7 +360,6 @@ void belle_sip_main_loop_iterate(belle_sip_main_loop_t *ml){
}
/*Step 1: prepare the pollfd table and get the next timeout value */
memset(pfd, 0, pfd_size);
for(elem=ml->sources;elem!=NULL;elem=next){
next=elem->next;
s=(belle_sip_source_t*)elem->data;
......@@ -390,7 +389,7 @@ void belle_sip_main_loop_iterate(belle_sip_main_loop_t *ml){
/* do the poll */
ret=belle_sip_poll(pfd,i,duration);
if (ret==-1){
return;
goto end;
}
/* Step 2: examine poll results and determine the list of source to be notified */
......@@ -443,6 +442,8 @@ void belle_sip_main_loop_iterate(belle_sip_main_loop_t *ml){
if (can_clean) belle_sip_object_pool_clean(ml->pool);
else if (tmp_pool) belle_sip_object_unref(tmp_pool);
end:
belle_sip_free(pfd);
}
void belle_sip_main_loop_run(belle_sip_main_loop_t *ml){
......
......@@ -149,14 +149,15 @@ int belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revents
int content_length;
if (revents & BELLE_SIP_EVENT_READ) {
if (obj->recv_error>0) {
if (obj->simulated_recv_return>0) {
num=belle_sip_channel_recv(obj,obj->input_stream.write_ptr,belle_sip_channel_input_stream_get_buff_length(&obj->input_stream)-1);
/*write ptr is only incremented if data were acquired from the transport*/
obj->input_stream.write_ptr+=num;
/*first null terminate the read buff*/
*obj->input_stream.write_ptr='\0';
} else {
num=obj->recv_error;
belle_sip_message("channel [%p]: simulating recv() returning %i",obj,obj->simulated_recv_return);
num=obj->simulated_recv_return;
}
} else if (!revents) {
num=obj->input_stream.write_ptr-obj->input_stream.read_ptr;
......@@ -288,7 +289,7 @@ void belle_sip_channel_init(belle_sip_channel_t *obj, belle_sip_stack_t *stack,c
if (bindip && strcmp(bindip,"::0")!=0 && strcmp(bindip,"0.0.0.0")!=0)
obj->local_ip=belle_sip_strdup(bindip);
obj->local_port=localport;
obj->recv_error=1;/*not set*/
obj->simulated_recv_return=1;/*not set*/
belle_sip_channel_input_stream_reset(&obj->input_stream);
update_inactivity_timer(obj,FALSE);
}
......
......@@ -92,8 +92,8 @@ struct belle_sip_channel{
belle_sip_channel_input_stream_t input_stream;
belle_sip_source_t *inactivity_timer;
uint64_t last_recv_time;
unsigned int recv_error:1; /* used to simulate network error. if <=0, channel_recv will return this value*/
unsigned int force_close:1; /* used to simulate network error. if <=0, channel_recv will return this value*/
int simulated_recv_return; /* used to simulate network error. 0= no data (disconnected) >0= do nothing -1= network error*/
unsigned int force_close:1; /* when channel is intentionnaly disconnected, in order to prevent looping notifications*/
};
#define BELLE_SIP_CHANNEL(obj) BELLE_SIP_CAST(obj,belle_sip_channel_t)
......
......@@ -845,7 +845,7 @@ void belle_sip_provider_set_recv_error(belle_sip_provider_t *prov, int recv_erro
belle_sip_list_t *channels;
for(lps=prov->lps;lps!=NULL;lps=lps->next){
for(channels=((belle_sip_listening_point_t*)lps->data)->channels;channels!=NULL;channels=channels->next){
((belle_sip_channel_t*)channels->data)->recv_error=recv_error;
((belle_sip_channel_t*)channels->data)->simulated_recv_return=recv_error;
((belle_sip_source_t*)channels->data)->notify_required=(recv_error<=0);
}
}
......
......@@ -70,6 +70,7 @@ BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(belle_sip_hop_t);
BELLE_SIP_INSTANCIATE_VPTR(belle_sip_hop_t,belle_sip_object_t,belle_sip_hop_destroy,belle_sip_hop_clone,NULL,TRUE);
static void belle_sip_stack_destroy(belle_sip_stack_t *stack){
belle_sip_message("stack [%p] destroyed.",stack);
belle_sip_object_unref(stack->ml);
}
......
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