Author: cgutman Date: Mon Aug 12 04:08:20 2013 New Revision: 59706
URL: http://svn.reactos.org/svn/reactos?rev=59706&view=rev Log: [LWIP] - Ensure that the connection failure gets delivered if the socket is not yet ready to receive or has shutdown receive
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/event.c trunk/reactos/lib/drivers/lwip/src/rostcp.c
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/event.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tc... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] Mon Aug 12 04:08:20 2013 @@ -264,11 +264,9 @@ const NTSTATUS Status = TCPTranslateError(err); KIRQL OldIrql;
+ ASSERT(Connection->SocketContext == NULL); ASSERT(Connection->AddressFile); ASSERT(err != ERR_OK); - - /* First off all, remove the PCB pointer */ - Connection->SocketContext = NULL;
/* Complete all outstanding requests now */ FlushAllQueues(Connection, Status);
Modified: trunk/reactos/lib/drivers/lwip/src/rostcp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/lwip/src/rostcp... ============================================================================== --- trunk/reactos/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Mon Aug 12 04:08:20 2013 @@ -251,10 +251,13 @@ { Connection->SocketContext = NULL; tcp_arg(pcb, NULL); + TCPFinEventHandler(Connection, ERR_OK); } - - /* Remotely initiated close */ - TCPRecvEventHandler(arg); + else + { + /* Remotely initiated close */ + TCPRecvEventHandler(arg); + } }
return ERR_OK; @@ -299,16 +302,18 @@ PCONNECTION_ENDPOINT Connection = arg;
/* Make sure the socket didn't get closed */ - if (!arg) return; + if (!arg || Connection->SocketContext == NULL) return;
/* The PCB is dead now */ Connection->SocketContext = NULL;
- /* Defer the error delivery until all data is gone */ + /* Give them one shot to receive the remaining data */ Connection->ReceiveShutdown = TRUE; Connection->ReceiveShutdownStatus = TCPTranslateError(err); - - TCPRecvEventHandler(arg); + TCPRecvEventHandler(Connection); + + /* Terminate the connection */ + TCPFinEventHandler(Connection, err); }
static @@ -663,6 +668,7 @@ /* The PCB is not ours anymore */ msg->Input.Shutdown.Connection->SocketContext = NULL; tcp_arg(pcb, NULL); + TCPFinEventHandler(msg->Input.Shutdown.Connection, ERR_CLSD); } }
@@ -724,8 +730,6 @@ /* Check if the PCB was already "closed" but the client doesn't know it yet */ if (!msg->Input.Close.Connection->SocketContext) { - if (msg->Input.Close.Callback) - TCPFinEventHandler(msg->Input.Close.Connection, ERR_CLSD); msg->Output.Close.Error = ERR_OK; goto done; }