diff options
Diffstat (limited to 'usr.sbin/relayd/relayd.c')
-rw-r--r-- | usr.sbin/relayd/relayd.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index b369e2549de..e8c2c5aba1f 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.108 2012/05/08 15:10:15 benno Exp $ */ +/* $OpenBSD: relayd.c,v 1.109 2012/09/21 09:56:27 benno Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -1220,3 +1220,22 @@ get_data(u_int8_t *ptr, size_t len) return (data); } + +int +accept_reserve(int sockfd, struct sockaddr *addr, socklen_t *addrlen, + int reserve, volatile int *counter) +{ + int ret; + if (getdtablecount() + reserve + + *counter >= getdtablesize()) { + errno = EMFILE; + return -1; + } + + if ((ret = accept(sockfd, addr, addrlen)) > -1) { + (*counter)++; + log_debug("%s: inflight incremented, now %d",__func__, + *counter); + } + return ret; +} |