[bugfix]api-80
Change-Id: Ifdc971baf0a76e114d4df368d5265775ae426763
diff --git a/lib/liblynq-call/lynq_call.cpp b/lib/liblynq-call/lynq_call.cpp
index 0b4ae92..a72566c 100755
--- a/lib/liblynq-call/lynq_call.cpp
+++ b/lib/liblynq-call/lynq_call.cpp
@@ -64,8 +64,8 @@
static pthread_cond_t s_urc_call_state_change_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t s_incoming_call_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t s_incoming_call_cond = PTHREAD_COND_INITIALIZER;
-pthread_t lynq_call_urc_tid;
-pthread_t lynq_call_list_loop_tid;
+pthread_t lynq_call_urc_tid = -1;
+pthread_t lynq_call_list_loop_tid = -1;
/*lei add*/
/* socket文件描述符 */
@@ -110,6 +110,12 @@
bool call_list_loop = 1;
int isDial = 0;
int lynqIncomingCallId = 0;
+/**
+ * @brief mark call initialization state
+ * 0: deinit state
+ * 1: init state
+ */
+int g_lynq_call_init_flag = 0;
int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error)
{
@@ -596,7 +602,12 @@
printf("call state change,sim:%d\n",soc_id);
}
int lynq_init_call(int uToken)
-{
+{
+ if(g_lynq_call_init_flag == 1){
+ LYDBGLOG("lynq init call failed!!!");
+ return -1;
+ }
+ g_lynq_call_init_flag = 1;
int result = 0;
Global_uToken_call = uToken;
urc_call_recive_status = 1;
@@ -624,22 +635,35 @@
}
int lynq_deinit_call()
{
- int ret = -1;
- if(lynq_call_client_sockfd>0)
+ if(g_lynq_call_init_flag == 0)
{
- close(lynq_call_client_sockfd);
+ LYDBGLOG("lynq_deinit_call failed!!!");
+ return -1;
}
- urc_call_recive_status = 0;
- call_list_loop = 0;
- ret = pthread_cancel(lynq_call_urc_tid);
- LYDBGLOG("pthread cancel ret = %d",ret);
- ret = pthread_cancel(lynq_call_list_loop_tid);
- LYDBGLOG("pthread cancel ret = %d",ret);
- ret = pthread_join(lynq_call_urc_tid,NULL);
- LYDBGLOG("pthread join ret = %d",ret);
- ret = pthread_join(lynq_call_list_loop_tid,NULL);
- LYDBGLOG("pthread join ret = %d",ret);
- return 0;
+ else
+ {
+ g_lynq_call_init_flag = 0;
+ int ret = -1;
+ if(lynq_call_client_sockfd>0)
+ {
+ close(lynq_call_client_sockfd);
+ }
+ urc_call_recive_status = 0;
+ call_list_loop = 0;
+ if(lynq_call_urc_tid == -1 || lynq_call_list_loop_tid == -1)
+ {
+ return -1;
+ }
+ ret = pthread_cancel(lynq_call_urc_tid);
+ LYDBGLOG("pthread cancel ret = %d",ret);
+ ret = pthread_cancel(lynq_call_list_loop_tid);
+ LYDBGLOG("pthread cancel ret = %d",ret);
+ ret = pthread_join(lynq_call_urc_tid,NULL);
+ LYDBGLOG("pthread join ret = %d",ret);
+ ret = pthread_join(lynq_call_list_loop_tid,NULL);
+ LYDBGLOG("pthread join ret = %d",ret);
+ return 0;
+ }
}
int lynq_call(int* handle,char addr[])
{