Commit b107e6cf authored by Sebastian Smolorz via Xenomai's avatar Sebastian Smolorz via Xenomai Committed by Jan Kiszka

net/tcp: fix TCP connection termination

Closing a connected TCP socket initiates a handshake procedure. The
closing socket is supposed to receive two more packets and send one
ACK at the end. RTnet's TCP stack tries to get a reference to a
socket before writing data to its buffer. Taking a reference to an
RTnet socket in Xenomai 3 is realized by calling rtdm_fd_lock() which
fails when a socket is about to be closed.
Signed-off-by: 's avatarSebastian Smolorz <sebastian.smolorz@gmx.de>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 654eaaa3
......@@ -249,15 +249,18 @@ static struct rtsocket *rt_tcp_v4_lookup(u32 daddr, u16 dport)
{
rtdm_lockctx_t context;
struct tcp_socket *ts;
int ret;
rtdm_lock_get_irqsave(&tcp_socket_base_lock, context);
ts = port_hash_search(daddr, dport);
if (ts && rt_socket_reference(&ts->sock) == 0) {
rtdm_lock_put_irqrestore(&tcp_socket_base_lock, context);
if (ts != NULL) {
ret = rt_socket_reference(&ts->sock);
if (ret == 0 || (ret == -EIDRM && ts->is_closed)) {
rtdm_lock_put_irqrestore(&tcp_socket_base_lock, context);
return &ts->sock;
return &ts->sock;
}
}
rtdm_lock_put_irqrestore(&tcp_socket_base_lock, context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment