Exemple #1
0
void *
dbgsysLoadLibrary(const char *name, char *err_buf, int err_buflen)
{
    void * result;
#ifdef NATIVE
    result = dlopen(name, RTLD_LAZY);
#else
    sysMonitorEnter(greenThreadSelf(), &_dl_lock);
    result = dlopen(name, RTLD_NOW);
    sysMonitorExit(greenThreadSelf(), &_dl_lock);
    /*
     * This is a bit of bulletproofing to catch the commonly occurring
     * problem of people loading a library which depends on libthread into
     * the VM.  thr_main() should always return -1 which means that libthread
     * isn't loaded.
     */
    if (thr_main() != -1) {
         VM_CALL(panic)("libthread loaded into green threads");
    }
#endif
    if (result == NULL) {
        (void)strncpy(err_buf, dlerror(), err_buflen-2);
        err_buf[err_buflen-1] = '\0';
    }
    return result;
}
Exemple #2
0
res_state
__res_state(void)
{
	res_state statp;

	if (thr_main() != 0)
		return (&_res);

	if (thr_once(&res_init_once, res_keycreate) != 0 ||
	    !res_thr_keycreated)
		return (&_res);

	statp = thr_getspecific(res_key);
	if (statp != NULL)
		return (statp);
	statp = calloc(1, sizeof(*statp));
	if (statp == NULL)
		return (&_res);
#ifdef __BIND_RES_TEXT
	statp->options = RES_TIMEOUT;			/* Motorola, et al. */
#endif
	if (thr_setspecific(res_key, statp) == 0)
		return (statp);
	free(statp);
	return (&_res);
}
/*
 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
 */
enum clnt_stat
clnt_broadcast(u_long prog, u_long vers, u_long proc, xdrproc_t xargs,
    void *argsp, xdrproc_t xresults, void *resultsp, resultproc_t eachresult)
