[Feature][T8TSK-54][Call]Sending send at the same time blocks subsequent apis
[Feature][T8TSK-30][Call]Set timeout to 60 by default
Change-Id: I2bbe0c00d52f72f63e22154241a038e96a4c0a26
diff --git a/src/lynq/lib/liblynq-call/lynq_call.cpp b/src/lynq/lib/liblynq-call/lynq_call.cpp
index 07a81d8..0775118 100755
--- a/src/lynq/lib/liblynq-call/lynq_call.cpp
+++ b/src/lynq/lib/liblynq-call/lynq_call.cpp
@@ -1,3 +1,4 @@
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -75,6 +76,7 @@
static pthread_cond_t *s_urc_call_state_change_cond = NULL;
static pthread_mutex_t s_incoming_call_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t s_incoming_call_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t g_lynq_call_sendto_mutex;
pthread_t lynq_call_urc_tid = -1;
pthread_t lynq_call_list_loop_tid = -1;
@@ -690,6 +692,14 @@
{
return lynq_call_client_sockfd;
}
+ struct timeval timeOut;
+ timeOut.tv_sec = 60;
+ timeOut.tv_usec = 0;
+ if (setsockopt(lynq_call_client_sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0)
+ {
+ RLOGD("time out setting failed\n");
+ return -1;
+ }
/* 设置address */
memset(&addr_serv, 0, sizeof(addr_serv));
addr_serv.sin_family = AF_INET;
@@ -1173,6 +1183,7 @@
strcat(client.param," 0");
lynq_call_id = addAddr(addr);
LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&g_lynq_call_sendto_mutex);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
@@ -1180,6 +1191,7 @@
return -1;
}
get_response(lynq_call_client_sockfd,p);
+ pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
if(error==0)
@@ -1226,12 +1238,14 @@
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&g_lynq_call_sendto_mutex);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
get_response(lynq_call_client_sockfd,p);
+ pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
return error;
@@ -1258,12 +1272,14 @@
call_id = *handle;
sprintf(client.param,"%d",call_id);
LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&g_lynq_call_sendto_mutex);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
get_response(lynq_call_client_sockfd,p);
+ pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
if(error==0)
@@ -1289,12 +1305,14 @@
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&g_lynq_call_sendto_mutex);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
get_response(lynq_call_client_sockfd,p);
+ pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
return error;
@@ -1394,12 +1412,14 @@
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&g_lynq_call_sendto_mutex);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
get_response(lynq_call_client_sockfd,p);
+ pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
return error;
@@ -1418,12 +1438,14 @@
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&g_lynq_call_sendto_mutex);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
get_response(lynq_call_client_sockfd,p);
+ pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
return error;
@@ -1442,12 +1464,14 @@
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&g_lynq_call_sendto_mutex);
if(send_request(lynq_call_client_sockfd,&client)==-1)
{
LYERRLOG("send request fail");
return -1;
}
get_response(lynq_call_client_sockfd,p);
+ pthread_mutex_unlock(&g_lynq_call_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
return error;