diff options
| author | ame <[email protected]> | 2024-11-07 01:47:00 -0600 |
|---|---|---|
| committer | ame <[email protected]> | 2024-11-07 01:47:00 -0600 |
| commit | bbaf2ecb5ca47d9eaf098a183cd197e536d20a02 (patch) | |
| tree | 967134a4369fff5f6297b2a6108bc950fcf4ebbe /src/net.c | |
| parent | 7c920f7f22a26e377aa9eab0f56ca45caddf7217 (diff) | |
fix two errors/'crashes'
Diffstat (limited to 'src/net.c')
| -rw-r--r-- | src/net.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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);
|
