From cd08dff9e0cd0e01717d7cce2460c01f376b8234 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 6 Feb 2024 20:05:05 +0800
Subject: [PATCH 200/204] sleep some time in ServiceWorkThread to prevent the
 CPU from being occupied all the time

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 src/daemon/entry/cri/websocket/service/ws_server.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/daemon/entry/cri/websocket/service/ws_server.cc b/src/daemon/entry/cri/websocket/service/ws_server.cc
index d439dd96..a85e4a02 100644
--- a/src/daemon/entry/cri/websocket/service/ws_server.cc
+++ b/src/daemon/entry/cri/websocket/service/ws_server.cc
@@ -673,6 +673,8 @@ void WebsocketServer::ServiceWorkThread(int threadid)
 
     while (n >= 0 && !m_forceExit) {
         n = lws_service(m_context, 0);
+        // sleep some time to prevent the CPU from being occupied all the time
+        std::this_thread::sleep_for(std::chrono::milliseconds(10));
     }
 }
 
-- 
2.25.1

