(bug 613) Tcp should NotifyDataRecv () when a FIN arrives
authorTom Henderson <tomh@tomh.org>
Fri, 26 Jun 2009 19:05:28 -0700
changeset 4625 615583240b77
parent 4624 eaa8501e614b
child 4626 a7b70048bd4a
(bug 613) Tcp should NotifyDataRecv () when a FIN arrives
src/internet-stack/tcp-socket-impl.cc
--- a/src/internet-stack/tcp-socket-impl.cc	Fri Jun 26 19:27:34 2009 -0700
+++ b/src/internet-stack/tcp-socket-impl.cc	Fri Jun 26 19:05:28 2009 -0700
@@ -666,6 +666,7 @@
   // simulation singleton is a way to get a single global static instance of a
   // class intended to be a singleton; see simulation-singleton.h
   SA stateAction = SimulationSingleton<TcpStateMachine>::Get ()->Lookup (m_state,e);
+  NS_LOG_LOGIC ("TcpSocketImpl::ProcessEvent stateAction " << stateAction.action);
   // debug
   if (stateAction.action == RST_TX)
     {
@@ -691,6 +692,11 @@
       m_endPoint->SetPeer (m_remoteAddress, m_remotePort);
       NS_LOG_LOGIC ("TcpSocketImpl " << this << " Connected!");
     }
+  if (saveState < CLOSING && (m_state == CLOSING || m_state == TIMED_WAIT) )
+    {
+      NS_LOG_LOGIC ("TcpSocketImpl peer closing, send EOF to application");
+      NotifyDataRecv ();
+    }
 
   if (needCloseNotify && !m_closeNotified)
     {
@@ -851,6 +857,7 @@
   switch (a)
   {
     case ACK_TX:
+      NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action ACK_TX");
       if(tcpHeader.GetFlags() & TcpHeader::FIN)
       {
         ++m_nextRxSequence; //bump this to account for the FIN
@@ -1183,11 +1190,6 @@
                 << " seq " << tcpHeader.GetSequenceNumber()
                 << " ack " << tcpHeader.GetAckNumber()
                 << " p.size is " << p->GetSize () );
-  NS_LOG_DEBUG ("TcpSocketImpl " << this <<
-                " NewRx," <<
-                " seq " << tcpHeader.GetSequenceNumber() <<
-                " ack " << tcpHeader.GetAckNumber() <<
-                " p.size is " << p->GetSize());
   States_t origState = m_state;
   if (RxBufferFreeSpace() < p->GetSize()) 
     { //if not enough room, fragment