diff seobeo/os/s_linux_edge.c @ 71:75de5903355c

Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
author June Park <parkjune1995@gmail.com>
date Sun, 28 Dec 2025 20:34:22 -0800
parents a0f0ad5e42eb
children 48f260576059
line wrap: on
line diff
--- a/seobeo/os/s_linux_edge.c	Thu Dec 25 20:10:46 2025 -0800
+++ b/seobeo/os/s_linux_edge.c	Sun Dec 28 20:34:22 2025 -0800
@@ -70,7 +70,7 @@
 void Seobeo_Web_Edge(
     Seobeo_Handle *p_server_handle,
     int thread_count,
-    Dowa_HashMap *p_html_cache)
+    Seobeo_Cache_Entry *p_html_cache)
 {
   pthread_attr_t attr;
   pthread_attr_init(&attr);
@@ -91,96 +91,3 @@
 
   pthread_attr_destroy(&attr);
 }
-
-
-void Seobeo_Web_Edge_2(Seobeo_Handle *p_handle_server, Dowa_HashMap *cache)
-{
-  const int MAX_EVENTS = 1024;
-  struct epoll_event events[MAX_EVENTS];
-  char keybuf[32];
-
-  int epfd = epoll_create1(0);
-  if (epfd < 0)
-  {
-    perror("epoll_create1");
-    return;
-  }
-
-  struct epoll_event ev = {
-    .events = EPOLLIN | EPOLLET,
-    .data.fd = p_handle_server->socket
-  };
-  if (epoll_ctl(epfd, EPOLL_CTL_ADD, p_handle_server->socket, &ev) < 0)
-  {
-    perror("epoll_ctl ADD server");
-    close(epfd);
-    return;
-  }
-
-  Dowa_HashMap *handles = Dowa_HashMap_Create(1024);
-  snprintf(keybuf, sizeof(keybuf), "%d", p_handle_server->socket);
-  Dowa_HashMap_Push_Value(handles, keybuf, p_handle_server, sizeof(p_handle_server));
-
-  while (1) {
-    int n = epoll_wait(epfd, events, MAX_EVENTS, -1);
-    if (n < 0)
-    {
-      if (errno == EINTR) continue;
-      perror("epoll_wait");
-      break;
-    }
-
-    for (int i = 0; i < n; i++)
-    {
-      int fd = events[i].data.fd;
-
-      if (fd == p_handle_server->socket)
-      {
-        while (1)
-        {
-          Seobeo_Handle *p_handle_client = Seobeo_Stream_Handle_Server_Accept(p_handle_server);
-          if (!p_handle_client) break;
-
-          struct epoll_event client_ev = {
-            .events = EPOLLIN | EPOLLET,
-            .data.fd = p_handle_client->socket
-          };
-          if (epoll_ctl(epfd, EPOLL_CTL_ADD, p_handle_client->socket, &client_ev) < 0)
-          {
-            perror("epoll_ctl ADD client");
-            Seobeo_Handle_Destroy(p_handle_client); 
-            continue;
-          }
-
-          snprintf(keybuf, sizeof(keybuf), "%d", p_handle_client->socket);
-          if (p_handle_client)
-              Dowa_HashMap_Push_Value_With_Type_NoCopy(handles, keybuf, p_handle_client,
-                                                       sizeof(p_handle_client), DOWA_HASH_MAP_TYPE_HASHMAP);
-        }
-        continue;
-      }
-
-      snprintf(keybuf, sizeof(keybuf), "%d", fd);
-      Seobeo_Handle *p_handle_client = Dowa_HashMap_Get(handles, keybuf);
-      if (!p_handle_client)
-      {
-        // might happen if client closed between event and lookup
-        epoll_ctl(epfd, EPOLL_CTL_DEL, fd, NULL);
-        continue;
-      }
-
-      // Remove from epoll
-      epoll_ctl(epfd, EPOLL_CTL_DEL, fd, NULL);
-
-      // Handle request (this function destroys the handle internally)
-      Seobeo_Web_HandleClientRequest(p_handle_client, cache);
-
-      // Remove from hashmap (handle is already destroyed by HandleClientRequest)
-      Dowa_HashMap_Pop_Key(handles, keybuf);
-    }
-  }
-
-  close(epfd);
-  Dowa_HashMap_Destroy(handles);
-}
-