diff options
author | Leah Neukirchen <leah@vuxu.org> | 2020-05-08 22:31:26 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2020-05-08 22:31:26 +0200 |
commit | 78eba2b9099db2abcdddb828b82fcd2d4e5e29d1 (patch) | |
tree | f195e939fa9ca6034ed7e96c88f69376bf5078b8 | |
parent | 2550dbacea260e0f918eb23a1fdf762c5104053c (diff) | |
download | hittpd-78eba2b9099db2abcdddb828b82fcd2d4e5e29d1.tar.gz hittpd-78eba2b9099db2abcdddb828b82fcd2d4e5e29d1.tar.xz hittpd-78eba2b9099db2abcdddb828b82fcd2d4e5e29d1.zip |
rename OPEN_MAX to MAX_CLIENTS
-rw-r--r-- | hittpd.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/hittpd.c b/hittpd.c index d8d71be..0d33211 100644 --- a/hittpd.c +++ b/hittpd.c @@ -22,6 +22,7 @@ */ #define TIMEOUT 60 +#define MAX_CLIENTS 1024 #ifdef __linux__ #include <sys/sendfile.h> @@ -717,11 +718,9 @@ static http_parser_settings settings = { .on_url = on_url, }; -#define OPEN_MAX 1024 - -struct pollfd client[OPEN_MAX]; -struct http_parser parsers[OPEN_MAX]; -struct conn_data datas[OPEN_MAX]; +struct pollfd client[MAX_CLIENTS]; +struct http_parser parsers[MAX_CLIENTS]; +struct conn_data datas[MAX_CLIENTS]; void close_connection(int i) @@ -946,7 +945,7 @@ main(int argc, char *argv[]) client[0].fd = listenfd; client[0].events = POLLRDNORM; - for (i = 1; i < OPEN_MAX; i++) + for (i = 1; i < MAX_CLIENTS; i++) client[i].fd = -1; /* -1 indicates available entry */ maxi = 0; /* max index into client[] array */ @@ -992,7 +991,7 @@ main(int argc, char *argv[]) if (client[0].revents & POLLRDNORM) { /* new client connection */ - for (i = 1; i < OPEN_MAX; i++) + for (i = 1; i < MAX_CLIENTS; i++) if (client[i].fd < 0) { struct sockaddr_in6 cliaddr; socklen_t clilen = sizeof cliaddr; @@ -1001,7 +1000,7 @@ main(int argc, char *argv[]) accept_client(i, connfd); break; } - if (i == OPEN_MAX) + if (i == MAX_CLIENTS) printf("too many clients\n"); if (i > maxi) maxi = i; /* max index in client[] array */ |