DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Programming with Remote Procedure Calls (RPC)

Server processing

Suppose a process is processing RPC requests while performing some other activity. If the other activity involves periodically updating a data structure, the process can set an alarm signal before calling svc_run.

If the other activity involves waiting on a file descriptor, however, the svc_run call will not work. Given the file descriptors of the transport endpoints associated with the programs being waited on, a process can have its own select that waits on both the RPC file descriptors and its own file descriptors.

For example, consider the code below, which is for an earlier version of svc_run. Note that svc_fdset is a bit mask of all the file descriptors that RPC is using for services. The mask can change every time any RPC library routine is called, because descriptors are constantly being opened and closed:

   void
   svc_run ()
   {
   	fd_set readfds;
   	extern int errno;
   

for (;;) { readfds = svc_fdset; switch (select(_rpc_dtbsize(), &readfds, (fd_set *)0, (fd_set *)0, (struct timeval *)0)) {

case -1: if (errno == EINTR) { continue; } /* * log an error: svc_run: select failed */ return; case 0: continue; default: svc_getreqset(&readfds); } } }

The current version of svc_run calls svc_getreq_poll. A process can bypass svc_run and call svc_getreqset (the dispatcher) or svc_getreq_poll directly. The svc_getreqset and svc_getreq_poll routines in turn call svc_getreq_common. These functions are described on the rpc_svc_reg(NS) manual page.


CAUTION: The svc_run and svc_getreq_poll routines are not thread-safe and should not be called from multiple threads of execution. See ``Writing multithreaded RPC procedures'' and also ``Multithreaded network programming'' for more information about using RPC with the Threads Library.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005