Fixed recursive lock problem in closeConnection

This commit is contained in:
Joseph Henry 2015-09-24 16:15:14 -04:00
parent b263926ea6
commit c25ceaf06b
2 changed files with 15 additions and 9 deletions

View file

@ -145,6 +145,9 @@ public:
void (*_netif_set_up)(NETIF_SET_UP_SIG); void (*_netif_set_up)(NETIF_SET_UP_SIG);
void (*_netif_poll)(NETIF_POLL_SIG); void (*_netif_poll)(NETIF_POLL_SIG);
Mutex _lock;
LWIPStack(const char* path) : LWIPStack(const char* path) :
_libref(NULL) _libref(NULL)
{ {

View file

@ -292,14 +292,14 @@ void NetconEthernetTap::closeAllClients()
void NetconEthernetTap::closeConnection(NetconConnection *conn) void NetconEthernetTap::closeConnection(NetconConnection *conn)
{ {
NetconClient *client = conn->owner; NetconClient *client = conn->owner;
lwipstack->tcp_arg(conn->pcb, NULL); lwipstack->_tcp_arg(conn->pcb, NULL);
lwipstack->tcp_sent(conn->pcb, NULL); lwipstack->_tcp_sent(conn->pcb, NULL);
lwipstack->tcp_recv(conn->pcb, NULL); lwipstack->_tcp_recv(conn->pcb, NULL);
lwipstack->tcp_err(conn->pcb, NULL); lwipstack->_tcp_err(conn->pcb, NULL);
lwipstack->tcp_poll(conn->pcb, NULL, 0); lwipstack->_tcp_poll(conn->pcb, NULL, 0);
lwipstack->tcp_close(conn->pcb); lwipstack->_tcp_close(conn->pcb);
_phy.close(conn->sock); _phy.close(conn->sock);
lwipstack->tcp_close(conn->pcb); lwipstack->_tcp_close(conn->pcb);
client->removeConnection(conn->sock); client->removeConnection(conn->sock);
} }
@ -308,8 +308,11 @@ void NetconEthernetTap::closeConnection(NetconConnection *conn)
*/ */
void NetconEthernetTap::closeClient(NetconClient *client) void NetconEthernetTap::closeClient(NetconClient *client)
{ {
closeConnection(client->rpc); {
closeConnection(client->unmapped_conn); Mutex::Lock _l(lwipstack->_lock);
closeConnection(client->rpc);
closeConnection(client->unmapped_conn);
}
for(size_t i=0; i<client->connections.size(); i++) for(size_t i=0; i<client->connections.size(); i++)
{ {
close(_phy.getDescriptor(client->connections[i]->sock)); close(_phy.getDescriptor(client->connections[i]->sock));