From: Juho Vähä-Herttua Date: Mon, 14 May 2012 20:04:41 +0000 (+0300) Subject: Make the maximum number of clients configurable X-Git-Tag: upstream/0.9.0~4^2~71 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=72fe063cf6771a3645d8cef0ae4426ad72b16917;p=deb_shairplay.git Make the maximum number of clients configurable --- diff --git a/src/include/raop.h b/src/include/raop.h index 1a7ebc2..5d5dc08 100644 --- a/src/include/raop.h +++ b/src/include/raop.h @@ -43,8 +43,8 @@ struct raop_callbacks_s { }; typedef struct raop_callbacks_s raop_callbacks_t; -RAOP_API raop_t *raop_init(raop_callbacks_t *callbacks, const char *pemkey); -RAOP_API raop_t *raop_init_from_keyfile(raop_callbacks_t *callbacks, const char *keyfile); +RAOP_API raop_t *raop_init(int max_clients, raop_callbacks_t *callbacks, const char *pemkey); +RAOP_API raop_t *raop_init_from_keyfile(int max_clients, raop_callbacks_t *callbacks, const char *keyfile); RAOP_API void raop_set_log_level(raop_t *raop, int level); RAOP_API void raop_set_log_callback(raop_t *raop, raop_log_callback_t callback); diff --git a/src/lib/httpd.c b/src/lib/httpd.c index 971a5bf..2bed984 100644 --- a/src/lib/httpd.c +++ b/src/lib/httpd.c @@ -110,6 +110,7 @@ httpd_add_connection(httpd_t *httpd, int fd, unsigned char *local, int local_len } } if (i == httpd->max_connections) { + /* This code should never be reached, we do not select server_fd when full */ logger_log(httpd->logger, LOGGER_INFO, "Max connections reached"); shutdown(fd, SHUT_RDWR); closesocket(fd); diff --git a/src/lib/raop.c b/src/lib/raop.c index 9ede243..fd02edf 100644 --- a/src/lib/raop.c +++ b/src/lib/raop.c @@ -349,7 +349,7 @@ conn_destroy(void *ptr) } raop_t * -raop_init(raop_callbacks_t *callbacks, const char *pemkey) +raop_init(int max_clients, raop_callbacks_t *callbacks, const char *pemkey) { raop_t *raop; httpd_t *httpd; @@ -357,6 +357,8 @@ raop_init(raop_callbacks_t *callbacks, const char *pemkey) httpd_callbacks_t httpd_cbs; assert(callbacks); + assert(max_clients > 0); + assert(max_clients < 100); assert(pemkey); /* Initialize the network */ @@ -388,7 +390,7 @@ raop_init(raop_callbacks_t *callbacks, const char *pemkey) httpd_cbs.conn_destroy = &conn_destroy; /* Initialize the http daemon */ - httpd = httpd_init(raop->logger, &httpd_cbs, 10, 1); + httpd = httpd_init(raop->logger, &httpd_cbs, max_clients, 1); if (!httpd) { free(raop); return NULL; @@ -412,7 +414,7 @@ raop_init(raop_callbacks_t *callbacks, const char *pemkey) } raop_t * -raop_init_from_keyfile(raop_callbacks_t *callbacks, const char *keyfile) +raop_init_from_keyfile(int max_clients, raop_callbacks_t *callbacks, const char *keyfile) { raop_t *raop; char *pemstr; @@ -420,7 +422,7 @@ raop_init_from_keyfile(raop_callbacks_t *callbacks, const char *keyfile) if (utils_read_file(&pemstr, keyfile) < 0) { return NULL; } - raop = raop_init(callbacks, pemstr); + raop = raop_init(max_clients, callbacks, pemstr); free(pemstr); return raop; } diff --git a/src/test/example.c b/src/test/example.c index c07b126..fdd9704 100644 --- a/src/test/example.c +++ b/src/test/example.c @@ -92,7 +92,7 @@ main(int argc, char *argv[]) raop_cbs.audio_flush = audio_flush; raop_cbs.audio_destroy = audio_destroy; - raop = raop_init_from_keyfile(&raop_cbs, "airport.key"); + raop = raop_init_from_keyfile(10, &raop_cbs, "airport.key"); raop_set_log_level(raop, RAOP_LOG_DEBUG); raop_set_log_callback(raop, &raop_log_callback); raop_start(raop, &raop_port, hwaddr, sizeof(hwaddr), "test");