repositories
/
deb_shairplay.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8c3f8f7
)
Do not give IPv4 any special treatment in httpd code
author
Juho Vähä-Herttua
<juhovh@iki.fi>
Mon, 24 Mar 2014 20:00:50 +0000
(22:00 +0200)
committer
Juho Vähä-Herttua
<juhovh@iki.fi>
Mon, 24 Mar 2014 20:00:50 +0000
(22:00 +0200)
src/lib/httpd.c
patch
|
blob
|
blame
|
history
diff --git
a/src/lib/httpd.c
b/src/lib/httpd.c
index f081c5e65cc74eb4c10f8ac7ad2818a50cffc73f..7cb6fdea61d4f322778f3407ba9f056f6afc54b7 100644
(file)
--- a/
src/lib/httpd.c
+++ b/
src/lib/httpd.c
@@
-198,8
+198,12
@@
httpd_thread(void *arg)
/* Get the correct nfds value and set rfds */
FD_ZERO(&rfds);
if (httpd->open_connections < httpd->max_connections) {
/* Get the correct nfds value and set rfds */
FD_ZERO(&rfds);
if (httpd->open_connections < httpd->max_connections) {
- FD_SET(httpd->server_fd4, &rfds);
- nfds = httpd->server_fd4+1;
+ if (httpd->server_fd4 != -1) {
+ FD_SET(httpd->server_fd4, &rfds);
+ if (nfds <= httpd->server_fd4) {
+ nfds = httpd->server_fd4+1;
+ }
+ }
if (httpd->server_fd6 != -1) {
FD_SET(httpd->server_fd6, &rfds);
if (nfds <= httpd->server_fd6) {
if (httpd->server_fd6 != -1) {
FD_SET(httpd->server_fd6, &rfds);
if (nfds <= httpd->server_fd6) {
@@
-229,7
+233,8
@@
httpd_thread(void *arg)
break;
}
break;
}
- if (FD_ISSET(httpd->server_fd4, &rfds)) {
+ if (httpd->open_connections < httpd->max_connections &&
+ httpd->server_fd4 != -1 && FD_ISSET(httpd->server_fd4, &rfds)) {
ret = httpd_accept_connection(httpd, httpd->server_fd4, 0);
if (ret == -1) {
break;
ret = httpd_accept_connection(httpd, httpd->server_fd4, 0);
if (ret == -1) {
break;
@@
-349,6
+354,9
@@
httpd_thread(void *arg)
int
httpd_start(httpd_t *httpd, unsigned short *port)
{
int
httpd_start(httpd_t *httpd, unsigned short *port)
{
+ /* How many connection attempts are kept in queue */
+ int backlog = 5;
+
assert(httpd);
assert(port);
assert(httpd);
assert(port);
@@
-370,14
+378,14
@@
httpd_start(httpd_t *httpd, unsigned short *port)
logger_log(httpd->logger, LOGGER_WARNING, "Continuing without IPv6 support");
}
logger_log(httpd->logger, LOGGER_WARNING, "Continuing without IPv6 support");
}
- if (
listen(httpd->server_fd4, 5
) == -1) {
+ if (
httpd->server_fd4 != -1 && listen(httpd->server_fd4, backlog
) == -1) {
logger_log(httpd->logger, LOGGER_ERR, "Error listening to IPv4 socket");
closesocket(httpd->server_fd4);
closesocket(httpd->server_fd6);
MUTEX_UNLOCK(httpd->run_mutex);
return -2;
}
logger_log(httpd->logger, LOGGER_ERR, "Error listening to IPv4 socket");
closesocket(httpd->server_fd4);
closesocket(httpd->server_fd6);
MUTEX_UNLOCK(httpd->run_mutex);
return -2;
}
- if (httpd->server_fd6 != -1 && listen(httpd->server_fd6,
5
) == -1) {
+ if (httpd->server_fd6 != -1 && listen(httpd->server_fd6,
backlog
) == -1) {
logger_log(httpd->logger, LOGGER_ERR, "Error listening to IPv6 socket");
closesocket(httpd->server_fd4);
closesocket(httpd->server_fd6);
logger_log(httpd->logger, LOGGER_ERR, "Error listening to IPv6 socket");
closesocket(httpd->server_fd4);
closesocket(httpd->server_fd6);