[comp.unix.i386] RPC questions

cs__sjh@umt.UUCP (Jeffrey Heng) (08/20/90)

I have run into a problem using broadcast RPC on 386/ix version 2.2,
and NFS 2.1.  After a broadcast RPC call, there are several portmappers
running, and the portmapper no longer works correctly.
We're using on a small TCP/IP network consisting of four 386s running 
Interactive UNIX 2.2 with NSF and MOTIF. 
This problem doesn't occur on a Sun computer.

Has anyone run accross this problem, and know of a workaround?  I think
yellow pages uses broadcast RPC without blowing away the portmapper.

Any help or suggestions will be greatly appreciated. Thank you.

Included are sample programs, server and client that illustrates the problem.
After starting server, but before you run client, these commands
will have the following output:
	% ps -e | grep portmap
	    4546 ?        0:00 portmap
	%
	% rpcinfo -p
	   program vers proto   port
	    100000    2   tcp    111  portmapper
	    100000    2   udp    111  portmapper
	    100017    1   tcp   1260  rexd
	    150001    1   udp   1481  pcnfsd
	    100005    1   udp   1484  mountd
	    100003    2   udp   2049  nfs
	    100024    1   udp   1494  status
	    100024    1   tcp   1261  status
	    100020    1   udp   1502  llockmgr
	    100020    1   tcp   1262  llockmgr
	    100021    2   tcp   1263  nlockmgr
	    100021    1   tcp   1265  nlockmgr
	    100021    1   udp   1511  nlockmg
		90    1   udp   1517
		90    1   tcp   1270

	%
When you run client, you will get the following output:
	% client
	daemon is running on CAD1
	%
Now the ps and rpcinfo commands return:
	% ps -e | grep portmap
	    4546 ?        0:00 portmap
	    4556 ?        0:00 portmap
	    4552 ?        0:00 portmap
	    4553 ?        0:00 portmap
	    4554 ?        0:00 portmap
	    4555 ?        0:00 portmap
	    4557 ?        0:00 portmap
	    4558 ?        0:00 portmap
	    4559 ?        0:00 portmap
	    4560 ?        0:00 portmap
	    4562 ?        0:00 portmap
	%
	% rpcinfo -p
	rpcinfo: can't contact portmapper: rpcinfo: RPC: Timed out
	%
To get things working again, I have to kill all the portmappers,
and restart it.  Restarting portmap without killing any portmaps
will not get the system working.

The program server:
	#include <stdio.h>
	#include <rpc/rpc.h>
	#include "daemon.h"

	int *
	dproc_1(val)
	int *val;
	{
		static int result = 0;
		return(&result);
	}

The program client:
	#include <stdio.h>
	#include <netdb.h>
	#include <rpc/rpc.h>
	#include <rpc/pmap_clnt.h>
	#include "daemon.h"

	bool_t eachresult() ;

	main()
	{
		int ret;
		= 0;
		enum clnt_stat clnt_stat;

		clnt_stat = clnt_broadcast(DPROG, DVERS, dproc,
		  xdr_int, &val, xdr_int, &ret, eachresult);
		
		if(clnt_stat != RPC_SUCCESS) {
			clnt_perrno(clnt_stat);
		}
	}

	bool_t
	eachresult(resultsp, raddr) 
	caddr_t resultsp;
	struct sockaddr_in *raddr;
	{
		struct hostent *hp;

		hp = gethostbyaddr(&raddr->sin_addr, sizeof(struct in_addr),
		  raddr->sin_family);

		printf("daemon is running on %s\n", hp->h_name);
		return(1);
	}

The rpcgen input file:

	program DPROG {
		version DVERS {
			int dproc(int) = 1;
		} = 1;
	} = 90;

A makefile:

	NETLIBS=-lrpc -linet
	all: daemon server client
	daemon: daemon.x
		rpcgen daemon.x
	server: server.o daemon_svc.o daemon.h
		cc -o server server.o daemon_svc.o $(NETLIBS)
	client: client.o daemon_clnt.o
		cc -o client client.o daemon_clnt.o $(NETLIBS)