Fix to net_con_close() which allows us to either delete the connection immediately if that is safe, or delete it later.
This commit is contained in:
parent
310ddf4e9d
commit
20ef6f8e53
@ -202,21 +202,21 @@ void net_con_update(struct net_connection* con, int ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void net_con_close(struct net_connection* con)
|
int net_con_close(struct net_connection* con)
|
||||||
{
|
{
|
||||||
uhub_assert(con);
|
uhub_assert(con);
|
||||||
|
|
||||||
if (net_con_flag_get(con, NET_CLEANUP))
|
if (net_con_flag_get(con, NET_CLEANUP))
|
||||||
{
|
{
|
||||||
LOG_INFO("Running net_con_close, but we already have closed...");
|
LOG_INFO("Running net_con_close, but we already have closed...");
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_con_flag_get(con, NET_PROCESSING_BUSY))
|
if (net_con_flag_get(con, NET_PROCESSING_BUSY))
|
||||||
{
|
{
|
||||||
LOG_INFO("Trying to close socket while processing it");
|
LOG_INFO("Trying to close socket while processing it");
|
||||||
net_con_flag_set(con, NET_CLEANUP);
|
net_con_flag_set(con, NET_CLEANUP);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_con_flag_get(con, NET_INITIALIZED))
|
if (net_con_flag_get(con, NET_INITIALIZED))
|
||||||
@ -230,6 +230,7 @@ void net_con_close(struct net_connection* con)
|
|||||||
con->sd = -1;
|
con->sd = -1;
|
||||||
|
|
||||||
net_con_flag_set(con, NET_CLEANUP);
|
net_con_flag_set(con, NET_CLEANUP);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SSL_SUPPORT
|
#ifdef SSL_SUPPORT
|
||||||
|
@ -69,10 +69,10 @@ extern void net_con_update(struct net_connection* con, int events);
|
|||||||
/**
|
/**
|
||||||
* Close the connection.
|
* Close the connection.
|
||||||
* This will ensure a connection is closed properly and will generate a NET_EVENT_DESTROYED event which indicates
|
* This will ensure a connection is closed properly and will generate a NET_EVENT_DESTROYED event which indicates
|
||||||
* that the con can safely be deleted (or set to NULL)
|
* that the con can safely be deleted (or set to NULL).
|
||||||
* NOTE: Do not dele
|
* @returns 1 if the memory can be freed immediately, or 0 if it needs to go through the NET_EVENT_DESTROYED event.
|
||||||
*/
|
*/
|
||||||
extern void net_con_close(struct net_connection* con);
|
extern int net_con_close(struct net_connection* con);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send data
|
* Send data
|
||||||
|
Loading…
Reference in New Issue
Block a user