Skip to content

Commit 9fef0c5

Browse files
rlubosfabiobaltieri
authored andcommitted
net: tcp: Remove net_tcp_unref()
There is a pending TODO regarding unifying net_tcp_unref() and net_tcp_put(). Given that net_tcp_unref() is no longer used by the upper layer (it should only use get/put APIs), the function can be removed from external TCP API, as referencing/dereferencing is now only used internally by the TCP stack. Signed-off-by: Robert Lubos <[email protected]>
1 parent 79461a3 commit 9fef0c5

File tree

3 files changed

+1
-43
lines changed

3 files changed

+1
-43
lines changed

subsys/net/ip/tcp.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -463,19 +463,6 @@ static int tcp_conn_unref(struct tcp *conn)
463463
return ref_count;
464464
}
465465

466-
int net_tcp_unref(struct net_context *context)
467-
{
468-
int ref_count = 0;
469-
470-
NET_DBG("context: %p, conn: %p", context, context->tcp);
471-
472-
if (context->tcp) {
473-
ref_count = tcp_conn_unref(context->tcp);
474-
}
475-
476-
return ref_count;
477-
}
478-
479466
#if CONFIG_NET_TCP_LOG_LEVEL >= LOG_LEVEL_DBG
480467
#define tcp_conn_close(conn, status) \
481468
tcp_conn_close_debug(conn, status, __func__, __LINE__)
@@ -2580,7 +2567,7 @@ int net_tcp_put(struct net_context *context)
25802567

25812568
k_mutex_unlock(&conn->lock);
25822569

2583-
net_tcp_unref(context);
2570+
tcp_conn_unref(conn);
25842571

25852572
return 0;
25862573
}

subsys/net/ip/tcp.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@ int net_tcp_get(struct net_context *context);
5252
*/
5353
int net_tcp_put(struct net_context *context);
5454

55-
/* TODO: Clarify what happens if the ref count goes to 0 */
56-
/**
57-
* @brief Unref a TCP connection
58-
*
59-
* @param context Network context
60-
*
61-
* @return 0 if successful, < 0 on error
62-
*/
63-
int net_tcp_unref(struct net_context *context);
64-
/* TODO: Merge net_tcp_unref() and net_tcp_put() */
65-
6655
/**
6756
* @brief Listen for an incoming TCP connection
6857
*

subsys/net/ip/tcp_internal.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,6 @@ static inline int net_tcp_get(struct net_context *context)
106106
}
107107
#endif
108108

109-
/**
110-
* @brief Unref TCP parts of a context
111-
*
112-
* @param context Network context
113-
*
114-
* @return 0 if successful, < 0 on error
115-
*/
116-
#if defined(CONFIG_NET_NATIVE_TCP)
117-
int net_tcp_unref(struct net_context *context);
118-
#else
119-
static inline int net_tcp_unref(struct net_context *context)
120-
{
121-
ARG_UNUSED(context);
122-
123-
return -EPROTONOSUPPORT;
124-
}
125-
#endif
126-
127109
/**
128110
* @brief Connect TCP connection
129111
*

0 commit comments

Comments
 (0)