diff svr-main.c @ 1023:a00303a7d247 fastopen

tcp fastopen for the server
author Matt Johnston <matt@ucc.asn.au>
date Sun, 15 Feb 2015 22:34:05 +0800
parents a48561559584
children 2265d7ebfdeb
line wrap: on
line diff
--- a/svr-main.c	Sat Feb 14 09:56:11 2015 +0800
+++ b/svr-main.c	Sun Feb 15 22:34:05 2015 +0800
@@ -138,7 +138,6 @@
 	}
 
 	for (i = 0; i < listensockcount; i++) {
-		set_sock_priority(listensocks[i], DROPBEAR_PRIO_LOWDELAY);
 		FD_SET(listensocks[i], &fds);
 	}
 
@@ -403,9 +402,9 @@
 }
 
 /* Set up listening sockets for all the requested ports */
-static size_t listensockets(int *sock, size_t sockcount, int *maxfd) {
-	
-	unsigned int i;
+static size_t listensockets(int *socks, size_t sockcount, int *maxfd) {
+
+	unsigned int i, n;
 	char* errstring = NULL;
 	size_t sockpos = 0;
 	int nsock;
@@ -416,7 +415,7 @@
 
 		TRACE(("listening on '%s:%s'", svr_opts.addresses[i], svr_opts.ports[i]))
 
-		nsock = dropbear_listen(svr_opts.addresses[i], svr_opts.ports[i], &sock[sockpos], 
+		nsock = dropbear_listen(svr_opts.addresses[i], svr_opts.ports[i], &socks[sockpos], 
 				sockcount - sockpos,
 				&errstring, maxfd);
 
@@ -427,6 +426,14 @@
 			continue;
 		}
 
+		for (n = 0; n < (unsigned int)nsock; n++) {
+			int sock = socks[sockpos + n];
+			set_sock_priority(sock, DROPBEAR_PRIO_LOWDELAY);
+#ifdef DROPBEAR_TCP_FAST_OPEN
+			set_listen_fast_open(sock);
+#endif
+		}
+
 		sockpos += nsock;
 
 	}