summaryrefslogtreecommitdiff
path: root/usr.sbin/slowcgi
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2018-10-19 08:13:35 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2018-10-19 08:13:35 +0000
commitdc388d4163b5f0cf447d8f1d605a6b3bd1da6346 (patch)
tree500d7357e9cead9640315b07eae398629d8e8e4e /usr.sbin/slowcgi
parent4376eb8a87e10050530e870437b46e1b752e8625 (diff)
When calculating the fd limit before accepting a new connection also
account for the inflight fds caused by the new connection. Without this slowcgi could fail when close to the limit because FD_RESERVE is smaller then FD_NEEDED. OK florian@, tested by Kristaps Dzonsons
Diffstat (limited to 'usr.sbin/slowcgi')
-rw-r--r--usr.sbin/slowcgi/slowcgi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c
index 696af7228f2..8def399a25d 100644
--- a/usr.sbin/slowcgi/slowcgi.c
+++ b/usr.sbin/slowcgi/slowcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slowcgi.c,v 1.54 2018/08/19 12:31:41 florian Exp $ */
+/* $OpenBSD: slowcgi.c,v 1.55 2018/10/19 08:13:34 claudio Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
* Copyright (c) 2013 Florian Obser <florian@openbsd.org>
@@ -437,7 +437,7 @@ accept_reserve(int sockfd, struct sockaddr *addr, socklen_t *addrlen,
{
int ret;
if (getdtablecount() + reserve +
- (*counter * FD_NEEDED) >= getdtablesize()) {
+ ((*counter + 1) * FD_NEEDED) >= getdtablesize()) {
ldebug("inflight fds exceeded");
errno = EMFILE;
return -1;