net: tcp2: Socket was accepted too early
The TCP2 was calling accept callback before actually finalizing the connection attempt. Fixes #29164 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
c1ccd6b14e
commit
d3283231a5
|
@ -1079,10 +1079,7 @@ static enum net_verdict tcp_recv(struct net_conn *net_conn,
|
|||
|
||||
net_ipaddr_copy(&conn_old->context->remote, &conn->dst.sa);
|
||||
|
||||
conn_old->accept_cb(conn->context,
|
||||
&conn_old->context->remote,
|
||||
sizeof(struct sockaddr), 0,
|
||||
conn_old->context);
|
||||
conn->accepted_conn = conn_old;
|
||||
}
|
||||
in:
|
||||
if (conn) {
|
||||
|
@ -1266,6 +1263,18 @@ next_state:
|
|||
net_context_set_state(conn->context,
|
||||
NET_CONTEXT_CONNECTED);
|
||||
|
||||
if (conn->accepted_conn) {
|
||||
conn->accepted_conn->accept_cb(
|
||||
conn->context,
|
||||
&conn->accepted_conn->context->remote,
|
||||
sizeof(struct sockaddr), 0,
|
||||
conn->accepted_conn->context);
|
||||
|
||||
/* Make sure the accept_cb is only called once.
|
||||
*/
|
||||
conn->accepted_conn = NULL;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
if (tcp_data_get(conn, pkt) < 0) {
|
||||
break;
|
||||
|
|
|
@ -183,7 +183,10 @@ struct tcp { /* TCP connection */
|
|||
struct net_if *iface;
|
||||
void *recv_user_data;
|
||||
sys_slist_t send_queue;
|
||||
net_tcp_accept_cb_t accept_cb;
|
||||
union {
|
||||
net_tcp_accept_cb_t accept_cb;
|
||||
struct tcp *accepted_conn;
|
||||
};
|
||||
struct k_mutex lock;
|
||||
struct k_sem connect_sem; /* semaphore for blocking connect */
|
||||
struct tcp_options recv_options;
|
||||
|
|
Loading…
Reference in a new issue