[Bugfix]add mutex to data and sms

Change-Id: I280974cb0f6a8609c4d0720041910c2a0abbfaa6
diff --git a/src/lynq/lib/liblynq-data/lynq_data.cpp b/src/lynq/lib/liblynq-data/lynq_data.cpp
index a20513a..220463a 100755
--- a/src/lynq/lib/liblynq-data/lynq_data.cpp
+++ b/src/lynq/lib/liblynq-data/lynq_data.cpp
@@ -59,6 +59,11 @@
 static pthread_mutex_t s_lynq_apn_change_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t s_lynq_apn_change_cond = PTHREAD_COND_INITIALIZER;
 
+/**g_lynq_data_sendto_mutex
+* @brief mark data send request mutex
+*/
+static pthread_mutex_t g_lynq_data_sendto_mutex;
+
 /**g_lynq_data_init_flag
 * @brief mark data initialization state
 * 0:deinit status
@@ -515,6 +520,7 @@
     LYLOGSET(LOG_INFO);
     LYLOGEINIT(USER_LOG_TAG);
     result = lynq_socket_client_start();
+    pthread_mutex_init(&g_lynq_data_sendto_mutex, NULL);
     if(result!=0)
     {
         LYERRLOG("init socket client fail!!!");
@@ -581,6 +587,7 @@
     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_data_sendto_mutex);
     if(send_request(lynq_client_sockfd,&client)==-1)
     {
         LYERRLOG("send request fail");
@@ -588,6 +595,7 @@
         return -1;
     }
     get_response(lynq_client_sockfd,p);
+    pthread_mutex_unlock(&g_lynq_data_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);
     lynq_data_call_id = updateApn("default");
@@ -634,6 +642,7 @@
         sprintf(client.param,"%s",lynq_apn_table[lynq_data_call_id].apnType);
     }
     LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+    pthread_mutex_lock(&g_lynq_data_sendto_mutex);
     if(send_request(lynq_client_sockfd,&client)==-1)
     {
         LYERRLOG("send request fail");
@@ -641,6 +650,7 @@
         return -1;
     }
     get_response(lynq_client_sockfd,p);
+    pthread_mutex_unlock(&g_lynq_data_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);
     cleanOnceApnTable(lynq_data_call_id);
@@ -708,6 +718,7 @@
     bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
     sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],argv[5]);
     LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+    pthread_mutex_lock(&g_lynq_data_sendto_mutex);
     if(send_request(lynq_client_sockfd,&client)==-1)
     {
         LYERRLOG("send request fail");
@@ -715,6 +726,7 @@
         return -1;
     }
     get_response(lynq_client_sockfd,p);
+    pthread_mutex_unlock(&g_lynq_data_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);
     lynq_data_call_id = updateApn(apnType);
@@ -786,6 +798,7 @@
     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_data_sendto_mutex);
     if(send_request(lynq_client_sockfd,&client)==-1)
     {
         LYERRLOG("send request fail");
@@ -793,6 +806,7 @@
         return -1;
     }
     get_response(lynq_client_sockfd,p);
+    pthread_mutex_unlock(&g_lynq_data_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);
     p.readInt32(&version);
@@ -1103,11 +1117,13 @@
         return -1;
     }
     LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+    pthread_mutex_lock(&g_lynq_data_sendto_mutex);
     if(send_request(lynq_client_sockfd,&client)==-1)
     {
         LYERRLOG("send request fail");
         return -1;
     }
+    pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
     waitApnResult();
     strcpy(out, g_lynq_apn_result);
     LYINFLOG(">>>>>output info:%s",out);
@@ -1127,11 +1143,13 @@
     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_data_sendto_mutex);
     if (send_request(lynq_client_sockfd, &client) == -1)
     {
         LYERRLOG("send request fail");
         return -1;
     }
+    pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
     waitApnResult();
     strcpy(result, g_lynq_apn_result);
     LYINFLOG(">>>>>result:%s",result);