summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2023-07-24 16:58:30 +0800
committeryangwei <[email protected]>2023-07-24 16:58:30 +0800
commit9d9b3f689f33bc13cfdc50c49ef6e6cf9c0dc682 (patch)
tree71cab81888ebf7661f7f7b3c24f82451c8dc7f0e
parentc97be84ec7cc4847ace846bb96a8714ad201f2f2 (diff)
🐞 fix(sapp_watch_dog): 更新检测到死锁触发退出条件,并增加相关日志
从exit改为abort,保留现场死锁堆栈
-rw-r--r--src/timer/sapp_timer.c19
-rw-r--r--test/test_app_sapp.c5
2 files changed, 20 insertions, 4 deletions
diff --git a/src/timer/sapp_timer.c b/src/timer/sapp_timer.c
index 00b6d52..8771a3d 100644
--- a/src/timer/sapp_timer.c
+++ b/src/timer/sapp_timer.c
@@ -451,8 +451,16 @@ static void sapp_watch_dog(void)
{
deadlock_detected=1;
check_result = "WATCHDOG=trigger";
- sapp_runtime_log(RLOG_LV_FATAL, "##### detect deadlock in PID:%ld, at timestamp:%ld, thread index:%d, TID(LWP):%u, send systemd notify WATCHDOG=trigger #####",
- getpid(), ABBR_CURRENT_TIME, thread_index, sapp_global_val->individual_fixed.thread_tid[thread_index]);
+ if(sd_notify_enable)
+ {
+ sapp_runtime_log(RLOG_LV_FATAL, "##### detect deadlock in PID:%ld, at timestamp:%ld, thread index:%d, TID(LWP):%u, sd_notify_enable:%d, deadlock_detected:%d, deadlock_cnt:%d, send systemd notify WATCHDOG=trigger #####",
+ getpid(), ABBR_CURRENT_TIME, thread_index, sapp_global_val->individual_fixed.thread_tid[thread_index], sd_notify_enable, deadlock_detected, deadlock_cnt);
+ }
+ else
+ {
+ sapp_runtime_log(RLOG_LV_FATAL, "##### detect deadlock in PID:%ld, at timestamp:%ld, thread index:%d, TID(LWP):%u, sd_notify_enable:%d, deadlock_detected:%d, deadlock_cnt:%d #####",
+ getpid(), ABBR_CURRENT_TIME, thread_index, sapp_global_val->individual_fixed.thread_tid[thread_index], sd_notify_enable, deadlock_detected, deadlock_cnt);
+ }
break;
}
@@ -468,9 +476,12 @@ static void sapp_watch_dog(void)
{
if(deadlock_detected)
{
- if(deadlock_cnt++ > 10)
+ deadlock_cnt+=1;
+ if(deadlock_cnt > 10)
{
- exit(-1);
+ sapp_runtime_log(RLOG_LV_FATAL, "##### detect deadlock in PID:%ld, at timestamp:%ld, thread index:%d, TID(LWP):%u, sd_notify_enable:%d, deadlock_detected:%d, deadlock_cnt:%d, Trigger ABORT #####",
+ getpid(), ABBR_CURRENT_TIME, thread_index, sd_notify_enable, deadlock_detected, deadlock_cnt, sapp_global_val->individual_fixed.thread_tid[thread_index]);
+ abort();
}
}
else
diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c
index 52c0083..13897db 100644
--- a/test/test_app_sapp.c
+++ b/test/test_app_sapp.c
@@ -1099,7 +1099,12 @@ test_set_stream_timeout(pstream, pme, thread_seq, a_packet);
}
return APP_STATE_GIVEME;
}
+char test_deadlock(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
+{
+ sleep(12);
+ return APP_STATE_GIVEME;
+}
/* 关于网络相关字�??, 均为网络�? network order */
struct __test_inline_vxlan_hdr{