Merge "[Bugfix][T106BUG-454][AUTOSUSPEND]find Segmentation fault when deinit after deinit"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
index ea9b381..01ccd5d 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
@@ -32,7 +32,7 @@
 #define UEVENT_MSG_LEN 128
 
 int device_fd;
-
+int g_init_flag = 0;
 struct dtr_uevent {
     const char *action;
     const char *path;
@@ -317,12 +317,17 @@
 {
     int ret;
     int num;
-
+    if(g_init_flag != 0)
+    {
+        LYERRLOG("g_init_flag is error\n");
+        return -1;
+    }
+    g_init_flag = 1;
     g_lpm_handler = qser_lpm_handler;
     ret = pthread_create(&thid,NULL,check_dtr,NULL);
     if(ret != 0)
     {
-        LYERRLOG("restart service fail");
+        LYERRLOG("pthread create fail, qser_lpm_init fail\n");
     }
     return ret;
 }
@@ -331,6 +336,12 @@
 int qser_lpm_deinit(void)
 {
     int ret;
+    if(g_init_flag != 1)
+    {
+        LYERRLOG("g_init_flag is error");
+        return -1;
+    }
+    g_init_flag = 0;
     ret = pthread_cancel(thid);
     close(device_fd);
     if(!ret)