aboutsummaryrefslogtreecommitdiff
path: root/src/net.c
diff options
context:
space:
mode:
authorame <[email protected]>2024-11-07 01:47:00 -0600
committerame <[email protected]>2024-11-07 01:47:00 -0600
commitdd6c0b6b3333f287dcd0886f8a0551f283948505 (patch)
tree967134a4369fff5f6297b2a6108bc950fcf4ebbe /src/net.c
parent94d76d9e7ed5cb9273169babfa27e60fb28c4104 (diff)
fix two errors/'crashes'
Diffstat (limited to 'src/net.c')
-rw-r--r--src/net.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/net.c b/src/net.c
index 7f94047..7cc3b12 100644
--- a/src/net.c
+++ b/src/net.c
@@ -5,7 +5,7 @@
#define max_uri_size 2048
-volatile size_t threads = 0;
+_Atomic size_t threads = 0;
void* handle_client(void *_arg){
//printf("--\n");
//pthread_mutex_lock(&mutex);
@@ -313,7 +313,6 @@ int start_serv(lua_State* L, int port){
if (pthread_mutex_init(&con_mutex, NULL) != 0)
p_fatal("con_mutex init failed\n");
- int count = 0;
for(;;){
struct sockaddr_in client_addr;
socklen_t client_addr_len = sizeof(client_addr);
@@ -322,7 +321,7 @@ int start_serv(lua_State* L, int port){
if((*client_fd = accept(server_fd, (struct sockaddr*)&client_addr, &client_addr_len)) < 0)
p_fatal("failed to accept\n");
- if(count >= max_con){
+ if(threads >= max_con){
//deny request
net_error(*client_fd, 503);
close(*client_fd);
@@ -330,7 +329,6 @@ int start_serv(lua_State* L, int port){
continue;
}
- count++;
//open a state to call shit, should be somewhat thread safe
thread_arg_struct* args = malloc(sizeof * args);