net: socket: fix hanging net contexts

Calls put instead of unref on net contexts
in the socket accept function.
Mere unref didn't subtract the reference
count of net context which leaves
it in used state. This situation happens
in case of accepting already
closed connection.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
This commit is contained in:
Daniel Nejezchleb 2023-04-14 23:36:57 +02:00 committed by Carles Cufí
parent e9e5498a51
commit 663b684fea

View File

@ -615,7 +615,7 @@ int zsock_accept_ctx(struct net_context *parent, struct sockaddr *addr,
sock_set_eof(ctx);
z_free_fd(fd);
zsock_flush_queue(ctx);
net_context_unref(ctx);
net_context_put(ctx);
errno = ECONNABORTED;
return -1;
}
@ -625,7 +625,7 @@ int zsock_accept_ctx(struct net_context *parent, struct sockaddr *addr,
errno = ECONNABORTED;
z_free_fd(fd);
zsock_flush_queue(ctx);
net_context_unref(ctx);
net_context_put(ctx);
return -1;
}
@ -647,7 +647,7 @@ int zsock_accept_ctx(struct net_context *parent, struct sockaddr *addr,
z_free_fd(fd);
errno = ENOTSUP;
zsock_flush_queue(ctx);
net_context_unref(ctx);
net_context_put(ctx);
return -1;
}
}