datacommsserver/esockserver/ssock/ss_intsock.cpp
changeset 65 41cc8e7ff496
parent 22 592244873960
equal deleted inserted replaced
40:34fc115b8742 65:41cc8e7ff496
  2010 	{
  2010 	{
  2011 	__ASSERT_DEBUG(State()!=ESStateDead,Panic(EBadStateUpCall));
  2011 	__ASSERT_DEBUG(State()!=ESStateDead,Panic(EBadStateUpCall));
  2012 //	__ASSERT_DEBUG(State()!=ESStateCreated,Panic(EBadStateUpCall));		// no longer forced into shuttingdown state upon half-close
  2012 //	__ASSERT_DEBUG(State()!=ESStateCreated,Panic(EBadStateUpCall));		// no longer forced into shuttingdown state upon half-close
  2013 	__ASSERT_DEBUG(State()!=ESStateClosing,Panic(EBadStateUpCall));
  2013 	__ASSERT_DEBUG(State()!=ESStateClosing,Panic(EBadStateUpCall));
  2014 	__ASSERT_DEBUG(!(iBlockedOperations&EReadStopped),Panic(EBadStateUpCall));
  2014 	__ASSERT_DEBUG(!(iBlockedOperations&EReadStopped),Panic(EBadStateUpCall));
  2015 	__ASSERT_DEBUG(State()!=ESStateError,Panic(EBadStateUpCall));
  2015 
       
  2016 	// The socket can now be errored from the control side as well as from the protocol below.  Hence, the socket
       
  2017 	// can receive an upcall while in the errored state as the protocol is unaware of the socket errored state.
       
  2018 	// Specific scenario is that TransportFlowShim receives a DataClientStop(KErrForceDisconnect), places the socket
       
  2019 	// in the errored state and, subsequently, the TCP/IP stack issues NewData(KNewDataEndofData) as a result of an
       
  2020 	// incoming FIN.
       
  2021 	//__ASSERT_DEBUG(State()!=ESStateError,Panic(EBadStateUpCall));
       
  2022 
  2016 	__ASSERT_DEBUG(State()!=ESStateDisconnected,Panic(EBadStateUpCall));
  2023 	__ASSERT_DEBUG(State()!=ESStateDisconnected,Panic(EBadStateUpCall));
  2017 // zero is used in v1.5 to resume after	reneging __ASSERT_DEBUG(aCount>0,Panic(EBadDataCount));
  2024 // zero is used in v1.5 to resume after	reneging __ASSERT_DEBUG(aCount>0,Panic(EBadDataCount));
  2018 
  2025 
  2019 	if(aCount==KNewDataEndofData)
  2026 	if(aCount==KNewDataEndofData)
  2020 		{
  2027 		{
  2054 	{
  2061 	{
  2055 	__ASSERT_DEBUG(State()!=ESStateDead,Panic(EBadStateUpCall));
  2062 	__ASSERT_DEBUG(State()!=ESStateDead,Panic(EBadStateUpCall));
  2056 	__ASSERT_DEBUG(State()!=ESStateCreated,Panic(EBadStateUpCall));
  2063 	__ASSERT_DEBUG(State()!=ESStateCreated,Panic(EBadStateUpCall));
  2057 	__ASSERT_DEBUG(State()!=ESStateClosing,Panic(EBadStateUpCall));
  2064 	__ASSERT_DEBUG(State()!=ESStateClosing,Panic(EBadStateUpCall));
  2058 	__ASSERT_DEBUG(State()!=ESStateShuttingDown,Panic(EBadStateUpCall));
  2065 	__ASSERT_DEBUG(State()!=ESStateShuttingDown,Panic(EBadStateUpCall));
  2059 	__ASSERT_DEBUG(State()!=ESStateError,Panic(EBadStateUpCall));
  2066 	// See comment in ASocket::NewData() as to why the errored state is valid here.
       
  2067 	//__ASSERT_DEBUG(State()!=ESStateError,Panic(EBadStateUpCall));
  2060 	__ASSERT_DEBUG(State()!=ESStateDisconnected,Panic(EBadStateUpCall));
  2068 	__ASSERT_DEBUG(State()!=ESStateDisconnected,Panic(EBadStateUpCall));
  2061 
  2069 
  2062 	TBool writeflowedoff = iBlockedOperations&EWriteFlowedOff;
  2070 	TBool writeflowedoff = iBlockedOperations&EWriteFlowedOff;
  2063 	iBlockedOperations &= ~EWriteFlowedOff;
  2071 	iBlockedOperations &= ~EWriteFlowedOff;
  2064 	if(IsBlockedWrite())
  2072 	if(IsBlockedWrite())
  2078 */
  2086 */
  2079 	{
  2087 	{
  2080 	//__ASSERT_DEBUG(State()==ESStateOpeningActive,Panic(EBadStateUpCall));
  2088 	//__ASSERT_DEBUG(State()==ESStateOpeningActive,Panic(EBadStateUpCall));
  2081 	if (IsConnectionOriented())
  2089 	if (IsConnectionOriented())
  2082 		{
  2090 		{
  2083 		SetState(ESStateConnected);
  2091 	   // See comment in ASocket::NewData() as to why the errored state is valid here.
       
  2092         if (State() != ESStateError)
       
  2093             {
       
  2094             SetState(ESStateConnected);
       
  2095             }
  2084 		//__ASSERT_DEBUG(IsBlockedConnect(), Panic(EUnexpectedConnect));
  2096 		//__ASSERT_DEBUG(IsBlockedConnect(), Panic(EUnexpectedConnect));
  2085 		// assertion is invalid because operation could have been cancelled MarkT
  2097 		// assertion is invalid because operation could have been cancelled MarkT
  2086 		CompleteConnect(KErrNone);
  2098 		CompleteConnect(KErrNone);
  2087 		}
  2099 		}
  2088 	TryToCompleteSelectIoctl();
  2100 	TryToCompleteSelectIoctl();
  2110 void ASocket::ConnectComplete(CSubConnectionFlowBase& anSSP)
  2122 void ASocket::ConnectComplete(CSubConnectionFlowBase& anSSP)
  2111 /**
  2123 /**
  2112 Called from protocol to indicate that a passive open has completed
  2124 Called from protocol to indicate that a passive open has completed
  2113 */
  2125 */
  2114 	{
  2126 	{
  2115 	__ASSERT_DEBUG(State()==ESStateOpeningPassive,Panic(EBadStateUpCall));
  2127     // See comment in ASocket::NewData() as to why the errored state is valid here.
       
  2128 	__ASSERT_DEBUG(State()==ESStateOpeningPassive || State()==ESStateError,Panic(EBadStateUpCall));
  2116 	__ASSERT_ALWAYS(iAcceptQ, Panic(ENotListeningSocket));
  2129 	__ASSERT_ALWAYS(iAcceptQ, Panic(ENotListeningSocket));
  2117 	__ASSERT_ALWAYS(iAcceptQ->Count()<iAcceptQ->Length(), Panic(EAcceptQueFull));
  2130 	__ASSERT_ALWAYS(iAcceptQ->Count()<iAcceptQ->Length(), Panic(EAcceptQueFull));
  2118 
  2131 
  2119 	TAcceptQEntry n;
  2132 	TAcceptQEntry n;
  2120 	n.iSSP = &anSSP;
  2133 	n.iSSP = &anSSP;
  2294 /**
  2307 /**
  2295 Called from protocol to indicate that a disconnect has been initiated - prob from the remote host
  2308 Called from protocol to indicate that a disconnect has been initiated - prob from the remote host
  2296 */
  2309 */
  2297 	{
  2310 	{
  2298 	__ASSERT_ALWAYS(IsConnectionOriented(),Panic(EBadDisconnect));
  2311 	__ASSERT_ALWAYS(IsConnectionOriented(),Panic(EBadDisconnect));
  2299 	__ASSERT_DEBUG(State()==ESStateConnected || State()==ESStateShuttingDown,Panic(EBadStateUpCall));
  2312    // See comment in ASocket::NewData() as to why the errored state is valid here.
       
  2313 	__ASSERT_DEBUG(State()==ESStateConnected || State()==ESStateShuttingDown || State()==ESStateError, Panic(EBadStateUpCall));
  2300 
  2314 
  2301 	iDisconnectDataError=KErrNone;
  2315 	iDisconnectDataError=KErrNone;
  2302 
  2316 
  2303 	SetState(CanReconnect() ? ESStateCreated : ESStateDisconnected);
  2317 	if (State() != ESStateError)
       
  2318 	    {
       
  2319         SetState(CanReconnect() ? ESStateCreated : ESStateDisconnected);
       
  2320 	    }
  2304 	CompleteWrite(KErrDisconnected);
  2321 	CompleteWrite(KErrDisconnected);
  2305 	CompleteRead(KErrDisconnected);
  2322 	CompleteRead(KErrDisconnected);
  2306 	CompleteConnect(KErrDisconnected);
  2323 	CompleteConnect(KErrDisconnected);
  2307 	TryToCompleteSelectIoctl();
  2324 	TryToCompleteSelectIoctl();
  2308 	}
  2325 	}
  2311 /**
  2328 /**
  2312 Called from protocol to indicate that a disconnect has been initiated - prob from the remote host - with disconnect data
  2329 Called from protocol to indicate that a disconnect has been initiated - prob from the remote host - with disconnect data
  2313 */
  2330 */
  2314 	{
  2331 	{
  2315 	__ASSERT_DEBUG(IsConnectionOriented(),Panic(EBadDisconnect));
  2332 	__ASSERT_DEBUG(IsConnectionOriented(),Panic(EBadDisconnect));
  2316 	__ASSERT_DEBUG(State()==ESStateConnected || State()==ESStateShuttingDown,Panic(EBadStateUpCall));
  2333 	   // See comment in ASocket::NewData() as to why the errored state is valid here.
       
  2334 	__ASSERT_DEBUG(State()==ESStateConnected || State()==ESStateShuttingDown || State()==ESStateError,Panic(EBadStateUpCall));
  2317 
  2335 
  2318 	Disconnect();
  2336 	Disconnect();
  2319 	iDisconnectData=aDisconnectData.Alloc();
  2337 	iDisconnectData=aDisconnectData.Alloc();
  2320 	if(!iDisconnectData)
  2338 	if(!iDisconnectData)
  2321 		{
  2339 		{