summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-26 23:12:49 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-26 23:12:49 +0000
commit395e22b9e15bc70a2d91641355874596097fa7ee (patch)
tree2e608c483e51e1a4811e851d29e701b1ad897564
parent0b5da0afa6d233e48965f08e0dfef7bb3eaeef69 (diff)
downloadedk2-395e22b9e15bc70a2d91641355874596097fa7ee.zip
edk2-395e22b9e15bc70a2d91641355874596097fa7ee.tar.gz
edk2-395e22b9e15bc70a2d91641355874596097fa7ee.tar.bz2
Add support for the O_NONBLOCK file option.
Addresses Auber's accept test 4.3.2. Signed-off by: Lee Leahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/EADK@12445 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--StdLib/BsdSocketLib/accept.c13
-rw-r--r--StdLib/BsdSocketLib/connect.c4
-rw-r--r--StdLib/BsdSocketLib/sendto.c9
3 files changed, 17 insertions, 9 deletions
diff --git a/StdLib/BsdSocketLib/accept.c b/StdLib/BsdSocketLib/accept.c
index 3d1e89f..4f0dbac 100644
--- a/StdLib/BsdSocketLib/accept.c
+++ b/StdLib/BsdSocketLib/accept.c
@@ -18,10 +18,10 @@
/**
Worker routine for ::accept and ::AcceptNB
- @param [in] s Socket file descriptor returned from ::socket.
+ @param [in] s Socket file descriptor returned from ::socket.
- @param [in] bBlocking TRUE if this is a blocking call
- @param [in] address Address of a buffer to receive the remote network address.
+ @param [in] bBlockingAllowed TRUE if this is a blocking call
+ @param [in] address Address of a buffer to receive the remote network address.
@param [in, out] address_len Address of a buffer containing the Length in bytes
of the remote network address buffer. Upon return,
@@ -34,11 +34,12 @@
int
AcceptWork (
int s,
- BOOLEAN bBlocking,
+ BOOLEAN bBlockingAllowed,
struct sockaddr * address,
socklen_t * address_len
)
{
+ BOOLEAN bBlocking;
INT32 NewSocketFd;
struct __filedes * pDescriptor;
EFI_SOCKET_PROTOCOL * pNewSocket;
@@ -58,8 +59,10 @@ AcceptWork (
&errno );
if ( NULL != pSocketProtocol ) {
//
- // TODO: Update bBlocking by anding with check for NON_BLOCKING
+ // Determine if the operation is blocking
//
+ bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));
+ bBlocking &= bBlockingAllowed;
//
// Attempt to accept a new network connection
diff --git a/StdLib/BsdSocketLib/connect.c b/StdLib/BsdSocketLib/connect.c
index 644ef7a..aa4df57 100644
--- a/StdLib/BsdSocketLib/connect.c
+++ b/StdLib/BsdSocketLib/connect.c
@@ -71,9 +71,9 @@ connect (
&errno );
if ( NULL != pSocketProtocol ) {
//
- // TODO: Check for NON_BLOCKING
+ // Determine if the operation is blocking
//
- bBlocking = TRUE;
+ bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));
//
// Attempt to connect to a remote system
diff --git a/StdLib/BsdSocketLib/sendto.c b/StdLib/BsdSocketLib/sendto.c
index 61a42f1..2fb7737 100644
--- a/StdLib/BsdSocketLib/sendto.c
+++ b/StdLib/BsdSocketLib/sendto.c
@@ -54,6 +54,7 @@ sendto (
socklen_t tolen
)
{
+ BOOLEAN bBlocking;
ssize_t LengthInBytes;
CONST UINT8 * pData;
struct __filedes * pDescriptor;
@@ -73,6 +74,11 @@ sendto (
&errno );
if ( NULL != pSocketProtocol ) {
//
+ // Determine if the operation is blocking
+ //
+ bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));
+
+ //
// Send the data using the socket
//
pData = buffer;
@@ -96,8 +102,7 @@ sendto (
//
pData += LengthInBytes;
length -= LengthInBytes;
- // TODO: Add non-blocking check
- } while (( 0 != length ) && ( EFI_NOT_READY == Status ));
+ } while (( 0 != length ) && ( EFI_NOT_READY == Status ) && bBlocking );
}
//