mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Fixed memory leak
This commit is contained in:
parent
58ebfdffcb
commit
a73638b214
1 changed files with 11 additions and 11 deletions
|
@ -420,6 +420,7 @@ void NetconEthernetTap::removeConnection(TcpConnection *conn)
|
||||||
for(size_t i=0;i<_TcpConnections.size();++i) {
|
for(size_t i=0;i<_TcpConnections.size();++i) {
|
||||||
if(_TcpConnections[i] == conn){
|
if(_TcpConnections[i] == conn){
|
||||||
_TcpConnections.erase(_TcpConnections.begin() + i);
|
_TcpConnections.erase(_TcpConnections.begin() + i);
|
||||||
|
delete conn;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,10 +436,7 @@ void NetconEthernetTap::closeConnection(PhySocket *sock)
|
||||||
TcpConnection *conn = getConnection(sock);
|
TcpConnection *conn = getConnection(sock);
|
||||||
if(!conn)
|
if(!conn)
|
||||||
return;
|
return;
|
||||||
else
|
if(conn->pcb) {
|
||||||
removeConnection(conn);
|
|
||||||
if(!conn->pcb)
|
|
||||||
return;
|
|
||||||
if(conn->pcb->state == SYN_SENT || conn->pcb->state == CLOSE_WAIT) {
|
if(conn->pcb->state == SYN_SENT || conn->pcb->state == CLOSE_WAIT) {
|
||||||
dwr(MSG_DEBUG," closeConnection(): invalid PCB state for this operation. ignoring.\n");
|
dwr(MSG_DEBUG," closeConnection(): invalid PCB state for this operation. ignoring.\n");
|
||||||
return;
|
return;
|
||||||
|
@ -447,6 +445,8 @@ void NetconEthernetTap::closeConnection(PhySocket *sock)
|
||||||
if(lwipstack->_tcp_close(conn->pcb) != ERR_OK) {
|
if(lwipstack->_tcp_close(conn->pcb) != ERR_OK) {
|
||||||
dwr(MSG_ERROR," closeConnection(): error while calling tcp_close()\n");
|
dwr(MSG_ERROR," closeConnection(): error while calling tcp_close()\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
removeConnection(conn);
|
||||||
if(!sock)
|
if(!sock)
|
||||||
return;
|
return;
|
||||||
close(_phy.getDescriptor(sock));
|
close(_phy.getDescriptor(sock));
|
||||||
|
|
Loading…
Add table
Reference in a new issue