mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 06:39:01 +08:00
tcp:add net_lock to protect tcp resource
add net_lock in the tcp_callback_cleanup & Set the devif_callback_s of tcp_callback_s to a two-dimensional pointer. Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
+1
-1
@@ -442,7 +442,7 @@ struct tcp_backlog_s
|
||||
struct tcp_callback_s
|
||||
{
|
||||
FAR struct tcp_conn_s *tc_conn;
|
||||
FAR struct devif_callback_s *tc_cb;
|
||||
FAR struct devif_callback_s **tc_cb;
|
||||
FAR sem_t *tc_sem;
|
||||
};
|
||||
|
||||
|
||||
@@ -437,8 +437,10 @@ void tcp_callback_cleanup(FAR void *arg)
|
||||
{
|
||||
FAR struct tcp_callback_s *cb = (FAR struct tcp_callback_s *)arg;
|
||||
|
||||
net_lock();
|
||||
nerr("ERROR: pthread is being canceled, need to cleanup cb\n");
|
||||
tcp_callback_free(cb->tc_conn, cb->tc_cb);
|
||||
tcp_callback_free(cb->tc_conn, *(cb->tc_cb));
|
||||
nxsem_destroy(cb->tc_sem);
|
||||
net_unlock();
|
||||
}
|
||||
#endif /* NET_TCP_HAVE_STACK */
|
||||
|
||||
@@ -375,7 +375,7 @@ int psock_tcp_connect(FAR struct socket *psock,
|
||||
*/
|
||||
|
||||
info.tc_conn = conn;
|
||||
info.tc_cb = state.tc_cb;
|
||||
info.tc_cb = &state.tc_cb;
|
||||
info.tc_sem = &state.tc_sem;
|
||||
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);
|
||||
|
||||
|
||||
@@ -803,7 +803,7 @@ static ssize_t tcp_recvfrom_one(FAR struct tcp_conn_s *conn, FAR void *buf,
|
||||
*/
|
||||
|
||||
info.tc_conn = conn;
|
||||
info.tc_cb = state.ir_cb;
|
||||
info.tc_cb = &state.ir_cb;
|
||||
info.tc_sem = &state.ir_sem;
|
||||
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);
|
||||
|
||||
|
||||
@@ -1467,7 +1467,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
*/
|
||||
|
||||
info.tc_conn = conn;
|
||||
info.tc_cb = conn->sndcb;
|
||||
info.tc_cb = &conn->sndcb;
|
||||
info.tc_sem = &conn->snd_sem;
|
||||
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);
|
||||
|
||||
|
||||
@@ -611,7 +611,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
|
||||
*/
|
||||
|
||||
info.tc_conn = conn;
|
||||
info.tc_cb = state.snd_cb;
|
||||
info.tc_cb = &state.snd_cb;
|
||||
info.tc_sem = &state.snd_sem;
|
||||
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user