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:
parent
5dc4682c32
commit
30f30ccae7
@ -2609,17 +2609,15 @@ soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio,
|
|||||||
error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags));
|
error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags));
|
||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
SOCKBUF_LOCK(sb);
|
|
||||||
|
|
||||||
#ifdef KERN_TLS
|
#ifdef KERN_TLS
|
||||||
if (sb->sb_tls_info != NULL) {
|
if (__predict_false(sb->sb_tls_info != NULL)) {
|
||||||
SOCKBUF_UNLOCK(sb);
|
|
||||||
SOCK_IO_RECV_UNLOCK(so);
|
SOCK_IO_RECV_UNLOCK(so);
|
||||||
return (soreceive_generic(so, psa, uio, mp0, controlp,
|
return (soreceive_generic(so, psa, uio, mp0, controlp,
|
||||||
flagsp));
|
flagsp));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SOCKBUF_LOCK(sb);
|
||||||
/* Easy one, no space to copyout anything. */
|
/* Easy one, no space to copyout anything. */
|
||||||
if (uio->uio_resid == 0) {
|
if (uio->uio_resid == 0) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user