Fixed the bug that not to stop PXE functionality when PXE meeting some failure. And enhanced DriverBindingStop() to stop PXE functionality if PXE was still alive. 

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9478 6f19259b-4bc3-4df7-8a09-765794883524
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
index eaa3c03..9dc32f2 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
@@ -534,6 +534,14 @@
   if (EFI_ERROR (Status)) {

     return Status;

   }

+  

+  //

+  // Stop functionality of PXE Base Code protocol

+  //

+  Status = PxeBc->Stop (PxeBc);

+  if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {

+    return Status;

+  }

 

   Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (PxeBc);

 

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
index d548e67..b41dc76 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
@@ -2697,12 +2697,14 @@
   // Check download status

   //

   if (Status == EFI_SUCCESS) {

+    PxeBc->Stop (PxeBc); 

     return EFI_SUCCESS;

 

   } else if (Status == EFI_BUFFER_TOO_SMALL) {

     if (Buffer != NULL) {

       AsciiPrint ("PXE-E05: Download buffer is smaller than requested file.\n");

     } else {

+      PxeBc->Stop (PxeBc); 

       return Status;

     }