/*
 *	u_long		prog;		// program number
 *	u_long		vers;		// version number
 *	u_long		proc;		// procedure number
 *	xdrproc_t	xargs;		// xdr routine for args
 *	void	       *argsp;		// pointer to args
 *	xdrproc_t	xresults;	// xdr routine for results
 *	void	       *resultsp;	// pointer to results
 *	resultproc_t	eachresult;	// call with each result obtained
 */
{

	if (thr_main())
		clnt_broadcast_result_main = eachresult;
	else {
		thr_once(&clnt_broadcast_once, clnt_broadcast_key_init);
		thr_setspecific(clnt_broadcast_key, (void *) eachresult);
	}
	return rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers,
	    (rpcproc_t)proc, xargs, argsp, xresults, resultsp,
	    (resultproc_t) rpc_wrap_bcast, "udp");
}
Exemple #4
0
char *
fdevname(int fd)
{
	char	*buf;
	int	error;

	if (thr_main() != 0)
		buf = fdevname_buf;
	else {
		if (thr_once(&fdevname_init_once, fdevname_keycreate) != 0 ||
		    !fdevname_keycreated)
			return (NULL);
		if ((buf = thr_getspecific(fdevname_key)) == NULL) {
			if ((buf = malloc(sizeof fdevname_buf)) == NULL)
				return (NULL);
			if (thr_setspecific(fdevname_key, buf) != 0) {
				free(buf);
				return (NULL);
			}
		}
	}

	if (((error = fdevname_r(fd, buf, sizeof fdevname_buf))) != 0) {
		errno = error;
		return (NULL);
	}
	return (buf);
}
Exemple #5
0
static int *
__nc_error(void)
{
	static int nc_error = 0;
	int *nc_addr;

	/*
	 * Use the static `nc_error' if we are the main thread
	 * (including non-threaded programs), or if an allocation
	 * fails.
	 */
	if (thr_main())
		return (&nc_error);
	if (thr_once(&nc_once, nc_key_init) != 0 || nc_key_error != 0)
		return (&nc_error);
	if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) {
		nc_addr = (int *)malloc(sizeof (int));
		if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
			free(nc_addr);
			return (&nc_error);
		}
		*nc_addr = 0;
	}
	return (nc_addr);
}
Exemple #6
0
char *
ttyname(int fd)
{
	char	*buf;

	if (thr_main() != 0)
		buf = ttyname_buf;
	else {
		if (thr_once(&ttyname_init_once, ttyname_keycreate) != 0 ||
		    !ttyname_keycreated)
			return (NULL);
		if ((buf = thr_getspecific(ttyname_key)) == NULL) {
			if ((buf = malloc(sizeof ttyname_buf)) == NULL)
				return (NULL);
			if (thr_setspecific(ttyname_key, buf) != 0) {
				free(buf);
				return (NULL);
			}
		}
	}

	if (ttyname_r(fd, buf, sizeof ttyname_buf) != 0)
		return (NULL);
	return (buf);
}
static char *
sig_tlsalloc(void)
{
	char *ebuf = NULL;

	if (thr_main() != 0)
		ebuf = sig_ebuf;
	else {
		if (thr_once(&sig_init_once, sig_keycreate) != 0 ||
		    !sig_keycreated)
			goto thr_err;
		if ((ebuf = thr_getspecific(sig_key)) == NULL) {
			if ((ebuf = malloc(sizeof(sig_ebuf))) == NULL)
				goto thr_err;
			if (thr_setspecific(sig_key, ebuf) != 0) {
				free(ebuf);
				ebuf = NULL;
				goto thr_err;
			}
		}
	}
thr_err:
	if (ebuf == NULL)
		ebuf = sig_ebuf_err;
	return (ebuf);
}
Exemple #8
0
int
ea_error(void)
{
	if (thr_main())
		return (exacct_errval);
	if (errkey == THR_ONCE_KEY)
		return (EXR_OK);
	return ((int)(uintptr_t)pthread_getspecific(errkey));
}
Exemple #9
0
void
exacct_seterr(int errval)
{
	if (thr_main()) {
		exacct_errval = errval;
		return;
	}
	(void) thr_keycreate_once(&errkey, 0);
	(void) thr_setspecific(errkey, (void *)(intptr_t)errval);
}
Exemple #10
0
int *
___nbra(void)
{
	if (thr_main())
		return (&nbra);
	else {
		vars_storage *vars = _get_vars_storage(&key);
		return (&vars->nbra);
	}
}
Exemple #11
0
int *
___reglength(void)
{
	if (thr_main())
		return (&reglength);
	else {
		vars_storage *vars = _get_vars_storage(&key);
		return (&vars->reglength);
	}
}
Exemple #12
0
/* ARGSUSED2 */
static bool_t
rpc_wrap_bcast(char *resultp, struct netbuf *addr, struct netconfig *nconf)
{
	resultproc_t clnt_broadcast_result;

	clnt_broadcast_result = thr_main()? clnt_broadcast_result_main :
		(resultproc_t)pthread_getspecific(clnt_broadcast_key);
	return ((*clnt_broadcast_result)(resultp,
				/* LINTED pointer cast */
				(struct sockaddr_in *)addr->buf));
}
Exemple #13
0
int *
__t_errno(void)
{
	static pthread_key_t t_errno_key = PTHREAD_ONCE_KEY_NP;
	int *ret;

	if (thr_main())
		return (&t_errno);
	ret = thr_get_storage(&t_errno_key, sizeof (int), free);
	/* if thr_get_storage fails we return the address of t_errno */
	return (ret ? ret : &t_errno);
}
Exemple #14
0
/* Initialize platform specific portions of the instance Globals */
void
KCPInitIGblP(KpGenericPtr_t FAR* theIGPtr, initializedGlobals_p iGP)
{
KpInt32_t	nProcessors;
#if defined(KCP_ACCEL)
	char	tempBuffer[100];
#endif

	if (theIGPtr) {}

	/* setup directory for CPxx files */
#if defined (KPSGI) || defined(KPSGIALL)
	strcpy (iGP->KCPDataDir, "/var/cms/cmscp/");
#elif defined (KPSUN) && defined (SOLARIS_CMM)
	strcpy (iGP->KCPDataDir, "/tmp/");
#elif defined (JAVACMM)
	strcpy(iGP->KCPDataDir, "/tmp/");
#else 
	strcpy (iGP->KCPDataDir, "/var/kodak/cmscp/");
#endif

#if defined(KCP_ACCEL)
	/* load shared library */
	kcp_cte_hnd = dlopen ("libkcme1.so.1", RTLD_NOW);
	if (kcp_cte_hnd != NULL){
		kcp_cte = (int (*)())dlsym (kcp_cte_hnd, "cte_proc_send");
		if (kcp_cte == NULL){
			strcpy (tempBuffer, "PTInitialize: ");
			strcat (tempBuffer, dlerror());
			diagWindow(tempBuffer, (int)kcp_cte_hnd);
			dlclose (kcp_cte_hnd);
			kcp_cte_hnd = NULL;
		}
	}
	else{
		strcpy (tempBuffer, "PTInitialize: "); 
		strcat (tempBuffer, dlerror()); 
		diagWindow(tempBuffer, (int)kcp_cte_hnd);
	}
#endif  /* end of KCP_ACCEL */

#if defined (KPSGI) || defined(KPSGIALL)
	nProcessors = sysconf(_SC_NPROC_ONLN);	/* get # of processors */
#elif defined (KPSUN)
	nProcessors = sysconf(_SC_NPROCESSORS_ONLN);	/* get # of processors */
#endif
#if defined (JAVACMM)
	if (thr_main() == -1) {
		nProcessors = 1;		/* no Java threading, can't use extra processors */
	}
#endif
	iGP->numProcessorsAvailable = iGP->numProcessors = nProcessors;
}
Exemple #15
0
struct rpc_createerr *
__rpc_createerr()
{
	static pthread_key_t rce_key = PTHREAD_ONCE_KEY_NP;
	struct rpc_createerr *rce_addr;

	if (thr_main())
		return (&rpc_createerr);
	rce_addr = thr_get_storage(&rce_key, sizeof (*rce_addr), free);
	if (rce_addr == NULL) {
		syslog(LOG_ERR, "__rpc_createerr : out of memory.");
		return (&rpc_createerr);
	}
	return (rce_addr);
}
Exemple #16
0
/*
 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
 */
