Commit d8189345 authored by jehan's avatar jehan

fix double transaction on the same channel

parent fd19c02d
......@@ -60,7 +60,7 @@
<folderInfo id="cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base.1209613831" name="cdt.managedbuild.toolchain.gnu.macosx.base" superClass="cdt.managedbuild.toolchain.gnu.macosx.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.MachO64" id="cdt.managedbuild.target.gnu.platform.macosx.base.973927327" name="Debug Platform" osList="macosx" superClass="cdt.managedbuild.target.gnu.platform.macosx.base"/>
<builder arguments="CFLAGS=&quot;-g -Wall -Werror&quot;" command="make" id="cdt.managedbuild.target.gnu.builder.macosx.base.190701400" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.macosx.base"/>
<builder arguments="CFLAGS=&quot;-g -Wall -Werror&quot; V=1" command="make" id="cdt.managedbuild.target.gnu.builder.macosx.base.190701400" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.macosx.base"/>
<tool id="cdt.managedbuild.tool.macosx.c.linker.macosx.base.419159753" name="MacOS X C Linker" superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.base">
<inputType id="cdt.managedbuild.tool.macosx.c.linker.input.1079464415" superClass="cdt.managedbuild.tool.macosx.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
......
......@@ -222,6 +222,7 @@ void belle_sip_header_cseq_set_method(belle_sip_header_cseq_t* cseq,const char*
unsigned int belle_sip_header_cseq_get_seq_number(const belle_sip_header_cseq_t* cseq);
void belle_sip_header_cseq_set_seq_number(belle_sip_header_cseq_t* cseq,unsigned int seq_number);
#define BELLE_SIP_HEADER_CSEQ(t) BELLE_SIP_CAST(t,belle_sip_header_cseq_t)
#define BELLE_SIP_CSEQ "CSeq"
/******************************
* content type object inherent from parameters
*
......@@ -251,7 +252,7 @@ void belle_sip_header_expires_set_expires(belle_sip_header_expires_t* expires,in
int belle_sip_header_expires_decrement_expires(belle_sip_header_expires_t* expires);
belle_sip_header_expires_t* belle_sip_header_expires_create(int expires);
#define BELLE_SIP_HEADER_EXPIRES(t) BELLE_SIP_CAST(t,belle_sip_header_expires_t)
#define BELLE_SIP_EXPIRES "Expires"
/******************************
* Route header object inherent from header_address
*
......
......@@ -56,11 +56,11 @@ void belle_sip_request_set_uri(belle_sip_request_t* request, belle_sip_uri_t* ur
const char* belle_sip_request_get_method(const belle_sip_request_t* request);
void belle_sip_request_set_method(belle_sip_request_t* request,const char* method);
int belle_sip_message_is_response(belle_sip_message_t *msg);
int belle_sip_message_is_response(const belle_sip_message_t *msg);
belle_sip_header_t *belle_sip_message_get_header(belle_sip_message_t *msg, const char *header_name);
belle_sip_header_t *belle_sip_message_get_header(const belle_sip_message_t *msg, const char *header_name);
const belle_sip_list_t* belle_sip_message_get_headers(belle_sip_message_t *message,const char* header_name);
const belle_sip_list_t* belle_sip_message_get_headers(const belle_sip_message_t *message,const char* header_name);
/**
* add an header to this message
......
......@@ -36,7 +36,7 @@ void belle_sip_provider_add_sip_listener(belle_sip_provider_t *p, belle_sip_list
void belle_sip_provider_remove_sip_listener(belle_sip_provider_t *p, belle_sip_listener_t *l);
belle_sip_header_call_id_t * belle_sip_provider_create_call_id(belle_sip_provider_t *prov);
belle_sip_header_call_id_t * belle_sip_provider_create_call_id(const belle_sip_provider_t *prov);
belle_sip_client_transaction_t *belle_sip_provider_create_client_transaction(belle_sip_provider_t *p, belle_sip_request_t *req);
......
......@@ -496,7 +496,7 @@ belle_sip_header_cseq_t * belle_sip_header_cseq_create(unsigned int number, cons
cseq->seq_number=number;
return cseq;
}
BELLE_SIP_NEW_HEADER(header_cseq,header,"CSeq")
BELLE_SIP_NEW_HEADER(header_cseq,header,BELLE_SIP_CSEQ)
BELLE_SIP_PARSE(header_cseq)
GET_SET_STRING(belle_sip_header_cseq,method);
GET_SET_INT(belle_sip_header_cseq,seq_number,unsigned int)
......@@ -622,7 +622,7 @@ int belle_sip_header_expires_marshal(belle_sip_header_expires_t* expires, char*
current_offset+=snprintf(buff+current_offset,buff_size-current_offset,"%i",expires->expires);
return current_offset-offset;
}
BELLE_SIP_NEW_HEADER(header_expires,header,"Expires")
BELLE_SIP_NEW_HEADER(header_expires,header,BELLE_SIP_EXPIRES)
BELLE_SIP_PARSE(header_expires)
GET_SET_INT(belle_sip_header_expires,expires,int)
belle_sip_header_expires_t* belle_sip_header_expires_create(int expires) {
......
......@@ -258,7 +258,7 @@ void belle_sip_main_loop_iterate(belle_sip_main_loop_t *ml){
if (revents!=0 || (s->timeout>=0 && cur>=s->expire_ms)){
char *objdesc=belle_sip_object_to_string((belle_sip_object_t*)s);
s->expired=TRUE;
belle_sip_message("source %s notified revents=%u, timeout=%i",objdesc,revents,s->timeout);
if (s->timeout>1 /*FIXME, should be 0*/) belle_sip_message("source %s notified revents=%u, timeout=%i",objdesc,revents,s->timeout);
belle_sip_free(objdesc);
ret=s->notify(s->data,revents);
if (ret==0){
......
......@@ -93,7 +93,7 @@ static void belle_sip_message_init(belle_sip_message_t *message){
}
headers_container_t* belle_sip_headers_container_get(belle_sip_message_t* message,const char* header_name) {
headers_container_t* belle_sip_headers_container_get(const belle_sip_message_t* message,const char* header_name) {
belle_sip_list_t * result = belle_sip_list_find_custom( message->header_list
, (belle_sip_compare_func)belle_sip_headers_container_comp_func
, header_name);
......@@ -135,7 +135,7 @@ void belle_sip_message_set_header(belle_sip_message_t *msg, belle_sip_header_t*
headers_container->header_list=belle_sip_list_append(headers_container->header_list,header);
}
const belle_sip_list_t* belle_sip_message_get_headers(belle_sip_message_t *message,const char* header_name) {
const belle_sip_list_t* belle_sip_message_get_headers(const belle_sip_message_t *message,const char* header_name) {
headers_container_t* headers_container = belle_sip_headers_container_get(message,header_name);
return headers_container ? headers_container->header_list:NULL;
}
......@@ -256,11 +256,11 @@ int belle_sip_message_is_request(belle_sip_message_t *msg){
return BELLE_SIP_IS_INSTANCE_OF(BELLE_SIP_OBJECT(msg),belle_sip_request_t);
}
int belle_sip_message_is_response(belle_sip_message_t *msg){
int belle_sip_message_is_response(const belle_sip_message_t *msg){
return BELLE_SIP_IS_INSTANCE_OF(BELLE_SIP_OBJECT(msg),belle_sip_response_t);
}
belle_sip_header_t *belle_sip_message_get_header(belle_sip_message_t *msg, const char *header_name){
belle_sip_header_t *belle_sip_message_get_header(const belle_sip_message_t *msg, const char *header_name){
const belle_sip_list_t *l=belle_sip_message_get_headers(msg,header_name);
if (l!=NULL)
return (belle_sip_header_t*)l->data;
......
......@@ -217,7 +217,7 @@ void belle_sip_provider_remove_sip_listener(belle_sip_provider_t *p, belle_sip_l
p->listeners=belle_sip_list_remove(p->listeners,l);
}
belle_sip_header_call_id_t * belle_sip_provider_create_call_id(belle_sip_provider_t *prov){
belle_sip_header_call_id_t * belle_sip_provider_create_call_id(const belle_sip_provider_t *prov){
belle_sip_header_call_id_t *cid=belle_sip_header_call_id_new();
char tmp[11];
belle_sip_header_call_id_set_call_id(cid,belle_sip_random_token(tmp,sizeof(tmp)));
......
......@@ -213,6 +213,7 @@ void belle_sip_client_transaction_send_request(belle_sip_client_transaction_t *t
belle_sip_stack_get_next_hop(prov->stack,t->base.request,&hop);
chan=belle_sip_provider_get_channel(prov,hop.host, hop.port, hop.transport);
if (chan){
belle_sip_provider_add_client_transaction(t->base.provider,t);
belle_sip_object_ref(chan);
belle_sip_channel_add_listener(chan,BELLE_SIP_CHANNEL_LISTENER(t));
t->base.channel=chan;
......@@ -220,6 +221,8 @@ void belle_sip_client_transaction_send_request(belle_sip_client_transaction_t *t
belle_sip_channel_prepare(chan);
if (belle_sip_channel_get_state(chan)!=BELLE_SIP_CHANNEL_READY){
belle_sip_message("belle_sip_client_transaction_send_request(): waiting channel to be ready");
} else {
BELLE_SIP_OBJECT_VPTR(t,belle_sip_client_transaction_t)->send_request(t);
}
}else belle_sip_error("belle_sip_client_transaction_send_request(): no channel available");
belle_sip_hop_free(&hop);
......@@ -253,7 +256,6 @@ static void on_channel_state_changed(belle_sip_channel_listener_t *l, belle_sip_
belle_sip_message("transaction on_channel_state_changed");
switch(state){
case BELLE_SIP_CHANNEL_READY:
belle_sip_provider_add_client_transaction(t->base.provider,t);
BELLE_SIP_OBJECT_VPTR(t,belle_sip_client_transaction_t)->send_request(t);
break;
default:
......
......@@ -144,6 +144,21 @@ static void register_test(const char *transport, int use_transaction) {
belle_sip_stack_sleep(stack,33000);
CU_ASSERT_EQUAL(is_register_ok,1);
CU_ASSERT_EQUAL(using_transaction,use_transaction);
/*unregister*/
is_register_ok=0;
using_transaction=0;
belle_sip_header_cseq_t* cseq=(belle_sip_header_cseq_t*)belle_sip_message_get_header((belle_sip_message_t*)req,BELLE_SIP_CSEQ);
belle_sip_header_cseq_set_seq_number(cseq,belle_sip_header_cseq_get_seq_number(cseq)+1);
belle_sip_header_expires_t* expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_EXPIRES);
belle_sip_header_expires_set_expires(expires_header,0);
if (use_transaction){
belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t);
}else belle_sip_provider_send_request(prov,req);
belle_sip_stack_sleep(stack,33000);
CU_ASSERT_EQUAL(is_register_ok,1);
CU_ASSERT_EQUAL(using_transaction,use_transaction);
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