[comp.unix.questions] RPC programming

tph@cs.utexas.edu (Pow-Hwee Tan) (02/27/90)

Howdy!

I have just started doing some NFS programming using RPC and XDR, and
have the following questions which I hope some of you can enlighten
me.

1.  I am using the intermediate RPC layer of function calls as described
in Sun's documenation.  The two functions calls I used are callprc and
registerrpc.  Both of these functions require a program number as
parameter.  As I understand from the documentation, I can use the numbers
in the range 0x20000000 - 0x3fffffff.  Am I right?  Or do I need to
make some kind of call to find out what number I should use?

2.  The XDR serializing/deserializing routines do not explicitly free
the memory allocated.  How can I free them myself?

Thanks in advance for any help.

---
P.H. Tan
tph@cs.utexas.edu

mh@awds26.eaton.com (Mike Hoegeman) (03/02/90)

In article <8008@cs.utexas.edu> tph@cs.utexas.edu (Pow-Hwee Tan) writes:
 >Howdy!
 >I have just started doing some NFS programming using RPC and XDR, and
 >have the following questions which I hope some of you can enlighten
 >me.
 >1.  I am using the intermediate RPC layer of function calls as described
 >in Sun's documenation.  The two functions calls I used are callprc and
 >registerrpc.  Both of these functions require a program number as
 >parameter.  As I understand from the documentation, I can use the numbers
 >in the range 0x20000000 - 0x3fffffff.  Am I right?  Or do I need to
 >make some kind of call to find out what number I should use?

there is no call to get an OK program number , just use one in the 
temporary range. 

also, just from the general tone of your message, i would guess that you
need to read up on RPCGEN, which is an RPC client <-->server protocol
compiler. this will do a lot of the mechanical rpc coding for you.
it will elminate you needing to things like 'registerrpc'.

 
 >2.  The XDR serializing/deserializing routines do not explicitly free
 >the memory allocated.  How can I free them myself?

for free client side xdr memory, check out clnt_freeres in the RPC(3N)
man page for sunOS.  you should'nt need anything on the server side if
you use RPCGEN.  also check out clnt_create, clnt_call, and
clnt_destory.  you should really use these instead of callrpc. in fact,
if you use RPCGEN you just call a canned routine that RPCGEN makes for
you from your protocol description.

zessel@descartes.informatik.uni-kl.de (Holger Zessel) (03/04/90)

tph@cs.utexas.edu (Pow-Hwee Tan) writes:
>Howdy!

>I have just started doing some NFS programming using RPC and XDR, and
>have the following questions which I hope some of you can enlighten
>me.

>1.  ...

>2.  The XDR serializing/deserializing routines do not explicitly free
>the memory allocated.  How can I free them myself?

This would interest me too. I write some kind of NFS-Server. Now 
I have the problem that ist prototypes are growing permanently while
serving NFS-requests. I could not find any reason for this memory leak
in my code.
>P.H. Tan
>tph@cs.utexas.edu
Holger
----------------------------------------------------------------
Holger Zessel, uucp: ...!uunet!unido!uklirb!incas!zessel
	or	zessel@informatik.uni-kl.de
	or	zessel%informatik.uni-kl.de@relay.cs.net (from usa)
Fachbereich Informatik, SFB124-D1
Universitaet Kaiserslautern, West-Germany

RSPELLMAN@bat.bates.edu (03/08/90)

tph@cs.utexas.edu write:
>2.  The XDR serializing/deserializing routines do not explicitly free
>the memory allocated.  How can I free them myself?

/*
 * Xdr operations.  XDR_ENCODE causes the type to be encoded into the
 * stream.  XDR_DECODE causes the type to be extracted from the stream.
 * XDR_FREE can be used to release the space allocated by an XDR_DECODE
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 * request.
 */
enum xdr_op {
     XDR_ENCODE=0,
     XDR_DECODE=1,
     XDR_FREE=2
};

This piece of code comes from xdr.h.  These enums define the values for
xdrs->x_op.

liam@cs.qmw.ac.uk (William Roberts) (03/09/90)

If you've actually followed the examples and read the
documentation, you should be using a loop of the form


            svc_getargs( .... stuff ... )
            handle the call and do whatever your server is
                        supposed to do
            svc_freeargs( .... stuff ... )

The svc_freeargs call releases all the memory malloc'd by the
svc_getargs, and the argument list is identical.

If you've done anything more complicated, then shame on you for
not reading the documentation!
-- 

William Roberts                 ARPA: liam@cs.qmw.ac.uk
Queen Mary & Westfield College  UUCP: liam@qmw-cs.UUCP
Mile End Road                   AppleLink: UK0087
LONDON, E1 4NS, UK              Tel:  01-975 5250 (Fax: 01-980 6533)

mb@rex.cs.tulane.edu (Mark Benard) (03/15/90)

In article <3744@incas.informatik.uni-kl.de> zessel@descartes.informatik.uni-kl.de (Holger Zessel) writes:
>tph@cs.utexas.edu (Pow-Hwee Tan) writes:
>>2.  The XDR serializing/deserializing routines do not explicitly free
>>the memory allocated.  How can I free them myself?
>
>This would interest me too. I write some kind of NFS-Server. Now
>I have the problem that ist prototypes are growing permanently while
>serving NFS-requests. I could not find any reason for this memory leak
>in my code.

Won't xdr_free() do the job?

Mark
-- 
Mark Benard
Department of Computer Science     INTERNET & BITNET: mb@cs.tulane.edu
Tulane University                  USENET:   rex!mb
New Orleans, LA 70118