[Bugfix][T106bug-413]Using lynq-systime-demo rtc_set for more than 256 times will fail

Only Configure:No
Affected branch:master
Affected module:systime
Is it affected on both ZXIC and MTK:Only ZXIC
Self-test:Yes
Doc Update:No

Change-Id: Ieb19c7428c2ab22d56c70acca6969569c0dca48c
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
index fb00165..d349bd5 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
@@ -64,6 +64,8 @@
 extern int sc_rtc_time_get(int srcid, sc_rtc_time_get_cb rtc_notify);

 extern int sc_cfg_get(char *name, char* buf, int bufLen);

 extern int sc_cfg_set (char *name, char *value);

+extern int get_terminate_flag(void);

+

 

 

 char sync_from_rtc_cb_flag = 1;

@@ -230,6 +232,7 @@
     int ret = -1;

     int srcid = -1;

     int i = 0;

+    int count = 0;

     if ((srcid = sc_rtc_timer_init()) <= 0)

     {

         LYERRLOG("rtc_timer_demo:rtc_timer_init fail!\n");

@@ -264,6 +267,12 @@
         LYERRLOG("uninit failed \n");

         return -1;

     }

+    //xy.he add for T106BUG-413 2024-01-04

+    while((get_terminate_flag() == 0) && (count <100))

+    {

+        usleep(10*1000);

+        count ++;

+    }

     return 0;

 }

 

@@ -274,6 +283,7 @@
     LYDBGLOG("[%s][%d] enter.\n", __FUNCTION__, __LINE__);

     int ret = -1;

     int srcid = -1;

+    int count = 0;

     if ((srcid = sc_rtc_timer_init()) <= 0)

     {

         LYERRLOG("rtc_timer_demo:rtc_timer_init fail!\n");

@@ -291,7 +301,13 @@
         LYERRLOG("uninit failed \n");

         return -1;

     }

-    usleep(5000);

+    //xy.he add for T106BUG-413 2024-01-04

+    while((get_terminate_flag() == 0) && (count <100))

+    {

+        usleep(10*1000);

+        count ++;

+    }

+    printf("lynq_set_rtc_time_success\n");

     return 0;

 }

 

@@ -303,6 +319,7 @@
     int ret = -1;

     int srcid = -1;

     int i = 0;

+    int count = 0;

     if (NULL == ulsec)

     {

         LYERRLOG("NULL parameter!\n");

@@ -341,6 +358,12 @@
         LYERRLOG("uninit failed \n");

         return -1;

     }

+    //xy.he add for T106BUG-413 2024-01-04

+    while((get_terminate_flag() == 0) && (count <100))

+    {

+        usleep(10*1000);

+        count ++;

+    }

     return 0;

 }

 #endif

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile
index d0e37e8..20fc50a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile
@@ -38,6 +38,7 @@
     -llynq-uci \

     -llynq-log \

     -lnvram \

+    -lscipc \

 

 

 SOURCES = $(wildcard *.cpp)

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
index 7b32b99..04dc0c4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
@@ -52,6 +52,8 @@
 static int s_local_fd = -1;

 static int s_local_key = -1;

 static int s_remote_fd = -1;

+//xy.he add for T106BUG-413 2024-01-04

+int terminate_loop_flag = 0;

 

 static pthread_t s_tid_dispatch;

 //static pthread_t s_tid_reader;

@@ -284,6 +286,8 @@
 

 	pthread_mutex_lock(&s_startupMutex);

     s_started = 1;

+    //xy.he add for T106BUG-413 2024-01-04

+    terminate_loop_flag = 0;

     pthread_cond_broadcast(&s_startupCond);

     pthread_mutex_unlock(&s_startupMutex);

 	

@@ -311,7 +315,9 @@
 

     if(-1 != s_local_fd)

         sc_ipc_destroy_msg_fd(s_local_fd);

-

+    //xy.he add for T106BUG-413 2024-01-04

+    terminate_loop_flag = 1;

+    

     return (void*)0;

 }

 

@@ -641,7 +647,7 @@
     int ret = 0;

     sc_ipc_msg msg = {0};

 

-	if(s_started)

+	if(!s_started)

 		goto Done;

 

     msg.type = 0;

@@ -680,3 +686,10 @@
 	return;

 }

 

+//xy.he add for T106BUG-413 2024-01-04

+int get_terminate_flag()

+{

+    return terminate_loop_flag;

+}

+

+