[comp.protocols.nfs] Async RPC serving: one solution and one question

joshua@athertn.Atherton.COM (Flame Bait) (12/28/90)

I'm trying to write an asyncronous RPC server, and I've had some 
success, but it's not total.  The first part of this posting describes
what I've done, so if it solves your problem, you can use it.  The
second part describes the remaining problem, and asks for help.

When I say "Async RPC serving" I mean that the server spends most of
its time doing something else, but when an RPC call comes in, it drops
its normal work and fields the RPC call.  It then continues with what
it was doing before the RPC call arrived.  

I've got this to work using Sun's RPC over UDP quite easily.  I made no
changes to my client at all, and only three changes to the server.

First, I changed the main loop to be:
    initialize_async_rpc() ;
    do_real work() ;
instead of
    run_svc()

Second, I wrote the initialize_async_rpc stuff:
    pmap_unset
    transp = svcupd_create
    svc_register
    signal(SIGIO,handler)
    fcntl(transp->xp_sock,F_SETOWN,getpid())
    fcntl(transp->xp_sock,F_SETFL,FASYNC)

Third, I write the handler stuff (used in the function refered to in signal):
    handler()
    {
    #ifdef FD_SETSIZE
        fd_set readfds;
    #else
        int readfds;
    #endif /* def FD_SETSIZE */

    #ifdef FD_SETSIZE
        readfds = svc_fdset;
    #else
        readfds = svc_fds;
    #endif /* def FD_SETSIZE */
        svc_getreqset(&readfds);
    }

And it all seem to work, under UDP.  The problem is that I want it to
work under TCP, and it does not.  When I use TCP, both the client and
the server freeze when the request is made.  Can someone tell me
what changes I need to make in order for this to work under RPC/TCP?
Thanks.

Joshua Levy   (joshua@atherton.com)    (408) 734-9822