Browse Source

Added support for listen backlogs

Joseph Henry 9 years ago
parent
commit
9ca699c86d
2 changed files with 8 additions and 4 deletions
  1. 2 0
      ext/lwipopts.h
  2. 6 4
      netcon/NetconEthernetTap.cpp

+ 2 - 0
ext/lwipopts.h

@@ -48,6 +48,8 @@
 //#define TCP_MSS 2048
 //#define TCP_MSS 2048
 //#define TCP_WND 512
 //#define TCP_WND 512
 
 
+#define TCP_LISTEN_BACKLOG   1
+
 /*------------------------------------------------------------------------------
 /*------------------------------------------------------------------------------
 ---------------------------------- Timers --------------------------------------
 ---------------------------------- Timers --------------------------------------
 ------------------------------------------------------------------------------*/
 ------------------------------------------------------------------------------*/

+ 6 - 4
netcon/NetconEthernetTap.cpp

@@ -542,7 +542,6 @@ err_t NetconEthernetTap::nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
 		tap->tcp_connections.push_back(new_tcp_conn);
 		tap->tcp_connections.push_back(new_tcp_conn);
 
 
 		int send_fd = tap->_phy.getDescriptor(conn->rpcSock);
 		int send_fd = tap->_phy.getDescriptor(conn->rpcSock);
-
 		int n = write(larg_fd, "z", 1); // accept() in library waits for this byte
 		int n = write(larg_fd, "z", 1); // accept() in library waits for this byte
     if(n > 0) {
     if(n > 0) {
 			if(sock_fd_write(send_fd, fds[1]) > 0) {
 			if(sock_fd_write(send_fd, fds[1]) > 0) {
@@ -905,10 +904,14 @@ void NetconEthernetTap::handle_listen(PhySocket *sock, void **uptr, struct liste
       return;
       return;
     }
     }
 
 
-		// TODO: Implement liste_with_backlog
+		struct tcp_pcb* listening_pcb;
+		if(listen_rpc->backlog > 0)
+			listening_pcb = lwipstack->tcp_listen_with_backlog(conn->pcb, listen_rpc->backlog);
+		else
+			listening_pcb = lwipstack->tcp_listen(conn->pcb);
+
 		// FIXME: Correct return values from this method, most is handled in intercept lib
 		// FIXME: Correct return values from this method, most is handled in intercept lib
 
 
-    struct tcp_pcb* listening_pcb = lwipstack->tcp_listen(conn->pcb);
     if(listening_pcb != NULL) {
     if(listening_pcb != NULL) {
       conn->pcb = listening_pcb;
       conn->pcb = listening_pcb;
       lwipstack->tcp_accept(listening_pcb, nc_accept);
       lwipstack->tcp_accept(listening_pcb, nc_accept);
@@ -1092,7 +1095,6 @@ void NetconEthernetTap::handle_write(TcpConnection *conn)
 	}
 	}
 	if(conn->idx < max) {
 	if(conn->idx < max) {
 		int sndbuf = conn->pcb->snd_buf; // How much we are currently allowed to write to the connection
 		int sndbuf = conn->pcb->snd_buf; // How much we are currently allowed to write to the connection
-
 		/* PCB send buffer is full,turn off readability notifications for the
 		/* PCB send buffer is full,turn off readability notifications for the
 		corresponding PhySocket until nc_sent() is called and confirms that there is
 		corresponding PhySocket until nc_sent() is called and confirms that there is
 		now space on the buffer */
 		now space on the buffer */