Author: zhu
Date: Wed Aug 17 17:53:42 2016
New Revision: 72243
URL:
http://svn.reactos.org/svn/reactos?rev=72243&view=rev
Log:
More complete shutdown forces lwIP to get rid of lingering, dead connections to allow
re-binding to dead TCP ports.
Modified:
branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c
branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h
Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c [iso-8859-1] (original)
+++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c [iso-8859-1] Wed Aug 17
17:53:42 2016
@@ -413,6 +413,20 @@
{
tcp_arg(CurrentContext->lwip_tcp_pcb, NULL);
tcp_close(CurrentContext->lwip_tcp_pcb);
+#ifndef NDEBUG
+ REMOVE_PCB(CurrentContext->lwip_tcp_pcb);
+#endif
+ CurrentContext->lwip_tcp_pcb = NULL;
+ }
+ RELEASE_SERIAL_MUTEX();
+ break;
+ case TCP_REQUEST_CANCEL_MODE_SHUTDOWN :
+ Timeout.QuadPart = -1;
+ ACQUIRE_SERIAL_MUTEX(&CurrentContext->Mutex, &Timeout);
+ if (CurrentContext->lwip_tcp_pcb != NULL)
+ {
+ tcp_arg(CurrentContext->lwip_tcp_pcb, NULL);
+ tcp_shutdown(CurrentContext->lwip_tcp_pcb, 1, 1);
#ifndef NDEBUG
REMOVE_PCB(CurrentContext->lwip_tcp_pcb);
#endif
@@ -1203,7 +1217,7 @@
Irp,
Context,
CancelRequestRoutine,
- TCP_REQUEST_CANCEL_MODE_PRESERVE,
+ TCP_REQUEST_CANCEL_MODE_SHUTDOWN,
TCP_REQUEST_PENDING_RECEIVE);
TCP_ADD_STATE(TCP_STATE_RECEIVING, Context);
ContextMutexRelease(Context);
@@ -2111,6 +2125,9 @@
/* A null buffer means the connection has been closed */
if (p == NULL)
{
+ /* Call tcp_abort() to keep this PCB from lingering in CLOSE_WAIT */
+ tcp_arg(Context->lwip_tcp_pcb, NULL);
+ tcp_abort(Context->lwip_tcp_pcb);
#ifndef NDEBUG
DPRINT("Context %p closed by lwIP\n", Context);
REMOVE_PCB(Context->lwip_tcp_pcb);
@@ -2118,7 +2135,7 @@
Context->lwip_tcp_pcb = NULL;
TCP_SET_STATE(TCP_STATE_CLOSED, Context);
ContextMutexRelease(Context);
- return ERR_OK;
+ return ERR_ABRT;
}
/* Sanity check the Context */
Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h [iso-8859-1] (original)
+++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h [iso-8859-1] Wed Aug 17
17:53:42 2016
@@ -2,7 +2,8 @@
#define TCP_REQUEST_CANCEL_MODE_ABORT 1
#define TCP_REQUEST_CANCEL_MODE_CLOSE 2
-#define TCP_REQUEST_CANCEL_MODE_PRESERVE 3
+#define TCP_REQUEST_CANCEL_MODE_SHUTDOWN 3
+#define TCP_REQUEST_CANCEL_MODE_PRESERVE 4
#define TCP_REQUEST_PENDING_SEND 1
#define TCP_REQUEST_PENDING_RECEIVE 2