diff options
Diffstat (limited to 'MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c')
-rw-r--r-- | MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c | 138 |
1 files changed, 48 insertions, 90 deletions
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c index 1d9138b39b..e2a78b7a9d 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c @@ -297,7 +297,7 @@ Tcp4DriverBindingStart ( " resource to create an Ip Io!\n"));
Status = EFI_OUT_OF_RESOURCES;
- goto ReleaseServiceData;
+ goto ON_ERROR;
}
//
@@ -312,7 +312,7 @@ Tcp4DriverBindingStart ( Status = IpIoOpen (TcpServiceData->IpIo, &OpenData);
if (EFI_ERROR (Status)) {
- goto ReleaseServiceData;
+ goto ON_ERROR;
}
//
@@ -324,7 +324,7 @@ Tcp4DriverBindingStart ( TCP4_DEBUG_ERROR (("Tcp4DriverBindingStart: Create TcpTimer"
" Event failed with %r\n", Status));
- goto ReleaseIpIo;
+ goto ON_ERROR;
}
//
@@ -344,7 +344,8 @@ Tcp4DriverBindingStart ( TCP4_DEBUG_ERROR (("Tcp4DriverBindingStart: Install Tcp4 Service Binding"
" Protocol failed for %r\n", Status));
- goto ReleaseTimer;
+ Tcp4DestroyTimer ();
+ goto ON_ERROR;
}
//
@@ -354,19 +355,17 @@ Tcp4DriverBindingStart ( TcpServiceData->Signature = TCP4_DRIVER_SIGNATURE;
TcpServiceData->DriverBindingHandle = This->DriverBindingHandle;
+ NetListInit (&TcpServiceData->SocketList);
+
TcpSetVariableData (TcpServiceData);
return EFI_SUCCESS;
-ReleaseTimer:
-
- Tcp4DestroyTimer ();
-
-ReleaseIpIo:
+ON_ERROR:
- IpIoDestroy (TcpServiceData->IpIo);
-
-ReleaseServiceData:
+ if (TcpServiceData->IpIo != NULL) {
+ IpIoDestroy (TcpServiceData->IpIo);
+ }
NetFreePool (TcpServiceData);
@@ -398,19 +397,15 @@ Tcp4DriverBindingStop ( {
EFI_STATUS Status;
EFI_HANDLE NicHandle;
- EFI_SERVICE_BINDING_PROTOCOL *Tcp4ServiceBinding;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
TCP4_SERVICE_DATA *TcpServiceData;
- TCP_CB *TcpPcb;
SOCKET *Sock;
- TCP4_PROTO_DATA *TcpProto;
- NET_LIST_ENTRY *Entry;
- NET_LIST_ENTRY *NextEntry;
// Find the NicHandle where Tcp4 ServiceBinding Protocol is installed.
//
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid);
if (NicHandle == NULL) {
- return EFI_SUCCESS;
+ return EFI_DEVICE_ERROR;
}
//
@@ -419,7 +414,7 @@ Tcp4DriverBindingStop ( Status = gBS->OpenProtocol (
NicHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
- (VOID **) &Tcp4ServiceBinding,
+ (VOID **) &ServiceBinding,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -429,95 +424,53 @@ Tcp4DriverBindingStop ( TCP4_DEBUG_ERROR (("Tcp4DriverBindingStop: Locate Tcp4 Service "
" Binding Protocol failed with %r\n", Status));
- return Status;
+ return EFI_DEVICE_ERROR;
}
- TcpServiceData = TCP4_FROM_THIS (Tcp4ServiceBinding);
-
- //
- // Kill TCP driver
- //
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mTcpRunQue) {
- TcpPcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
+ TcpServiceData = TCP4_FROM_THIS (ServiceBinding);
+ if (NumberOfChildren == 0) {
//
- // Try to destroy this child
+ // Uninstall TCP servicebinding protocol
//
- Sock = TcpPcb->Sk;
- TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
-
- if (TcpProto->TcpService == TcpServiceData) {
- Status = SockDestroyChild (Sock);
+ gBS->UninstallMultipleProtocolInterfaces (
+ NicHandle,
+ &gEfiTcp4ServiceBindingProtocolGuid,
+ ServiceBinding,
+ NULL
+ );
- if (EFI_ERROR (Status)) {
+ //
+ // Destroy the IpIO consumed by TCP driver
+ //
+ IpIoDestroy (TcpServiceData->IpIo);
- TCP4_DEBUG_ERROR (("Tcp4DriverBindingStop: Destroy Tcp "
- "instance failed with %r\n", Status));
- return Status;
- }
- }
- }
+ //
+ // Destroy the heartbeat timer.
+ //
+ Tcp4DestroyTimer ();
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mTcpListenQue) {
- TcpPcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
+ //
+ // Clear the variable.
+ //
+ TcpClearVariableData (TcpServiceData);
//
- // Try to destroy this child
+ // Release the TCP service data
//
- Sock = TcpPcb->Sk;
- TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
+ NetFreePool (TcpServiceData);
+ } else {
- if (TcpProto->TcpService == TcpServiceData) {
- Status = SockDestroyChild (TcpPcb->Sk);
- if (EFI_ERROR (Status)) {
+ while (!NetListIsEmpty (&TcpServiceData->SocketList)) {
+ Sock = NET_LIST_HEAD (&TcpServiceData->SocketList, SOCKET, Link);
- TCP4_DEBUG_ERROR (("Tcp4DriverBindingStop: Destroy Tcp "
- "instance failed with %r\n", Status));
- return Status;
- }
+ ServiceBinding->DestroyChild (ServiceBinding, Sock->SockHandle);
}
}
- //
- // Uninstall TCP servicebinding protocol
- //
- Status = gBS->UninstallMultipleProtocolInterfaces (
- NicHandle,
- &gEfiTcp4ServiceBindingProtocolGuid,
- Tcp4ServiceBinding,
- NULL
- );
- if (EFI_ERROR (Status)) {
-
- TCP4_DEBUG_ERROR (("Tcp4DriverBindingStop: Uninstall TCP service "
- "binding protocol failed with %r\n", Status));
- return Status;
- }
-
- //
- // Destroy the IpIO consumed by TCP driver
- //
- Status = IpIoDestroy (TcpServiceData->IpIo);
-
- //
- // Destroy the heartbeat timer.
- //
- Tcp4DestroyTimer ();
-
- //
- // Clear the variable.
- //
- TcpClearVariableData (TcpServiceData);
-
- //
- // Release the TCP service data
- //
- NetFreePool (TcpServiceData);
-
return Status;
}
-
/**
Creates a child handle with a set of TCP4 services.
@@ -608,9 +561,12 @@ Tcp4ServiceBindingCreateChild ( Sock->SockHandle
);
SockDestroyChild (Sock);
+ } else {
+ NetListInsertTail (&TcpServiceData->SocketList, &Sock->Link);
}
ON_EXIT:
+
NET_RESTORE_TPL (OldTpl);
return Status;
}
@@ -672,7 +628,9 @@ Tcp4ServiceBindingDestroyChild ( TcpProtoData = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
TcpServiceData = TcpProtoData->TcpService;
- Status = SockDestroyChild (Sock);
+ NetListRemoveEntry (&Sock->Link);
+
+ SockDestroyChild (Sock);
//
// Close the device path protocol
|