Multi-threading RPC servers

Multi-threading RPC servers

Post by Mike Walmsl » Tue, 04 Oct 1994 02:35:54



I have an application that currently (under SunOs 4.x) implements a
multi-threaded RPC server.  This is based on the ideas in the Nutshell
book (Power Programming with RPC's if my memory is correct) and works
reliably using the LWP libraries available with SunOS 4.x.

I now come to wish to port this to a Solaris 2.3 environment.  Quite
clearly all of the Sun documentation indicates that the server code is not
MT-safe, and indeed (well you've got to touch the paint to see if it really
IS wet!) I get weird and wonderful results if I try a very literal
translation of the LWP version.  

Whilst the basic calling mechanism does not break, the return mechanism
seems to sometimes return garbage and generally fall apart quite
dramatically, even with a single RPC operation in progress at any one time.
The design does run a thread per RPC operation, so the single RPC operation
situation does create a thread for the operation, whilst the main thread
returns to listening for requests.  Needless to say, everything is fine
if the server is kept truely single threaded.

Does anyone have any ideas where the MT-unsafeness lies in the RPC server
code, or know of likely sources of information on this subject?

Many thanks for your anticipated help...

--------------------------------------------------------

                        Voice:    +44 121 707 9163

 
 
 

Multi-threading RPC servers

Post by Adrian Cockcroft - SMCC Product Marketing Engineeri » Wed, 05 Oct 1994 09:32:40


You should use Solaris 2.4. They did a good job of fixing this limitation.

Extract from the Solaris 2.4 rpcgen manpage:

     -A              Enable the Automatic MT mode in  the  server
                    main  program.  In this mode, the RPC library
                    automatically  creates  threads  to   service
                    client   requests.    This  option  generates
                    multithread-safe stubs by implicitly  turning
                    on  the  -M  option.   Server  multithreading
                    modes and parameters can  be  set  using  the
                    rpc_control()  call.   rpcgen  generated code
                    does not change the default  values  for  the
                    Automatic MT mode.

Regards Adrian


>I have an application that currently (under SunOs 4.x) implements a
>multi-threaded RPC server.  This is based on the ideas in the Nutshell
>book (Power Programming with RPC's if my memory is correct) and works
>reliably using the LWP libraries available with SunOS 4.x.

>I now come to wish to port this to a Solaris 2.3 environment.  Quite
>clearly all of the Sun documentation indicates that the server code is not
>MT-safe, and indeed (well you've got to touch the paint to see if it really
>IS wet!) I get weird and wonderful results if I try a very literal
>translation of the LWP version.  

>Whilst the basic calling mechanism does not break, the return mechanism
>seems to sometimes return garbage and generally fall apart quite
>dramatically, even with a single RPC operation in progress at any one time.
>The design does run a thread per RPC operation, so the single RPC operation
>situation does create a thread for the operation, whilst the main thread
>returns to listening for requests.  Needless to say, everything is fine
>if the server is kept truely single threaded.

>Does anyone have any ideas where the MT-unsafeness lies in the RPC server
>code, or know of likely sources of information on this subject?

>Many thanks for your anticipated help...

>--------------------------------------------------------

>                        Voice:    +44 121 707 9163

---

SMCC Product Marketing Engineering - Phone 415 336 0615 - Fax 415 336 0648
Sun Microsystems, 2550 Garcia Avenue, Mountainview, CA 94043, USA

 
 
 

Multi-threading RPC servers

Post by Raj Srinivas » Thu, 06 Oct 1994 04:05:20



>Does anyone have any ideas where the MT-unsafeness lies in the RPC server
>code, or know of likely sources of information on this subject?

Mike,

Server side multi-threading is supported in Solaris 2.4. This is
described in the Solaris 2.4 Network Interfaces Programming Guide.

There are many areas of MT-unsafeness in the Solaris 2.3 RPC server
code, and even though I haven't read the Nutshell book, I would
guess that it would be pretty difficult to do what you've
done in 4.x for the Solaris 2.3 context.

If you have any questions about server side multi-threading in 2.4,
please drop me a line.

Raj