RPC_SVC_CALLS(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… RPC_SVC_CALLS(3) β€” library routines for RPC servers

okay bestie, welcome to the RPC server side of the universe ✨ this is the <rpc/rpc.h> girlies club, and honestly? it's giving "your server is about to be the main character." this page lives in the Library Functions Manual, and it's your cheat sheet for the whole squad of svc_* functions πŸŽ€


🌸 NAME 🌸

svc_dg_enablecache, svc_exit, svc_fdset, svc_freeargs, svc_getargs, svc_getreq_common, svc_getreq_poll, svc_getreqset, svc_getrpccaller, svc_pollset, svc_run, svc_sendreply β€” library routines for RPC servers 🫢


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” yeah, she's built in, no extra credit card needed πŸ’³βœ¨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <rpc/rpc.h>

int
svc_dg_enablecache(SVCXPRT *xprt, const unsigned cache_size);

void
svc_exit(void);

bool_t
svc_freeargs(const SVCXPRT *xprt, const xdrproc_t inproc, caddr_t in);

bool_t
svc_getargs(const SVCXPRT *xprt, const xdrproc_t inproc, caddr_t in);

void
svc_getreq_common(const int fd);

void
svc_getreq_poll(struct pollfd *pfdp, const int pollretval);

void
svc_getreqset(fd_set * rdfds);

struct netbuf *
svc_getrpccaller(const SVCXPRT *xprt);

struct cmsgcred *
__svc_getcallercreds(const SVCXPRT *xprt);

struct pollfd svc_pollset[FD_SETSIZE];

void
svc_run(void);

bool_t
svc_sendreply(SVCXPRT *xprt, xdrproc_t outproc, void *out);

πŸ’– DESCRIPTION πŸ’–

These routines are part of the RPC library, the whole thing that lets C programs make procedure calls on other machines across the network 🌐 like, remote procedure calls, hence the name, she's not subtle.

All of these are the server side of the RPC mechanism, and bestie there are two friend groups here: some of them get called by the server side dispatch function, and the others (hi svc_run()) get called when the server is initiated πŸ‘‘


🌈 Routines 🌈

peep rpc(3) for the definition of the SVCXPRT data structure β€” she's the VIP pass for all of this πŸ’…

✨ svc_dg_enablecache()

This function allocates a duplicate request cache for the service endpoint xprt, big enough to hold cache_size entries. It's giving "memory commitment." Once enabled, there is no way to disable caching β€” no take-backs, no undo, periodt πŸ’€

Returns 0 if the space necessary for a cache of the given size was successfully allocated, and 1 otherwise.

✨ svc_exit()

This function, when called by any of the RPC server procedure or otherwise, causes svc_run() to return πŸƒβ€β™€οΈπŸ’¨

As currently implemented, svc_exit() zeroes the svc_fdset global variable. So if RPC server activity is to be resumed, services must be reregistered with the RPC library β€” either through one of the rpc_svc_create(3) functions, or using xprt_register(). And heads up: svc_exit() has global scope and ends all RPC server activity. Not a local thing, not a "just this one" thing. Everything. 😭

✨ fd_set svc_fdset

A global variable reflecting the RPC server's read file descriptor bit mask, and it's suitable as an argument to the select(2) system call πŸŽ€

This is only of interest if service implementors do not call svc_run(), but rather do their own asynchronous event processing. Also: this variable is read-only β€” do not pass its address to select(2)! πŸ™ˆ Yet it may change after calls to svc_getreqset() or any creation routines.

✨ svc_freeargs()

A function macro that frees any data allocated by the RPC/XDR system when it decoded the arguments to a service procedure using svc_getargs() 🧹✨

Returns TRUE if the results were successfully freed, and FALSE otherwise.

✨ svc_getargs()

A function macro that decodes the arguments of an RPC request associated with the RPC service transport handle xprt. The in argument is the address where the arguments will be placed; inproc is the XDR routine used to decode the arguments πŸ“¦

Returns TRUE if decoding succeeds, and FALSE otherwise.

✨ svc_getreq_common()

This routine is called to handle a request on the given file descriptor 🎯

✨ svc_getreq_poll()

This one is only of interest if a service implementor does not call svc_run(), but instead implements custom asynchronous event processing.

It is called when poll(2) has determined that an RPC request has arrived on some RPC file descriptors; pollretval is the return value from poll(2) and pfdp is the array of pollfd structures on which the poll(2) was done. It is assumed to be an array large enough to contain the maximal number of descriptors allowed πŸ‘€

✨ svc_getreqset()

Same vibe check as above: only of interest if a service implementor does not call svc_run(), but instead implements custom asynchronous event processing.

It is called when poll(2) has determined that an RPC request has arrived on some RPC file descriptors; rdfds is the resultant read file descriptor bit mask. The routine returns when all file descriptors associated with the value of rdfds have been serviced βœ…

✨ svc_getrpccaller()

The approved way of getting the network address of the caller of a procedure associated with the RPC service transport handle xprt πŸ“¬ like, this is the sanctioned method, don't be out here doing weird workarounds bestie.

✨ __svc_getcallercreds()

⚠️ Warning: this macro is specific to FreeBSD and thus not portable πŸ’€

This macro returns a pointer to a cmsgcred structure, defined in <sys/socket.h>, identifying the calling client πŸ•΅οΈβ€β™€οΈ This only works if the client is calling the server over an AF_LOCAL socket.

✨ struct pollfd svc_pollset[FD_SETSIZE];

svc_pollset is an array of pollfd structures derived from svc_fdset[]. It is suitable as an argument to the poll(2) system call 🌸

The derivation of svc_pollset from svc_fdset is made in the current implementation in svc_run(). So service implementors who do not call svc_run() and who wish to use this array must perform this derivation themselves 🫑 no free rides!

✨ svc_run()

This routine never returns 😳 like literally never, she is committed.

It waits for RPC requests to arrive, and calls the appropriate service procedure using svc_getreq_poll() when one arrives. This procedure is usually waiting for the poll(2) system call to return πŸ’€

✨ svc_sendreply()

Called by an RPC service's dispatch routine to send the results of a remote procedure call πŸ“€

The xprt argument is the request's associated transport handle; outproc is the XDR routine which is used to encode the results; and out is the address of the results. This routine returns TRUE if it succeeds, FALSE otherwise πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

poll(2), select(2), rpc(3), rpc_svc_create(3), rpc_svc_err(3), rpc_svc_reg(3) β€” go read them, iykyk πŸ§šβ€β™€οΈ


and that's the page, bestie πŸŽ€ this one came from Debian, dated May 3, 1993 β€” yeah she's an icon from the olden days and she still slays πŸ’œ mwah, go build a server ✨

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms