Skip to content

Commit

Permalink
tcp/tls: fix tcp tls bugs
Browse files Browse the repository at this point in the history
assert: tcp conn and didn't recv ack, tcp_free will assert in L909
and no need to tcp free because tcp close will free by lpwork.

Change-Id: I5060980c27818ab2d1add6fe04417f04e4e8ea2f
Signed-off-by: meijian <[email protected]>
  • Loading branch information
Meissi-jian committed Nov 20, 2024
1 parent 42326e0 commit 33ef285
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 19 deletions.
3 changes: 1 addition & 2 deletions net/tcp/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,7 @@ struct tcp_callback_s
{
FAR struct tcp_conn_s *tc_conn;
FAR struct devif_callback_s *tc_cb;
sem_t *tc_sem;
bool tc_free;
FAR sem_t *tc_sem;
};

/****************************************************************************
Expand Down
14 changes: 1 addition & 13 deletions net/tcp/tcp_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,7 @@ void tcp_callback_cleanup(FAR void *arg)
FAR struct tcp_callback_s *cb = (FAR struct tcp_callback_s *)arg;

nerr("ERROR: pthread is being canceled, need to cleanup cb\n");

tcp_callback_free(cb->tc_conn, cb->tc_cb);
if (cb->tc_sem)
{
nxsem_destroy(cb->tc_sem);
}

/* Only connect canceled need to tcp_free */

if (cb->tc_free)
{
tcp_free(cb->tc_conn);
}
nxsem_destroy(cb->tc_sem);
}

#endif /* NET_TCP_HAVE_STACK */
1 change: 0 additions & 1 deletion net/tcp/tcp_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ int psock_tcp_connect(FAR struct socket *psock,
info.tc_conn = conn;
info.tc_cb = state.tc_cb;
info.tc_sem = &state.tc_sem;
info.tc_free = true;
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);

/* Wait for either the connect to complete or for an
Expand Down
1 change: 0 additions & 1 deletion net/tcp/tcp_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,6 @@ ssize_t psock_tcp_recvfrom(FAR struct socket *psock, FAR struct msghdr *msg,
info.tc_conn = conn;
info.tc_cb = state.ir_cb;
info.tc_sem = &state.ir_sem;
info.tc_free = false;
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);

/* Wait for either the receive to complete or for an error/timeout
Expand Down
1 change: 0 additions & 1 deletion net/tcp/tcp_send_buffered.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,6 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
info.tc_conn = conn;
info.tc_cb = conn->sndcb;
info.tc_sem = &conn->snd_sem;
info.tc_free = false;
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);

ret = net_sem_timedwait_uninterruptible(&conn->snd_sem,
Expand Down
1 change: 0 additions & 1 deletion net/tcp/tcp_send_unbuffered.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
info.tc_conn = conn;
info.tc_cb = state.snd_cb;
info.tc_sem = &state.snd_sem;
info.tc_free = false;
tls_cleanup_push(tls_get_info(), tcp_callback_cleanup, &info);

ret = net_sem_timedwait(&state.snd_sem,
Expand Down

0 comments on commit 33ef285

Please sign in to comment.