enum clnt_stat
clnt_broadcast(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs,
	caddr_t argsp, xdrproc_t xresults,
	caddr_t resultsp, resultproc_t eachresult)
{
	if (thr_main()) {
		clnt_broadcast_result_main = eachresult;
	} else {
		(void) pthread_key_create_once_np(&clnt_broadcast_key, NULL);
		(void) pthread_setspecific(clnt_broadcast_key,
							(void *)eachresult);
	}
	return (rpc_broadcast(prog, vers, proc, xargs, argsp, xresults,
				resultsp, (resultproc_t)rpc_wrap_bcast, "udp"));
}
Exemple #17
0
struct rpc_err *
__rpc_callerr(void)
{
	static pthread_key_t rpc_callerr_key = PTHREAD_ONCE_KEY_NP;
	struct rpc_err *tsd;

	if (thr_main())
		return (&rpc_callerr);
	tsd = thr_get_storage(&rpc_callerr_key, sizeof (struct rpc_err), free);
	if (tsd == NULL) {
		syslog(LOG_ERR, "__rpc_callerr : out of memory.");
		return (&rpc_callerr);
	}
	return (tsd);
}
/* ARGSUSED */
static bool_t
rpc_wrap_bcast(char *resultp, struct netbuf *addr, struct netconfig *nconf)
/*
 *	char *resultp;		// results of the call
 *	struct netbuf *addr;	// address of the guy who responded
 *	struct netconfig *nconf; // Netconf of the transport
 */
{
	resultproc_t clnt_broadcast_result;

	if (strcmp(nconf->nc_netid, "udp"))
		return (FALSE);
	if (thr_main())
		clnt_broadcast_result = clnt_broadcast_result_main;
	else
		clnt_broadcast_result = (resultproc_t)thr_getspecific(clnt_broadcast_key);
	return (*clnt_broadcast_result)(resultp,
				(struct sockaddr_in *)addr->buf);
}
Exemple #19
0
struct servdata *
__servdata_init(void)
{
	struct servdata *sd;

	if (thr_main() != 0)
		return (&servdata);
	if (thr_once(&servdata_init_once, servdata_keycreate) != 0 ||
	    !servdata_thr_keycreated)
		return (NULL);
	if ((sd = thr_getspecific(servdata_key)) != NULL)
		return (sd);
	if ((sd = calloc(1, sizeof(*sd))) == NULL)
		return (NULL);
	if (thr_setspecific(servdata_key, sd) == 0)
		return (sd);
	free(sd);
	return (NULL);
}
Exemple #20
0
const char *
gai_strerror(int ecode)
{
#if defined(NLS)
	nl_catd catd;
	char *buf;

	if (thr_main() != 0)
		buf = gai_buf;
	else {
		if (thr_once(&gai_init_once, gai_keycreate) != 0 ||
		    !gai_keycreated)
			goto thr_err;
		if ((buf = thr_getspecific(gai_key)) == NULL) {
			if ((buf = malloc(sizeof(gai_buf))) == NULL)
				goto thr_err;
			if (thr_setspecific(gai_key, buf) != 0) {
				free(buf);
				goto thr_err;
			}
		}
	}

	catd = catopen("libc", NL_CAT_LOCALE);
	if (ecode > 0 && ecode < EAI_MAX)
		strlcpy(buf, catgets(catd, 3, ecode, ai_errlist[ecode]),
		    sizeof(gai_buf));
	else if (ecode == 0)
		strlcpy(buf, catgets(catd, 3, NL_MSGMAX - 1, "Success"),
		    sizeof(gai_buf));
	else
		strlcpy(buf, catgets(catd, 3, NL_MSGMAX, "Unknown error"),
		    sizeof(gai_buf));
	catclose(catd);
	return buf;

thr_err:
#endif
	if (ecode >= 0 && ecode < EAI_MAX)
		return ai_errlist[ecode];
	return "Unknown error";
}
struct rpc_createerr *
__rpc_createerr(void)
{
	struct rpc_createerr *rce_addr = 0;

	if (thr_main())
		return (&rpc_createerr);
	if (thr_once(&rce_once, rce_key_init) != 0 || rce_key_error != 0)
		return (&rpc_createerr);
	rce_addr = (struct rpc_createerr *)thr_getspecific(rce_key);
	if (!rce_addr) {
		rce_addr = (struct rpc_createerr *)
			malloc(sizeof (struct rpc_createerr));
		if (thr_setspecific(rce_key, (void *) rce_addr) != 0) {
			free(rce_addr);
			return (&rpc_createerr);
		}
		memset(rce_addr, 0, sizeof (struct rpc_createerr));
		return (rce_addr);
	}
	return (rce_addr);
}
Exemple #22
0
/*
 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
 */
