mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-23 01:49:53 +03:00
Cedar/Proto.c: fix session deletion not being triggered in certain cases
ProtoHandleDatagrams() takes care of deleting a session if marked as halted. However, the check is performed when a packet for that session is received; that never happens if the remote host doesn't send at least a packet. This commit fixes the issue by moving the check into the loop that iterates through all sessions.
This commit is contained in:
parent
3b2db45509
commit
ac1b045634
@ -641,18 +641,14 @@ 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);
|
||||||
{
|
{
|
||||||
void *data = Clone(datagram->Data, datagram->Size);
|
if (session->Halt == false)
|
||||||
UDPPACKET *packet = NewUdpPacket(&datagram->SrcIP, datagram->SrcPort, &datagram->DstIP, datagram->DestPort, data, datagram->Size);
|
{
|
||||||
Add(session->DatagramsIn, packet);
|
void *data = Clone(datagram->Data, datagram->Size);
|
||||||
|
UDPPACKET *packet = NewUdpPacket(&datagram->SrcIP, datagram->SrcPort, &datagram->DstIP, datagram->DestPort, data, datagram->Size);
|
||||||
|
Add(session->DatagramsIn, packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Unlock(session->Lock);
|
Unlock(session->Lock);
|
||||||
}
|
}
|
||||||
@ -660,6 +656,13 @@ void ProtoHandleDatagrams(UDPLISTENER *listener, LIST *datagrams)
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user