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

Function soreserve

freebsd/kern/uipc_sockbuf.c:561–587  ·  view source on GitHub ↗

* Socket buffer (struct sockbuf) utility routines. * * Each socket contains two socket buffers: one for sending data and one for * receiving data. Each buffer contains a queue of mbufs, information about * the number of mbufs and amount of data in the queue, and other fields * allowing select() statements and notification on data availability to be * implemented. * * Data stored in a sock

Source from the content-addressed store, hash-verified

559 * be released by calling sbrelease() when the socket is destroyed.
560 */
561int
562soreserve(struct socket *so, u_long sndcc, u_long rcvcc)
563{
564 struct thread *td = curthread;
565
566 SOCKBUF_LOCK(&so->so_snd);
567 SOCKBUF_LOCK(&so->so_rcv);
568 if (sbreserve_locked(&so->so_snd, sndcc, so, td) == 0)
569 goto bad;
570 if (sbreserve_locked(&so->so_rcv, rcvcc, so, td) == 0)
571 goto bad2;
572 if (so->so_rcv.sb_lowat == 0)
573 so->so_rcv.sb_lowat = 1;
574 if (so->so_snd.sb_lowat == 0)
575 so->so_snd.sb_lowat = MCLBYTES;
576 if (so->so_snd.sb_lowat > so->so_snd.sb_hiwat)
577 so->so_snd.sb_lowat = so->so_snd.sb_hiwat;
578 SOCKBUF_UNLOCK(&so->so_rcv);
579 SOCKBUF_UNLOCK(&so->so_snd);
580 return (0);
581bad2:
582 sbrelease_locked(&so->so_snd, so);
583bad:
584 SOCKBUF_UNLOCK(&so->so_rcv);
585 SOCKBUF_UNLOCK(&so->so_snd);
586 return (ENOBUFS);
587}
588
589static int
590sysctl_handle_sb_max(SYSCTL_HANDLER_ARGS)

Callers 15

udp_attachFunction · 0.85
div_attachFunction · 0.85
rip_attachFunction · 0.85
tcp_usr_attachFunction · 0.85
send_attachFunction · 0.85
udp6_attachFunction · 0.85
rip6_attachFunction · 0.85
uipc_socket.cFile · 0.85
sopeeloffFunction · 0.85
uipc_attachFunction · 0.85
raw_attachFunction · 0.85
ng_attach_commonFunction · 0.85

Calls 2

sbreserve_lockedFunction · 0.85
sbrelease_lockedFunction · 0.85

Tested by

no test coverage detected