enum clnt_stat
clnt_broadcast(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs,
	caddr_t argsp, xdrproc_t xresults,
	caddr_t resultsp, resultproc_t eachresult)
{
	extern mutex_t tsd_lock;

	if (thr_main()) {
		clnt_broadcast_result_main = eachresult;
	} else {
		if (clnt_broadcast_key == 0) {
			(void) mutex_lock(&tsd_lock);
			if (clnt_broadcast_key == 0)
				(void) pthread_key_create(&clnt_broadcast_key,
									NULL);
			(void) mutex_unlock(&tsd_lock);
		}
		(void) pthread_setspecific(clnt_broadcast_key,
							(void *)eachresult);
	}
	return (rpc_broadcast(prog, vers, proc, xargs, argsp, xresults,
				resultsp, (resultproc_t)rpc_wrap_bcast, "udp"));
}
inline bool os::allocate_stack_guard_pages() {
    assert(uses_stack_guard_pages(), "sanity check");
    return thr_main();
}
Exemple #24
0
/*
 * Keep the handle cached.  This call may be made quite often.
 */
static CLIENT *
getkeyserv_handle(int vers)
{
	void *localhandle;
	struct netconfig *nconf;
	struct netconfig *tpconf;
	struct key_call_private *kcp = key_call_private_main;
	struct timeval wait_time;
	struct utsname u;
	int main_thread;
	int fd;
	static thread_key_t key_call_key;

#define	TOTAL_TIMEOUT	30	/* total timeout talking to keyserver */
#define	TOTAL_TRIES	5	/* Number of tries */

	if ((main_thread = thr_main())) {
		kcp = key_call_private_main;
	} else {
		if (key_call_key == 0) {
			mutex_lock(&tsd_lock);
			if (key_call_key == 0)
				thr_keycreate(&key_call_key, key_call_destroy);
			mutex_unlock(&tsd_lock);
		}
		kcp = (struct key_call_private *)thr_getspecific(key_call_key);
	}
	if (kcp == NULL) {
		kcp = (struct key_call_private *)malloc(sizeof (*kcp));
		if (kcp == NULL) {
			return (NULL);
		}
		if (main_thread)
			key_call_private_main = kcp;
		else
			thr_setspecific(key_call_key, (void *) kcp);
		kcp->client = NULL;
	}

	/* if pid has changed, destroy client and rebuild */
	if (kcp->client != NULL && kcp->pid != getpid()) {
		clnt_destroy(kcp->client);
		kcp->client = NULL;
	}

	if (kcp->client != NULL) {
		/* if uid has changed, build client handle again */
		if (kcp->uid != geteuid()) {
			kcp->uid = geteuid();
			auth_destroy(kcp->client->cl_auth);
			kcp->client->cl_auth =
				authsys_create("", kcp->uid, 0, 0, NULL);
			if (kcp->client->cl_auth == NULL) {
				clnt_destroy(kcp->client);
				kcp->client = NULL;
				return (NULL);
			}
		}
		/* Change the version number to the new one */
		clnt_control(kcp->client, CLSET_VERS, (void *)&vers);
		return (kcp->client);
	}
	if (!(localhandle = setnetconfig())) {
		return (NULL);
	}
	tpconf = NULL;
	if (uname(&u) == -1)
	{
		endnetconfig(localhandle);
		return (NULL);
	}
	while ((nconf = getnetconfig(localhandle)) != NULL) {
		if (strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) {
			/*
			 * We use COTS_ORD here so that the caller can
			 * find out immediately if the server is dead.
			 */
			if (nconf->nc_semantics == NC_TPI_COTS_ORD) {
				kcp->client = clnt_tp_create(u.nodename,
					KEY_PROG, vers, nconf);
				if (kcp->client)
					break;
			} else {
				tpconf = nconf;
			}
		}
	}
	if ((kcp->client == NULL) && (tpconf))
		/* Now, try the CLTS or COTS loopback transport */
		kcp->client = clnt_tp_create(u.nodename,
			KEY_PROG, vers, tpconf);
	endnetconfig(localhandle);

	if (kcp->client == NULL) {
		return (NULL);
	}
	kcp->uid = geteuid();
	kcp->pid = getpid();
	kcp->client->cl_auth = authsys_create("", kcp->uid, 0, 0, NULL);
	if (kcp->client->cl_auth == NULL) {
		clnt_destroy(kcp->client);
		kcp->client = NULL;
		return (NULL);
	}

	wait_time.tv_sec = TOTAL_TIMEOUT/TOTAL_TRIES;
	wait_time.tv_usec = 0;
	clnt_control(kcp->client, CLSET_RETRY_TIMEOUT,
		(char *)&wait_time);
	if (clnt_control(kcp->client, CLGET_FD, (char *)&fd))
		_fcntl(fd, F_SETFD, 1);	/* make it "close on exec" */

	return (kcp->client);
}
Exemple #25
0
inline bool os::allocate_stack_guard_pages() {
  assert(uses_stack_guard_pages(), "sanity check");
  int r = thr_main() ;
  guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
  return r;
}
Exemple #26
0
int main (int argc,char **argv )
{

  int generate = 0;
  if ( argc > 1 ) generate = 1;

  int lx = 4;
  int ly = 4;
  int lz = 4;
  int lt = 4;

  int nrow[4];
  nrow[0] = lx;
  nrow[1] = ly;
  nrow[2] = lz;
  nrow[3] = lt;

  bfmarg dwfa;
  dwfa.solver = WilsonFermion;
  dwfa.threads = 1;

  dwfa.node_latt[0]  = lx;
  dwfa.node_latt[1]  = ly;
  dwfa.node_latt[2]  = lz;
  dwfa.node_latt[3]  = lt;

  dwfa.local_comm[0]  = 0;
  dwfa.local_comm[1]  = 0;
  dwfa.local_comm[2]  = 0;
  dwfa.local_comm[3]  = 0;

  dwfa.Ls = 1;
  dwfa.mass = 0.0;
  dwfa.Csw  = 0.0;

  printf("Initialising bfm operator\n");
  printf("drand48 seed = 0\n");
  srand48(0);

  dwf.init(dwfa);

  psi_h = dwf.allocFermion();
  chi_h = dwf.allocFermion();
  check = dwf.allocFermion();
  diff  = dwf.allocFermion();
  
  dwf.randFermion(psi_h);
#ifdef GENERATE
  dwf.dump(psi_h,"src.C","src");
#endif

  //  dwf.importFermion(src,psi_h,0);
  
  dwf.unitGauge();

  printf("cb0dag0 is %lx\n",(unsigned long)cb0dag0);
  printf("cb0dag1 is %lx\n",(unsigned long)cb0dag1);
  printf("cb1dag0 is %lx\n",(unsigned long)cb1dag0);
  printf("cb1dag1 is %lx\n",(unsigned long)cb1dag1);
  // Naive Dslash

  // cb is cb of result, 1-cb is cb of input field

  int idx=0;
  for(cb=0;cb<2;cb++){
    
    /*Import this checkerboard of QDP fields to bagel*/

    // Fill the other checkerboard.
    for(dag=0;dag<2;dag++){

      
      printf("Checking cb=%d dag=%d %lx \n",cb,dag,
	     (unsigned long)arrays[idx]);

      dwf.importFermion(arrays[idx],check,0);

      thr_main(NULL);

#ifdef GENERATE
      dwf.dump(chi_h,files[idx],array_names[idx]);
#else
      printf("Norm of difference is %le\n",delta);
      //printf("Norm result %le\n",n2);
      //printf("Norm check  %le\n",n1);
#endif
      idx++;
    }
  }
  printf("Done\n"); 
}
/*
 * This is the simplified interface to the client rpc layer.
 * The client handle is not destroyed here and is reused for
 * the future calls to same prog, vers, host and nettype combination.
 *
 * The total time available is 25 seconds.
 */
