diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index a76634630c6..e3bf0bba668 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -310,10 +310,6 @@ struct tcp_conn_s /* Callback instance for TCP send() */ FAR struct devif_callback_s *sndcb; - -#ifdef CONFIG_DEBUG_ASSERTIONS - int sndcb_alloc_cnt; /* The callback allocation counter */ -#endif #endif /* accept() is called when the TCP logic has created a connection diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index de96e60474b..0789fd7b18b 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -1182,30 +1182,16 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, { conn->sndcb = tcp_callback_alloc(conn); -#ifdef CONFIG_DEBUG_ASSERTIONS - if (conn->sndcb != NULL) + /* Test if the callback has been allocated */ + + if (conn->sndcb == NULL) { - conn->sndcb_alloc_cnt++; + /* A buffer allocation error occurred */ - /* The callback is allowed to be allocated only once. - * This is to catch a potential re-allocation after - * conn->sndcb was set to NULL. - */ - - DEBUGASSERT(conn->sndcb_alloc_cnt == 1); + nerr("ERROR: Failed to allocate callback\n"); + ret = nonblock ? -EAGAIN : -ENOMEM; + goto errout_with_lock; } -#endif - } - - /* Test if the callback has been allocated */ - - if (conn->sndcb == NULL) - { - /* A buffer allocation error occurred */ - - nerr("ERROR: Failed to allocate callback\n"); - ret = nonblock ? -EAGAIN : -ENOMEM; - goto errout_with_lock; } /* Set up the callback in the connection */