Third take on the r319685 and r320480. Actually allow for call soisconnected()

via soisdisconnected(), and in the earlier unlock earlier to avoid lock
recursion.

This fixes a situation when a socket on accept queue is reset before being
accepted.

Reported by:	Jason Eggleston <jeggleston llnw.com>
This commit is contained in:
Gleb Smirnoff 2017-08-24 20:49:19 +00:00
parent 0fa4377182
commit 555b3e2f2c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=322856
2 changed files with 4 additions and 3 deletions

View File

@ -334,7 +334,7 @@ sowakeup(struct socket *so, struct sockbuf *sb)
if (sb->sb_flags & SB_AIO)
sowakeup_aio(so, sb);
SOCKBUF_UNLOCK(sb);
if (ret == SU_ISCONNECTED && !(so->so_state & SS_ISDISCONNECTED))
if (ret == SU_ISCONNECTED)
soisconnected(so);
if ((so->so_state & SS_ASYNC) && so->so_sigio != NULL)
pgsigio(&so->so_sigio, SIGIO, 0);

View File

@ -3769,13 +3769,14 @@ soisdisconnected(struct socket *so)
so->so_state |= SS_ISDISCONNECTED;
if (!SOLISTENING(so)) {
SOCK_UNLOCK(so);
SOCKBUF_LOCK(&so->so_rcv);
socantrcvmore_locked(so);
SOCKBUF_LOCK(&so->so_snd);
sbdrop_locked(&so->so_snd, sbused(&so->so_snd));
socantsendmore_locked(so);
}
SOCK_UNLOCK(so);
} else
SOCK_UNLOCK(so);
wakeup(&so->so_timeo);
}