Better handle transmit errors

Return 0 receive bytes when socket is closed


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12099 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lpleahy 2011-08-08 18:19:45 +00:00
parent 42372879b5
commit 1c34b250f6
2 changed files with 250 additions and 223 deletions

View File

@ -2524,6 +2524,15 @@ EslSocketReceive (
if ( NULL != pSocketProtocol ) {
pSocket = SOCKET_FROM_PROTOCOL ( pSocketProtocol );
//
// Return the transmit error if necessary
//
if ( EFI_SUCCESS != pSocket->TxError ) {
pSocket->errno = EIO;
Status = pSocket->TxError;
pSocket->TxError = EFI_SUCCESS;
}
else {
//
// Verify the socket state
//
@ -2671,6 +2680,7 @@ EslSocketReceive (
}
}
}
}
//
// Return the operation status
@ -2894,6 +2904,15 @@ EslSocketTransmit (
if ( NULL != pSocketProtocol ) {
pSocket = SOCKET_FROM_PROTOCOL ( pSocketProtocol );
//
// Return the transmit error if necessary
//
if ( EFI_SUCCESS != pSocket->TxError ) {
pSocket->errno = EIO;
Status = pSocket->TxError;
pSocket->TxError = EFI_SUCCESS;
}
else {
//
// Verify the socket state
//
@ -3063,6 +3082,7 @@ EslSocketTransmit (
}
}
}
}
//
// Return the operation status

View File

@ -2448,13 +2448,21 @@ EslTcpReceive4 (
&& ( NULL == pSocket->pRxPacketListHead )
&& ( NULL == pSocket->pRxOobPacketListHead )) {
Status = pSocket->RxError;
pSocket->RxError = EFI_SUCCESS;
switch ( Status ) {
default:
pSocket->errno = EIO;
break;
case EFI_CONNECTION_FIN:
pSocket->errno = ESHUTDOWN;
//
// Continue to return zero bytes received when the
// peer has successfully closed the connection
//
pSocket->RxError = EFI_CONNECTION_FIN;
*pDataLength = 0;
pSocket->errno = 0;
Status = EFI_SUCCESS;
break;
case EFI_CONNECTION_REFUSED:
@ -2481,7 +2489,6 @@ EslTcpReceive4 (
pSocket->errno = ENOPROTOOPT;
break;
}
pSocket->RxError = EFI_SUCCESS;
}
else {
Status = EFI_NOT_READY;