Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115658284
D46303.id142105.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D46303.id142105.diff
View Options
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2566,56 +2566,15 @@
/*
* Optimized version of soreceive() for stream (TCP) sockets.
*/
-int
-soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio,
- struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
+static int
+soreceive_stream_locked(struct socket *so, struct sockbuf *sb,
+ struct sockaddr **psa, struct uio *uio, struct mbuf **mp0,
+ struct mbuf **controlp, int flags)
{
- int len = 0, error = 0, flags, oresid;
- struct sockbuf *sb;
+ int len = 0, error = 0, oresid;
struct mbuf *m, *n = NULL;
- /* We only do stream sockets. */
- if (so->so_type != SOCK_STREAM)
- return (EINVAL);
- if (psa != NULL)
- *psa = NULL;
- if (flagsp != NULL)
- flags = *flagsp &~ MSG_EOR;
- else
- flags = 0;
- if (controlp != NULL)
- *controlp = NULL;
- if (flags & MSG_OOB)
- return (soreceive_rcvoob(so, uio, flags));
- if (mp0 != NULL)
- *mp0 = NULL;
-
- sb = &so->so_rcv;
-
-#ifdef KERN_TLS
- /*
- * KTLS store TLS records as records with a control message to
- * describe the framing.
- *
- * We check once here before acquiring locks to optimize the
- * common case.
- */
- if (sb->sb_tls_info != NULL)
- return (soreceive_generic(so, psa, uio, mp0, controlp,
- flagsp));
-#endif
-
- /* Prevent other readers from entering the socket. */
- error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags));
- if (error)
- return (error);
-#ifdef KERN_TLS
- if (__predict_false(sb->sb_tls_info != NULL)) {
- SOCK_IO_RECV_UNLOCK(so);
- return (soreceive_generic(so, psa, uio, mp0, controlp,
- flagsp));
- }
-#endif
+ SOCK_IO_RECV_ASSERT_LOCKED(so);
SOCKBUF_LOCK(sb);
/* Easy one, no space to copyout anything. */
@@ -2778,6 +2737,62 @@
SBLASTRECORDCHK(sb);
SBLASTMBUFCHK(sb);
SOCKBUF_UNLOCK(sb);
+ return (error);
+}
+
+int
+soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio,
+ struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
+{
+ struct sockbuf *sb;
+ int error, flags;
+
+ sb = &so->so_rcv;
+
+ /* We only do stream sockets. */
+ if (so->so_type != SOCK_STREAM)
+ return (EINVAL);
+ if (psa != NULL)
+ *psa = NULL;
+ if (flagsp != NULL)
+ flags = *flagsp & ~MSG_EOR;
+ else
+ flags = 0;
+ if (controlp != NULL)
+ *controlp = NULL;
+ if (flags & MSG_OOB)
+ return (soreceive_rcvoob(so, uio, flags));
+ if (mp0 != NULL)
+ *mp0 = NULL;
+
+#ifdef KERN_TLS
+ /*
+ * KTLS store TLS records as records with a control message to
+ * describe the framing.
+ *
+ * We check once here before acquiring locks to optimize the
+ * common case.
+ */
+ if (sb->sb_tls_info != NULL)
+ return (soreceive_generic(so, psa, uio, mp0, controlp,
+ flagsp));
+#endif
+
+ /*
+ * Prevent other threads from reading from the socket. This lock may be
+ * dropped in order to sleep waiting for data to arrive.
+ */
+ error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags));
+ if (error)
+ return (error);
+#ifdef KERN_TLS
+ if (__predict_false(sb->sb_tls_info != NULL)) {
+ SOCK_IO_RECV_UNLOCK(so);
+ return (soreceive_generic(so, psa, uio, mp0, controlp,
+ flagsp));
+ }
+#endif
+ error = soreceive_stream_locked(so, sb, psa, uio, mp0, controlp, flags);
SOCK_IO_RECV_UNLOCK(so);
return (error);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 27, 4:47 PM (17 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17819928
Default Alt Text
D46303.id142105.diff (3 KB)
Attached To
Mode
D46303: socket: Split up soreceive_stream()
Attached
Detach File
Event Timeline
Log In to Comment