Remove redundant code in UDPSocketClose()

This commit is contained in:
TomAwezome 2020-07-28 00:30:18 -05:00 committed by VoidNV
parent 4653f274e2
commit a8fb259f3a
3 changed files with 52 additions and 12 deletions

47
src/Home/Net/Test9.CC Normal file
View file

@ -0,0 +1,47 @@
"\n$$TX+UL,\"Making new socket\"$$\n";
CUDPSocket *s = UDPSocket(AF_INET);
CSocketAddressIPV4 *addr = CAlloc(sizeof(CSocketAddressIPV4));
ClassRep(s,, 9);
ClassRep(addr,, 9);
"\n$$TX+UL,\"Setting addr family to AF_INET and port to 0xDEAF in B.E., then P to N with 102.33.6.1\"$$\n";
addr->family = AF_INET;
addr->port = EndianU16(0xDEAF);
PresentationToNetwork(AF_INET,"102.33.6.1",&addr->address);
ClassRep(addr,, 9);
"\n$$TX+UL,\"UDPSocket bind with socket to addr\"$$\n";
UDPSocketBind(s, addr);
ClassRep(s,, 9);
"\n$$TX+UL,\"Global Tree:\"$$\n";
ClassRep(udp_globals.bound_socket_tree,, 9);
"\n$$TX+UL,\"Global Tree: Port 0xDEAF Queue\"$$\n";
ClassRep(udp_globals.bound_socket_tree->queue,, 9);
"\n$$TX+UL,\"Closing first socket\"$$\n";
UDPSocketClose(s);
"\n$$TX+UL,\"Global Tree:\"$$\n";
ClassRep(udp_globals.bound_socket_tree,, 9);
"\n$$TX+UL,\"Global Tree: Port 0xDEAF Queue\"$$\n";
ClassRep(udp_globals.bound_socket_tree->queue,, 9);
ClassRep(udp_globals.bound_socket_tree->queue->socket,, 9);

View file

@ -509,19 +509,12 @@ I64 UDPSocketClose(CUDPSocket *udp_socket)
if (queue)
{
if (queue == queue->next == queue->last)
{ // queue is alone. Means port only has this address bound.
Debug("queue==next==last. implemented(?) this in SocketSinglePop, test it");
}
else
{ // queue has other addresses bound at this port. only Free the queue entry, after removing it.
UDPTreeNodeQueueSocketSinglePop(udp_socket, node);
UDPTreeNodeQueueSocketSinglePop(udp_socket, node);
Free(udp_socket->socket);
Free(udp_socket->receive_buffer);
Free(udp_socket);
Free(queue);
}
Free(udp_socket->socket);
Free(udp_socket->receive_buffer);
Free(udp_socket);
Free(queue);
}
else
{