1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-19 10:10:40 +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:
Davide Beatrici 2020-05-11 07:50:55 +02:00
parent 667108319d
commit 0570f7d31c
2 changed files with 15 additions and 3 deletions

View File

@ -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);

View File

@ -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);