summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-07-09 15:39:51 -0300
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-07-09 16:04:33 -0300
commit3c36d76be739b6975fac4e6adee3b91002056db1 (patch)
tree82f26ce27c21cca23367b3b40849e710216ab8b2 /include
parent7a388dad85152a203033c14fee3c64607301865a (diff)
server.c: a basic multithreaded server to handle connectionsHEADmain
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'include')
-rw-r--r--include/server.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/server.h b/include/server.h
index e59c38d..238946a 100644
--- a/include/server.h
+++ b/include/server.h
@@ -1,6 +1,38 @@
#ifndef _SERVER_H_
#define _SERVER_H_
+#include <stdlib.h>
+#include <pthread.h>
+#include <netinet/in.h>
+#include "http.h"
+#define THREAD_POOL_NUM 12
+#define MAX_FD_QUEUE 512
+
+struct fd_queue {
+ int queue[512];
+ ssize_t front;
+ ssize_t back;
+ size_t count;
+};
+
+struct thread_data {
+ struct fd_queue queue;
+ pthread_mutex_t lock;
+ pthread_cond_t cond;
+ struct http *http;
+};
+
+struct server {
+ int server_fd;
+ struct sockaddr_in addr;
+ int addrlen;
+ pthread_t *pool;
+ size_t thread_pool_size;
+ struct thread_data data;
+};
+
+struct server *server_init(struct http *http);
+void server_poll(struct server *server);
#endif