Add http_server_options

This commit is contained in:
Kamil Trzcinski
2022-04-05 16:13:21 +02:00
parent 9cf4cc359a
commit 4d3e8835ab
3 changed files with 27 additions and 6 deletions

View File

@ -122,18 +122,18 @@ error:
return -1;
}
int http_server(int listen_port, int maxcons, http_method_t *methods)
int http_server(http_server_options_t *options, http_method_t *methods)
{
int listen_fd = http_listen(9092, maxcons);
int listen_fd = http_listen(options->listen_port, options->maxcons);
if (listen_fd < 0) {
return -1;
}
sigaction(SIGPIPE, &(struct sigaction){ SIG_IGN }, NULL);
while (maxcons-- > 0) {
for (int worker = 0; worker < options->maxcons; worker++) {
char name[20];
sprintf(name, "HTTP%d/%d", listen_port, maxcons);
sprintf(name, "HTTP%d/%d", options->listen_port, worker);
http_worker_t *worker = calloc(1, sizeof(http_worker_t));
worker->name = strdup(name);

View File

@ -28,7 +28,12 @@ typedef struct http_worker_s {
char client_method[256];
} http_worker_t;
int http_server(int listen_port, int maxcons, http_method_t *methods);
typedef struct http_server_options_s {
int listen_port;
int maxcons;
} http_server_options_t;
int http_server(http_server_options_t *options, http_method_t *methods);
void http_index(http_worker_t *worker, FILE *stream);
void http_video_html(http_worker_t *worker, FILE *stream);