1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-22 07:20:00 +00:00

socket: Simplify synchronization in soreceive_stream()

Now that the socket recv I/O lock is required in order to enable
receive-side KTLS, we can move a check from out of the socket buffer
lock, which in turn will simplify some further refactoring.

Add a __predict_false annotation while here since we already perform a
lockless check before acquiring any locks.

Reviewed by:	gallatin, jhb
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45922
This commit is contained in:
Mark Johnston 2024-07-09 10:33:53 -04:00
parent 5dc4682c32
commit 30f30ccae7

View File

@ -2609,17 +2609,15 @@ soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio,
error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags));
if (error)
return (error);
SOCKBUF_LOCK(sb);
#ifdef KERN_TLS
if (sb->sb_tls_info != NULL) {
SOCKBUF_UNLOCK(sb);
if (__predict_false(sb->sb_tls_info != NULL)) {
SOCK_IO_RECV_UNLOCK(so);
return (soreceive_generic(so, psa, uio, mp0, controlp,
flagsp));
}
#endif
SOCKBUF_LOCK(sb);
/* Easy one, no space to copyout anything. */
if (uio->uio_resid == 0) {
error = EINVAL;