mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-09 19:20:41 +03:00
Mayaqua/Network: add StopUdpListener()
This allows to stop a UDP listener without deleting it. It's especially useful when no datagrams should be received anymore, but there are other threads accessing the listener.
This commit is contained in:
parent
667108319d
commit
0570f7d31c
@ -19329,6 +19329,19 @@ UDPLISTENER *NewUdpListenerEx(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP
|
||||
return u;
|
||||
}
|
||||
|
||||
// Stop the UDP listener
|
||||
void StopUdpListener(UDPLISTENER *u)
|
||||
{
|
||||
if (u == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
u->Halt = true;
|
||||
SetSockEvent(u->Event);
|
||||
WaitThread(u->Thread, INFINITE);
|
||||
}
|
||||
|
||||
// Release the UDP listener
|
||||
void FreeUdpListener(UDPLISTENER *u)
|
||||
{
|
||||
@ -19339,10 +19352,8 @@ void FreeUdpListener(UDPLISTENER *u)
|
||||
return;
|
||||
}
|
||||
|
||||
u->Halt = true;
|
||||
SetSockEvent(u->Event);
|
||||
StopUdpListener(u);
|
||||
|
||||
WaitThread(u->Thread, INFINITE);
|
||||
ReleaseThread(u->Thread);
|
||||
ReleaseSockEvent(u->Event);
|
||||
|
||||
|
@ -1357,6 +1357,7 @@ UINT64 GetHostIPAddressListHash();
|
||||
UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip);
|
||||
UDPLISTENER *NewUdpListenerEx(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip, UINT packet_type);
|
||||
void UdpListenerThread(THREAD *thread, void *param);
|
||||
void StopUdpListener(UDPLISTENER *u);
|
||||
void FreeUdpListener(UDPLISTENER *u);
|
||||
void AddPortToUdpListener(UDPLISTENER *u, UINT port);
|
||||
void DeletePortFromUdpListener(UDPLISTENER *u, UINT port);
|
||||
|
Loading…
Reference in New Issue
Block a user