Merge "[Bugfix][API-622][pcie]Test pcie with at command returns error" into MR3.0
diff --git a/src/telephonyware/3.0/libvendor-ril/mtk-rilproxy/socket_channel.cpp b/src/telephonyware/3.0/libvendor-ril/mtk-rilproxy/socket_channel.cpp
old mode 100644
new mode 100755
index d7558a9..15a17ab
--- a/src/telephonyware/3.0/libvendor-ril/mtk-rilproxy/socket_channel.cpp
+++ b/src/telephonyware/3.0/libvendor-ril/mtk-rilproxy/socket_channel.cpp
@@ -105,11 +105,59 @@
RLOGD("[unlockMutex]name=%s", semName[socket_id]);\
sem_close(sem);\
} while(0)
+/*warren modfiy for fix bug API-614 on 2022/10/11 start*/
+int lynq_sem_timedwait(int mtime,sem_t * sem);
+
+#define lynq_sp_lockMutex(socket_id) {\
+ RLOGD("[lockMutex] name=%s", semName[socket_id]);\
+ int sem_v = -1;\
+ sem = sem_open(semName[socket_id], O_CREAT, 0644, 1);\
+ if(SEM_FAILED == sem){\
+ RLOGD("[ lockMutex]sem_open failed, errno = %d (%s)", errno, strerror(errno));\
+ exit(1);\
+ }\
+ sem_getvalue(sem,&sem_v);\
+ if(sem_v == 0)\
+ {\
+ RLOGD("lynq_sp_lockMutex sem_v == 0");\
+ lynq_sem_timedwait(2000,sem);\
+ /*if sem value == 0,wait 2s, then return*/\
+ }\
+ else\
+ {\
+ RLOGD("lynq_sp_lockMutex sem_v == %d",sem_v);\
+ sem_wait(sem);\
+ }\
+ }while(0)
+
+int lynq_sem_timedwait(int mtime,sem_t * sem)
+{
+ RLOGD("[%s]line %d",__FUNCTION__,__LINE__);
+ int sec = 0;
+ int usec = 0;
+ int s = 0;
+ struct timeval now;
+ struct timespec timeout;
+ gettimeofday(&now,NULL);
+ sec = mtime/1000;
+ usec = mtime%1000;
+ timeout.tv_sec = now.tv_sec+sec;
+ timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
+ RLOGD("lynq_sem_timedwait about to call sem_timedwait()");
+ while ((s = sem_timedwait(sem, &timeout)) == -1 && errno == EINTR)
+ {
+ continue; /* Restart if interrupted by handler */
+ }
+ return 0;
+}
+
+/*warren modfiy for fix bug API-614 on 2022/10/11 end*/
#endif
+
extern "C"
void setRadioState(RIL_RadioState newState, RIL_SOCKET_ID rid);
@@ -555,7 +603,16 @@
#else //DSDS and MT2635
for(i=0; i<RIL_SOCKET_NUM; i++) {
#if defined(TELEPHONYWARE)
- lockMutex(i);
+ /*warren modfiy for fix bug API-614 on 2022/10/11 start*/
+ /*
+ **The cause of this problem is the global semaphore deadlock.
+ **When ril_socket_init is initialized to lock in a very coincidental situation,
+ **the process hangs and is not unlocked, so a deadlock scene occurs.
+ **Only restart can restore.
+ */
+ lynq_sp_lockMutex(i);
+ //lockMutex(i);
+ /*warren modfiy for fix bug API-614 on 2022/10/11 end*/
#endif
socketName = RilpSocketUtil::getSocketName(RADIO_TECH_GROUP_GSM, RIL_SOCKET_ID(i));
#if defined(TELEPHONYWARE)