1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

Merge PR #1190: Cedar/Proto.c: fix session deletion not being triggered in certain cases

This commit is contained in:
Davide Beatrici 2020-08-05 01:53:08 +02:00 committed by GitHub
commit 712c51a971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -641,25 +641,28 @@ void ProtoHandleDatagrams(UDPLISTENER *listener, LIST *datagrams)
AddHash(proto->Sessions, session); AddHash(proto->Sessions, session);
} }
if (session->Halt)
{
DeleteHash(sessions, session);
ProtoDeleteSession(session);
continue;
}
Lock(session->Lock); Lock(session->Lock);
{
if (session->Halt == false)
{ {
void *data = Clone(datagram->Data, datagram->Size); void *data = Clone(datagram->Data, datagram->Size);
UDPPACKET *packet = NewUdpPacket(&datagram->SrcIP, datagram->SrcPort, &datagram->DstIP, datagram->DestPort, data, datagram->Size); UDPPACKET *packet = NewUdpPacket(&datagram->SrcIP, datagram->SrcPort, &datagram->DstIP, datagram->DestPort, data, datagram->Size);
Add(session->DatagramsIn, packet); Add(session->DatagramsIn, packet);
} }
}
Unlock(session->Lock); Unlock(session->Lock);
} }
for (i = 0; i < LIST_NUM(sessions->AllList); ++i) for (i = 0; i < LIST_NUM(sessions->AllList); ++i)
{ {
PROTO_SESSION *session = LIST_DATA(sessions->AllList, i); PROTO_SESSION *session = LIST_DATA(sessions->AllList, i);
if (session->Halt)
{
DeleteHash(sessions, session);
ProtoDeleteSession(session);
continue;
}
if (LIST_NUM(session->DatagramsIn) > 0) if (LIST_NUM(session->DatagramsIn) > 0)
{ {
SetSockEvent(session->SockEvent); SetSockEvent(session->SockEvent);
@ -678,7 +681,6 @@ void ProtoSessionThread(THREAD *thread, void *param)
while (session->Halt == false) while (session->Halt == false)
{ {
bool ok;
UINT interval; UINT interval;
void *param = session->Param; void *param = session->Param;
const PROTO_IMPL *impl = session->Impl; const PROTO_IMPL *impl = session->Impl;
@ -689,7 +691,7 @@ void ProtoSessionThread(THREAD *thread, void *param)
{ {
UINT i; UINT i;
ok = impl->ProcessDatagrams(param, received, to_send); session->Halt = impl->ProcessDatagrams(param, received, to_send) == false;
UdpListenerSendPackets(session->Proto->UdpListener, to_send); UdpListenerSendPackets(session->Proto->UdpListener, to_send);
@ -703,10 +705,9 @@ void ProtoSessionThread(THREAD *thread, void *param)
} }
Unlock(session->Lock); Unlock(session->Lock);
if (ok == false) if (session->Halt)
{ {
Debug("ProtoSessionThread(): breaking main loop\n"); Debug("ProtoSessionThread(): breaking main loop\n");
session->Halt = true;
break; break;
} }