Skip to content
Commit 79461a37 authored by Robert Lubos's avatar Robert Lubos Committed by Fabio Baltieri
Browse files

net: tcp: Fix TCP connection ref counting



The net_context/TCP connection context ref counting needed to be fixed,
to avoid situation where TCP connection context could be released
before net_context is released.

Generally, this commit modifies the ref counting of the above as
follows:
* net_context is referenced both by the application and TCP stack, when
  created.
* TCP context is referenced by the application when created. The TCP
  stack adds ref to the TCP context only after connection has been
  established.
* TCP stack needs to call the final upper layer callback when connection
  is closed, but before the TCP context is released (i. e. to give upper
  layer chance to dereference the context on its side). For this,
  tcp_conn_close() was introduced which is called from within TCP stack
  instead of directly dereferencing the TCP context.
* TCP stack dereferences the net_context only after the TCP context has
  been released (i. e. upper layer has dereferenced TCP context on it's
  side and connection has been tear down, if established).

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent c79a25b8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment