socket: fix listen(2) on an already listening socket

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35669
Fixes:			141fe2dcee
This commit is contained in:
Gleb Smirnoff 2022-06-30 07:50:29 -07:00
parent a765ac11c5
commit 66c8e3fccf

View File

@ -948,8 +948,9 @@ solisten_proto_check(struct socket *so)
mtx_lock(&so->so_rcv_mtx);
/* Interlock with soo_aio_queue(). */
if ((so->so_snd.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0 ||
(so->so_rcv.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0) {
if (!SOLISTENING(so) &&
((so->so_snd.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0 ||
(so->so_rcv.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0)) {
solisten_proto_abort(so);
return (EINVAL);
}