diff seobeo/os/s_macos_edge.c @ 33:c0f6c8c7829f

[Seobeo] Linux epoll. Set the client socket to be nonblocking so that it doesn't stop loading when two different threads handle different client calls. I might have problem with socket not being cleaned up properly so need to check that.
author MrJuneJune <me@mrjunejune.com>
date Fri, 10 Oct 2025 06:59:32 -0700
parents 875bb6e10db7
children ea9ef388ab97
line wrap: on
line diff
--- a/seobeo/os/s_macos_edge.c	Thu Oct 09 07:03:36 2025 -0700
+++ b/seobeo/os/s_macos_edge.c	Fri Oct 10 06:59:32 2025 -0700
@@ -6,14 +6,19 @@
 {
   WorkerArgs *args = vargs;
   struct kevent evlist[64];
-  while (1) {
+  while (1)
+  {
     int ne = kevent(args->evfd, NULL, 0, evlist, 64, NULL);
     if (ne < 0) continue;
-    for (int i = 0; i < ne; i++) {
+
+    for (int i = 0; i < ne; i++)
+    {
       Seobeo_PHandle h = evlist[i].udata;
-      if (h == args->srv) {
+      if (h == args->srv)
+      {
         Seobeo_PHandle cli =
           Seobeo_Stream_Handle_Server_Accept(args->srv);
+
         if (!cli) continue;
         struct kevent kev = {
           .ident  = cli->socket,
@@ -55,7 +60,7 @@
 
   pthread_attr_t attr;
   pthread_attr_init(&attr);
-  pthread_attr_setstacksize(&attr, 100 * 1024 * 1024); // 100 MB
+  pthread_attr_setstacksize(&attr, 5 * 1024 * 1024); // 5 MB
 
   pthread_t  threads[thread_count];
   for (int i = 0; i < thread_count; i++)