diff to backoff a little running out of fds

Loganaden Velvindron loganaden at gmail.com
Sat Dec 8 03:53:03 WST 2012


Based on similar work done by OpenBSD for sshd,

I came up with this:
The idea is to prevent spinning when out of file descriptors by
backing off for a while.

Suggestions ?


diff -r 63f8d6c469cf svr-main.c
--- a/svr-main.c	Thu May 17 00:26:12 2012 +0800
+++ b/svr-main.c	Sat Dec 08 03:48:40 2012 +0400
@@ -226,9 +226,10 @@
 			remoteaddrlen = sizeof(remoteaddr);
 			childsock = accept(listensocks[i],
 					(struct sockaddr*)&remoteaddr, &remoteaddrlen);
-
 			if (childsock < 0) {
 				/* accept failed */
+				if(errno == EMFILE || errno == ENFILE)
+					usleep(100*1000);
 				continue;
 			}

-- 
Brightest day,
Blackest night,
No bug shall escape my sight,
And those who worship evil's mind,
be wary of my powers,
puffy lantern's light !


More information about the Dropbear mailing list