Mercurial
comparison seobeo/os/s_macos_edge.c @ 16:fb2cff495a60
[Seobeo] Fixed the problem with edge server.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 03 Oct 2025 09:55:51 -0700 |
| parents | 114cad94008f |
| children | d97ec3ded2ae |
comparison
equal
deleted
inserted
replaced
| 15:2b9e75756825 | 16:fb2cff495a60 |
|---|---|
| 16 Seobeo_Stream_Handle_Accept(args->srv); | 16 Seobeo_Stream_Handle_Accept(args->srv); |
| 17 if (!cli) continue; | 17 if (!cli) continue; |
| 18 struct kevent kev = { | 18 struct kevent kev = { |
| 19 .ident = cli->socket, | 19 .ident = cli->socket, |
| 20 .filter = EVFILT_READ, | 20 .filter = EVFILT_READ, |
| 21 .flags = EV_ADD, | 21 .flags = EV_ADD | EV_ONESHOT, |
| 22 .udata = cli | 22 .udata = cli |
| 23 }; | 23 }; |
| 24 kevent(args->evfd, &kev, 1, NULL, 0, NULL); | 24 kevent(args->evfd, &kev, 1, NULL, 0, NULL); |
| 25 } else { | 25 } else { |
| 26 Seobeo_Web_HandleClientRequest(h, args->cache); | 26 if (h != args->srv) { |
| 27 struct kevent kev = { | 27 struct kevent kev = { |
| 28 .ident = h->socket, | 28 .ident = h->socket, |
| 29 .filter = EVFILT_READ, | 29 .filter = EVFILT_READ, |
| 30 .flags = EV_DELETE, | 30 .flags = EV_DELETE, |
| 31 }; | 31 }; |
| 32 kevent(args->evfd, &kev, 1, NULL, 0, NULL); | 32 kevent(args->evfd, &kev, 1, NULL, 0, NULL); // Remove from kqueue first |
| 33 Seobeo_Handle_Destroy(h); | 33 |
| 34 Seobeo_Web_HandleClientRequest(h, args->cache); // this frees | |
| 35 } | |
| 34 } | 36 } |
| 35 } | 37 } |
| 36 } | 38 } |
| 37 return NULL; | 39 return NULL; |
| 38 } | 40 } |
| 54 pthread_attr_t attr; | 56 pthread_attr_t attr; |
| 55 pthread_attr_init(&attr); | 57 pthread_attr_init(&attr); |
| 56 pthread_attr_setstacksize(&attr, 100 * 1024 * 1024); // 100 MB | 58 pthread_attr_setstacksize(&attr, 100 * 1024 * 1024); // 100 MB |
| 57 | 59 |
| 58 pthread_t threads[thread_count]; | 60 pthread_t threads[thread_count]; |
| 59 WorkerArgs args = { p_server_handle, p_html_cache, kq }; | |
| 60 for (int i = 0; i < thread_count; i++) | 61 for (int i = 0; i < thread_count; i++) |
| 61 { | 62 { |
| 63 WorkerArgs *args = malloc(sizeof(WorkerArgs)); | |
| 64 *args = (WorkerArgs){ p_server_handle, p_html_cache, kq }; | |
| 62 pthread_create(&threads[i], NULL, | 65 pthread_create(&threads[i], NULL, |
| 63 Seobeo_Web_Edge_Worker, &args); | 66 Seobeo_Web_Edge_Worker, args); |
| 64 } | 67 } |
| 65 for (int i = 0; i < thread_count; i++) | 68 for (int i = 0; i < thread_count; i++) |
| 66 { | 69 { |
| 67 pthread_join(threads[i], NULL); | 70 pthread_join(threads[i], NULL); |
| 68 } | 71 } |