MCPcopy Create free account
hub / github.com/F-Stack/f-stack / soreceive_stream

Function soreceive_stream

freebsd/kern/uipc_socket.c:2392–2609  ·  view source on GitHub ↗

* Optimized version of soreceive() for stream (TCP) sockets. */

Source from the content-addressed store, hash-verified

2390 * Optimized version of soreceive() for stream (TCP) sockets.
2391 */
2392int
2393soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio,
2394 struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
2395{
2396 int len = 0, error = 0, flags, oresid;
2397 struct sockbuf *sb;
2398 struct mbuf *m, *n = NULL;
2399
2400 /* We only do stream sockets. */
2401 if (so->so_type != SOCK_STREAM)
2402 return (EINVAL);
2403 if (psa != NULL)
2404 *psa = NULL;
2405 if (flagsp != NULL)
2406 flags = *flagsp &~ MSG_EOR;
2407 else
2408 flags = 0;
2409 if (controlp != NULL)
2410 *controlp = NULL;
2411 if (flags & MSG_OOB)
2412 return (soreceive_rcvoob(so, uio, flags));
2413 if (mp0 != NULL)
2414 *mp0 = NULL;
2415
2416 sb = &so->so_rcv;
2417
2418#ifdef KERN_TLS
2419 /*
2420 * KTLS store TLS records as records with a control message to
2421 * describe the framing.
2422 *
2423 * We check once here before acquiring locks to optimize the
2424 * common case.
2425 */
2426 if (sb->sb_tls_info != NULL)
2427 return (soreceive_generic(so, psa, uio, mp0, controlp,
2428 flagsp));
2429#endif
2430
2431 /* Prevent other readers from entering the socket. */
2432 error = sblock(sb, SBLOCKWAIT(flags));
2433 if (error)
2434 return (error);
2435 SOCKBUF_LOCK(sb);
2436
2437#ifdef KERN_TLS
2438 if (sb->sb_tls_info != NULL) {
2439 SOCKBUF_UNLOCK(sb);
2440 sbunlock(sb);
2441 return (soreceive_generic(so, psa, uio, mp0, controlp,
2442 flagsp));
2443 }
2444#endif
2445
2446 /* Easy one, no space to copyout anything. */
2447 if (uio->uio_resid == 0) {
2448 error = EINVAL;
2449 goto out;

Callers

nothing calls this directly

Calls 11

soreceive_rcvoobFunction · 0.85
sblockFunction · 0.85
sbunlockFunction · 0.85
sbwaitFunction · 0.85
minFunction · 0.85
m_catFunction · 0.85
sbfreeFunction · 0.85
m_copymFunction · 0.85
m_mbuftouioFunction · 0.85
sbdrop_lockedFunction · 0.85
sbavailFunction · 0.50

Tested by

no test coverage detected