Skip to content

Commit d5bc10e

Browse files
committed
Fix MacOS hang
1 parent 03ef7b1 commit d5bc10e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

include/slick/socket/tcp_server_unix.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,12 @@ void TCPServerBase<DerivedT>::server_loop()
285285

286286
while (running_.load())
287287
{
288-
// Wait for events with 1 second timeout
289-
int num_events = kevent(epoll_fd_, nullptr, 0, events, MAX_EVENTS, nullptr);
288+
// Set timeout to 1us to allow checking running_ flag
289+
struct timespec timeout;
290+
timeout.tv_sec = 0;
291+
timeout.tv_nsec = 1000; // 1us
292+
293+
int num_events = kevent(epoll_fd_, nullptr, 0, events, MAX_EVENTS, &timeout);
290294
if (num_events < 0)
291295
{
292296
if (errno == EINTR)
@@ -349,7 +353,6 @@ void TCPServerBase<DerivedT>::server_loop()
349353

350354
while (running_.load())
351355
{
352-
// Wait for events with 1 second timeout
353356
int num_events = epoll_wait(epoll_fd_, events, MAX_EVENTS, 0);
354357
if (num_events < 0)
355358
{

0 commit comments

Comments
 (0)