From a0909c7b51feedabda52faedfd0ec6d5f70b2c89 Mon Sep 17 00:00:00 2001
From: xietangxin <xietangxin@huawei.com>
Date: Mon, 29 Apr 2024 19:45:29 +0800
Subject: [PATCH] fix segmentation fault when setting out_channel of metrics to
 logs

---
 src/daemon/daemon.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 84d9a09..4891ef2 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -127,12 +127,16 @@ int DaemonRun(ResourceMgr *mgr)
     INFO("[DAEMON] create egress thread success.\n");
 
     // 3. start web_server thread
-    ret = pthread_create(&mgr->web_server_mgr->tid, NULL, DaemonRunWebServer, mgr->web_server_mgr);
-    if (ret != 0) {
-        ERROR("[DAEMON] create web_server thread failed.(errno:%d, %s)\n", errno, strerror(errno));
-        return -1;
+    if (mgr->web_server_mgr == NULL) {
+        INFO("[DAEMON] skip create web_server thread.\n");
+    } else {
+        ret = pthread_create(&mgr->web_server_mgr->tid, NULL, DaemonRunWebServer, mgr->web_server_mgr);
+        if (ret != 0) {
+            ERROR("[DAEMON] create web_server thread failed.(errno:%d, %s)\n", errno, strerror(errno));
+            return -1;
+        }
+        INFO("[DAEMON] create web_server thread success.\n");
     }
-    INFO("[DAEMON] create web_server thread success.\n");
 
     // 4. start metadata_report thread
     ret = pthread_create(&mgr->mmMgr->tid, NULL, DaemonRunMetadataReport, mgr->mmMgr);
-- 
2.28.0.windows.1

