net: context: fix net context / net conn leak

If a net context is not connected or listening, we can go ahead and
call net_context_unref() to free it up instead of waiting for
FIN_ACK which will never happen.

Change-Id: Ice06f572df64f2edb5918c10c92087ce0b7b254a
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This commit is contained in:
Michael Scott 2017-02-07 09:10:15 -08:00 committed by Jukka Rissanen
parent 7acb7aceb3
commit a2e9dd1361
1 changed files with 3 additions and 1 deletions

View File

@ -422,7 +422,9 @@ int net_context_put(struct net_context *context)
#if defined(CONFIG_NET_TCP)
if (net_context_get_ip_proto(context) == IPPROTO_TCP) {
if (!context->tcp->fin_rcvd) {
if ((net_context_get_state(context) == NET_CONTEXT_CONNECTED ||
net_context_get_state(context) == NET_CONTEXT_LISTENING)
&& !context->tcp->fin_rcvd) {
NET_DBG("TCP connection in active close, not "
"disposing yet");
queue_fin(context);