Commit 778fbca5 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

http-provider.c: instead of using the same channel for all requests for a...

http-provider.c: instead of using the same channel for all requests for a given host, only use it if it is not busy to avoid requests being discarded
parent 5766cffb
......@@ -293,6 +293,20 @@ belle_http_channel_context_t * belle_http_channel_context_new(belle_sip_channel_
return obj;
int belle_http_channel_is_busy(belle_sip_channel_t *obj) {
belle_sip_list_t *it;
if (obj->incoming_messages != NULL || obj->outgoing_messages != NULL) {
return 1;
for (it = obj->listeners; it != NULL; it = it->next) {
if (BELLE_SIP_IS_INSTANCE_OF(it->data, belle_http_channel_context_t)) {
belle_http_channel_context_t *obj = it->data;
return obj->pending_requests != NULL;
return 0;
......@@ -391,6 +405,15 @@ int belle_http_provider_send_request(belle_http_provider_t *obj, belle_http_requ
chan=belle_sip_channel_find_from_list(*channels,obj->ai_family, hop);
if (chan) {
// we cannot use the same channel for multiple requests yet since only the first
// one will be processed. Instead of queuing/serializing requests on a single channel,
// we currently create one channel per request if needed.
if (belle_http_channel_is_busy(chan)) {
belle_sip_message("%s: found an available channel but was busy, creating a new one", __FUNCTION__);
chan = NULL;
if (!chan){
if (strcasecmp(hop->transport,"tcp")==0){
......@@ -401,7 +424,8 @@ int belle_http_provider_send_request(belle_http_provider_t *obj, belle_http_requ
if (!chan){
belle_sip_error("belle_http_provider_send_request(): cannot create channel for [%s:%s:%i]",hop->transport,hop->cname,hop->port);
belle_sip_error("%s: cannot create channel for [%s:%s:%i]", __FUNCTION__, hop->transport, hop->cname,
return -1;
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