]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/UseSocketDxe/UseSocketDxe.c
Fixed close for socket to properly release the socket context structure and the handle.
[mirror_edk2.git] / StdLib / UseSocketDxe / UseSocketDxe.c
index 60741432648161fc15969744dd84ddd4b9654944..423419c23e55d9cd1176003eece0ea8e1544a7ff 100644 (file)
 #include <Protocol/ServiceBinding.h>\r
 \r
 \r
+/**\r
+  Free the socket resources\r
+\r
+  This releases the socket resources allocated by calling\r
+  EslServiceGetProtocol.\r
+\r
+  This routine is called from the ::close routine in BsdSocketLib\r
+  to release the socket resources.\r
+\r
+  @param [in] pSocketProtocol   Address of an ::EFI_SOCKET_PROTOCOL\r
+                                structure\r
+\r
+  @return       Value for ::errno, zero (0) indicates success.\r
+\r
+ **/\r
+int\r
+EslServiceFreeProtocol (\r
+  IN EFI_SOCKET_PROTOCOL * pSocketProtocol\r
+  )\r
+{\r
+  EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;\r
+  int RetVal;\r
+  EFI_STATUS Status;\r
+\r
+  //\r
+  //  Assume success\r
+  //\r
+  RetVal = 0;\r
+\r
+  //\r
+  //  Locate the socket protocol\r
+  //\r
+  Status = gBS->LocateProtocol ( &gEfiSocketServiceBindingProtocolGuid,\r
+                                 NULL,\r
+                                 (VOID **) &pServiceBinding );\r
+  if ( !EFI_ERROR ( Status )) {\r
+    //\r
+    //  Release the handle\r
+    //\r
+    Status = pServiceBinding->DestroyChild ( pServiceBinding,\r
+                                             pSocketProtocol->SocketHandle );\r
+  }\r
+  if ( EFI_ERROR ( Status )) {\r
+    RetVal = EIO;\r
+  }\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
+\r
+\r
 /**\r
   Connect to the EFI socket library\r
 \r