]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/close.c
Fix @return Doxygen commands to be singular instead of plural.
[mirror_edk2.git] / StdLib / BsdSocketLib / close.c
CommitLineData
d7ce7006 1/** @file\r
2 Implement the close API.\r
3\r
4 Copyright (c) 2011, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <SocketInternals.h>\r
16\r
17\r
18/**\r
19 Worker routine to close the socket.\r
20\r
7dc13291 21 @param[in] pSocketProtocol Socket protocol structure address\r
d7ce7006 22\r
7dc13291 23 @param[in] pErrno Address of the errno variable\r
d7ce7006 24\r
25 @retval EFI_SUCCESS Successfully closed the socket\r
26\r
27**/\r
28EFI_STATUS\r
29BslSocketCloseWork (\r
30 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
31 IN int * pErrno\r
32 )\r
33{\r
34 EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;\r
35 EFI_STATUS Status;\r
36\r
37 //\r
38 // Start closing the socket\r
39 //\r
40 Status = pSocketProtocol->pfnCloseStart ( pSocketProtocol,\r
41 FALSE,\r
42 pErrno );\r
43\r
44 //\r
45 // Wait for the socket to close or an error\r
46 //\r
47 while ( EFI_NOT_READY == Status ) {\r
48 Status = pSocketProtocol->pfnClosePoll ( pSocketProtocol,\r
49 pErrno );\r
50 }\r
51 if ( !EFI_ERROR ( Status )) {\r
52 //\r
53 // Locate the socket protocol\r
54 //\r
55 Status = gBS->LocateProtocol ( &gEfiSocketServiceBindingProtocolGuid,\r
56 NULL,\r
57 (VOID **) &pServiceBinding );\r
58 if ( !EFI_ERROR ( Status )) {\r
59 //\r
60 // Release the handle\r
61 //\r
62 Status = pServiceBinding->DestroyChild ( pServiceBinding,\r
63 pSocketProtocol->SocketHandle );\r
64 }\r
65 if ( EFI_ERROR ( Status )) {\r
66 *pErrno = EIO;\r
67 }\r
68 }\r
69 else {\r
70 DEBUG (( DEBUG_ERROR,\r
71 "ERROR - Failed to close the socket: %r\r\n",\r
72 Status ));\r
73 *pErrno = EIO;\r
74 }\r
75\r
76 //\r
77 // Return the close status\r
78 //\r
79 return Status;\r
80}\r
81\r
82\r
83/**\r
84 Close the socket\r
85\r
7dc13291 86 @param[in] pDescriptor Descriptor address for the file\r
d7ce7006 87\r
7dc13291 88 @return This routine returns 0 upon success and -1 upon failure.\r
d7ce7006 89 In the case of failure, errno contains more information.\r
90\r
91**/\r
92int\r
93BslSocketClose (\r
94 struct __filedes * pDescriptor\r
95 )\r
96{\r
97 int CloseStatus;\r
98 EFI_SOCKET_PROTOCOL * pSocketProtocol;\r
99\r
100 //\r
101 // Locate the socket protocol\r
102 //\r
103 pSocketProtocol = BslValidateSocketFd ( pDescriptor, &errno );\r
104 if ( NULL != pSocketProtocol ) {\r
105 //\r
106 // Close the socket\r
107 //\r
108 BslSocketCloseWork ( pSocketProtocol, &errno );\r
109 }\r
110\r
111 //\r
112 // Return the close status\r
113 //\r
114 CloseStatus = ( errno == 0 ) ? 0 : -1;\r
115 return CloseStatus;\r
116}\r