enum clnt_stat
rpc_call(const char *host,			/* host name */
	rpcprog_t prognum,			/* program number */
	rpcvers_t versnum,			/* version number */
	rpcproc_t procnum,			/* procedure number */
	xdrproc_t inproc,
	const char *in,
	xdrproc_t outproc,			/* in/out XDR procedures */
	char  *out,				/* recv/send data */
	const char *nettype)			/* nettype */
{
	struct rpc_call_private *rcp = NULL;
	enum clnt_stat clnt_stat;
	struct timeval timeout, tottimeout;
	static thread_key_t rpc_call_key;
	int main_thread = 1;

	if ((main_thread = thr_main())) {
		rcp = rpc_call_private_main;
	} else {
		if (rpc_call_key == 0) {
			mutex_lock(&tsd_lock);
			if (rpc_call_key == 0)
				thr_keycreate(&rpc_call_key, rpc_call_destroy);
			mutex_unlock(&tsd_lock);
		}
		rcp = (struct rpc_call_private *)thr_getspecific(rpc_call_key);
	}
	if (rcp == NULL) {
		rcp = malloc(sizeof (*rcp));
		if (rcp == NULL) {
			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
			rpc_createerr.cf_error.re_errno = errno;
			return (rpc_createerr.cf_stat);
		}
		if (main_thread)
			rpc_call_private_main = rcp;
		else
			thr_setspecific(rpc_call_key, (void *) rcp);
		rcp->valid = 0;
		rcp->client = NULL;
	}
	if ((nettype == NULL) || (nettype[0] == 0))
		nettype = "netpath";
	if (!(rcp->valid && rcp->pid == getpid() &&
		(rcp->prognum == prognum) &&
		(rcp->versnum == versnum) &&
		(!strcmp(rcp->host, host)) &&
		(!strcmp(rcp->nettype, nettype)))) {
		int fd;

		rcp->valid = 0;
		if (rcp->client)
			CLNT_DESTROY(rcp->client);
		/*
		 * Using the first successful transport for that type
		 */
		rcp->client = clnt_create(host, prognum, versnum, nettype);
		rcp->pid = getpid();
		if (rcp->client == NULL) {
			return (rpc_createerr.cf_stat);
		}
		/*
		 * Set time outs for connectionless case.  Do it
		 * unconditionally.  Faster than doing a t_getinfo()
		 * and then doing the right thing.
		 */
		timeout.tv_usec = 0;
		timeout.tv_sec = 5;
		CLNT_CONTROL(rcp->client,
				CLSET_RETRY_TIMEOUT, (char *)(void *)&timeout);
		if (CLNT_CONTROL(rcp->client, CLGET_FD, (char *)(void *)&fd))
			_fcntl(fd, F_SETFD, 1);	/* make it "close on exec" */
		rcp->prognum = prognum;
		rcp->versnum = versnum;
		if ((strlen(host) < (size_t)MAXHOSTNAMELEN) &&
		    (strlen(nettype) < (size_t)NETIDLEN)) {
			strcpy(rcp->host, host);
			strcpy(rcp->nettype, nettype);
			rcp->valid = 1;
		} else {
			rcp->valid = 0;
		}
	} /* else reuse old client */
	tottimeout.tv_sec = 25;
	tottimeout.tv_usec = 0;
	/*LINTED const castaway*/
	clnt_stat = CLNT_CALL(rcp->client, procnum, inproc, (char *) in,
	    outproc, out, tottimeout);
	/*
	 * if call failed, empty cache
	 */
	if (clnt_stat != RPC_SUCCESS)
		rcp->valid = 0;
	return (clnt_stat);
}