summaryrefslogtreecommitdiff
path: root/StdLib/BsdSocketLib/accept.c
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 23:02:35 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 23:02:35 +0000
commita88c31639bb24c73383a4528a5b77066e805148b (patch)
tree058801cd8687b0a0c6f82459b56b2ad3beb43bf4 /StdLib/BsdSocketLib/accept.c
parentdf7499fcc1fbd6c825cabf19bbed379688416125 (diff)
downloadedk2-platforms-a88c31639bb24c73383a4528a5b77066e805148b.tar.xz
Update the sockets library code
* Passes conformance and functional tests. * Builds with GCC 4.4 compiler. Signed-off by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12497 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/BsdSocketLib/accept.c')
-rw-r--r--StdLib/BsdSocketLib/accept.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/StdLib/BsdSocketLib/accept.c b/StdLib/BsdSocketLib/accept.c
index 25ae1b5861..4f0dbac5f9 100644
--- a/StdLib/BsdSocketLib/accept.c
+++ b/StdLib/BsdSocketLib/accept.c
@@ -16,29 +16,30 @@
/**
- Worker routine for ::Accept and ::AcceptNB
+ 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,
contains the length of the remote network address.
- @return ::accept returns zero if successful and -1 when an error occurs.
- In the case of an error, errno contains more details.
+ @return AcceptWork returns zero if successful and -1 when an error occurs.
+ In the case of an error, ::errno contains more details.
**/
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
@@ -75,12 +78,14 @@ AcceptWork (
//
// Convert the protocol to a socket
//
- NewSocketFd = BslSocketProtocolToFd ( pNewSocket, &errno );
- if ( -1 == NewSocketFd ) {
- //
- // Close the socket
- //
- BslSocketCloseWork ( pNewSocket, NULL );
+ if ( !EFI_ERROR ( Status )) {
+ NewSocketFd = BslSocketProtocolToFd ( pNewSocket, &errno );
+ if ( -1 == NewSocketFd ) {
+ //
+ // Close the socket
+ //
+ BslSocketCloseWork ( pNewSocket, NULL );
+ }
}
}
@@ -94,9 +99,10 @@ AcceptWork (
/**
Accept a network connection.
- The ::accept routine waits for a network connection to the socket.
- It is able to return the remote network address to the caller if
- requested. The
+ The accept routine waits for a network connection to the socket.
+ It returns the remote network address to the caller if requested.
+
+ The
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html">POSIX</a>
documentation is available online.
@@ -108,8 +114,8 @@ AcceptWork (
of the remote network address buffer. Upon return,
contains the length of the remote network address.
- @return ::accept returns zero if successful and -1 when an error occurs.
- In the case of an error, errno contains more details.
+ @return The accept routine returns zero if successful and -1 when an error occurs.
+ In the case of an error, ::errno contains more details.
**/
int
@@ -127,9 +133,7 @@ accept (
/**
- Non blocking version of accept.
-
- See ::accept
+ Non blocking version of ::accept.
@param [in] s Socket file descriptor returned from ::socket.
@@ -140,7 +144,7 @@ accept (
contains the length of the remote network address.
@return This routine returns zero if successful and -1 when an error occurs.
- In the case of an error, errno contains more details.
+ In the case of an error, ::errno contains more details.
**/
int