1 /* $NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $ */
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user.
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement.
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF.
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages.
27 * Sun Microsystems, Inc.
29 * Mountain View, California 94043
32 * Copyright (c) 1986-1991 by Sun Microsystems Inc.
35 /* #ident "@(#)clnt_dg.c 1.23 94/04/22 SMI" */
37 #include <sys/cdefs.h>
38 #if defined(LIBC_SCCS) && !defined(lint)
40 static char sccsid
[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro";
42 __RCSID("$NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $");
47 * Implements a connectionless client side RPC.
50 #include "namespace.h"
51 #include "reentrant.h"
53 #include <sys/types.h>
55 #include <sys/socket.h>
56 #include <sys/ioctl.h>
65 #include "rpc_internal.h"
68 __weak_alias(clnt_dg_create
,_clnt_dg_create
)
71 #define RPC_MAX_BACKOFF 30 /* seconds */
74 static struct clnt_ops
*clnt_dg_ops
__P((void));
75 static bool_t time_not_ok
__P((struct timeval
*));
76 static enum clnt_stat clnt_dg_call
__P((CLIENT
*, rpcproc_t
, xdrproc_t
,
77 const char *, xdrproc_t
, caddr_t
, struct timeval
));
78 static void clnt_dg_geterr
__P((CLIENT
*, struct rpc_err
*));
79 static bool_t clnt_dg_freeres
__P((CLIENT
*, xdrproc_t
, caddr_t
));
80 static void clnt_dg_abort
__P((CLIENT
*));
81 static bool_t clnt_dg_control
__P((CLIENT
*, u_int
, char *));
82 static void clnt_dg_destroy
__P((CLIENT
*));
88 * This machinery implements per-fd locks for MT-safety. It is not
89 * sufficient to do per-CLIENT handle locks for MT-safety because a
90 * user may create more than one CLIENT handle with the same fd behind
91 * it. Therfore, we allocate an array of flags (dg_fd_locks), protected
92 * by the clnt_fd_lock mutex, and an array (dg_cv) of condition variables
93 * similarly protected. Dg_fd_lock[fd] == 1 => a call is activte on some
94 * CLIENT handle created for that fd.
95 * The current implementation holds locks across the entire RPC and reply,
96 * including retransmissions. Yes, this is silly, and as soon as this
97 * code is proven to work, this should be the first thing fixed. One step
100 static int *dg_fd_locks
;
102 #define __rpc_lock_value __isthreaded;
103 extern mutex_t clnt_fd_lock
;
104 static cond_t
*dg_cv
;
105 #define release_fd_lock(fd, mask) { \
106 mutex_lock(&clnt_fd_lock); \
107 dg_fd_locks[fd] = 0; \
108 mutex_unlock(&clnt_fd_lock); \
109 thr_sigsetmask(SIG_SETMASK, &(mask), NULL); \
110 cond_signal(&dg_cv[fd]); \
113 #define release_fd_lock(fd,mask)
114 #define __rpc_lock_value 0
117 static const char mem_err_clnt_dg
[] = "clnt_dg_create: out of memory";
119 /* VARIABLES PROTECTED BY clnt_fd_lock: dg_fd_locks, dg_cv */
122 * Private data kept per client handle
125 int cu_fd
; /* connections fd */
126 bool_t cu_closeit
; /* opened by library */
127 struct sockaddr_storage cu_raddr
; /* remote address */
129 struct timeval cu_wait
; /* retransmit interval */
130 struct timeval cu_total
; /* total time for the call */
131 struct rpc_err cu_error
;
134 u_int cu_sendsz
; /* send size */
136 u_int cu_recvsz
; /* recv size */
137 struct pollfd cu_pfdp
;
142 * Connection less client creation returns with client handle parameters.
143 * Default options are set, which the user can change using clnt_control().
144 * fd should be open and bound.
145 * NB: The rpch->cl_auth is initialized to null authentication.
146 * Caller may wish to set this something more useful.
148 * sendsz and recvsz are the maximum allowable packet sizes that can be
149 * sent and received. Normally they are the same, but they can be
150 * changed to improve the program efficiency and buffer allocation.
151 * If they are 0, use the transport default.
153 * If svcaddr is NULL, returns NULL.
156 clnt_dg_create(fd
, svcaddr
, program
, version
, sendsz
, recvsz
)
157 int fd
; /* open file descriptor */
158 const struct netbuf
*svcaddr
; /* servers address */
159 rpcprog_t program
; /* program number */
160 rpcvers_t version
; /* version number */
161 u_int sendsz
; /* buffer recv size */
162 u_int recvsz
; /* buffer send size */
164 CLIENT
*cl
= NULL
; /* client handle */
165 struct cu_data
*cu
= NULL
; /* private data */
166 struct rpc_msg call_msg
;
171 struct __rpc_sockinfo si
;
174 sigfillset(&newmask
);
175 thr_sigsetmask(SIG_SETMASK
, &newmask
, &mask
);
176 mutex_lock(&clnt_fd_lock
);
177 if (dg_fd_locks
== NULL
) {
182 int dtbsize
= __rpc_dtbsize();
184 fd_allocsz
= dtbsize
* sizeof (int);
185 dg_fd_locks
= mem_alloc(fd_allocsz
);
186 if (dg_fd_locks
== NULL
) {
187 mutex_unlock(&clnt_fd_lock
);
188 thr_sigsetmask(SIG_SETMASK
, &(mask
), NULL
);
191 memset(dg_fd_locks
, '\0', fd_allocsz
);
194 cv_allocsz
= dtbsize
* sizeof (cond_t
);
195 dg_cv
= mem_alloc(cv_allocsz
);
197 mem_free(dg_fd_locks
, fd_allocsz
);
199 mutex_unlock(&clnt_fd_lock
);
200 thr_sigsetmask(SIG_SETMASK
, &(mask
), NULL
);
205 for (i
= 0; i
< dtbsize
; i
++)
206 cond_init(&dg_cv
[i
], 0, (void *) 0);
211 mutex_unlock(&clnt_fd_lock
);
212 thr_sigsetmask(SIG_SETMASK
, &(mask
), NULL
);
214 if (svcaddr
== NULL
) {
215 rpc_createerr
.cf_stat
= RPC_UNKNOWNADDR
;
219 if (!__rpc_fd2sockinfo(fd
, &si
)) {
220 rpc_createerr
.cf_stat
= RPC_TLIERROR
;
221 rpc_createerr
.cf_error
.re_errno
= 0;
225 * Find the receive and the send size
227 sendsz
= __rpc_get_t_size(si
.si_af
, si
.si_proto
, (int)sendsz
);
228 recvsz
= __rpc_get_t_size(si
.si_af
, si
.si_proto
, (int)recvsz
);
229 if ((sendsz
== 0) || (recvsz
== 0)) {
230 rpc_createerr
.cf_stat
= RPC_TLIERROR
; /* XXX */
231 rpc_createerr
.cf_error
.re_errno
= 0;
235 if ((cl
= mem_alloc(sizeof (CLIENT
))) == NULL
)
238 * Should be multiple of 4 for XDR.
240 sendsz
= ((sendsz
+ 3) / 4) * 4;
241 recvsz
= ((recvsz
+ 3) / 4) * 4;
242 cu
= malloc(sizeof (*cu
) + sendsz
+ recvsz
);
245 memset(cu
, 0, sizeof(*cu
));
246 (void) memcpy(&cu
->cu_raddr
, svcaddr
->buf
, (size_t)svcaddr
->len
);
247 cu
->cu_rlen
= svcaddr
->len
;
248 cu
->cu_outbuf
= &cu
->cu_inbuf
[recvsz
];
249 /* Other values can also be set through clnt_control() */
250 cu
->cu_wait
.tv_sec
= 15; /* heuristically chosen */
251 cu
->cu_wait
.tv_usec
= 0;
252 cu
->cu_total
.tv_sec
= -1;
253 cu
->cu_total
.tv_usec
= -1;
254 cu
->cu_sendsz
= sendsz
;
255 cu
->cu_recvsz
= recvsz
;
256 call_msg
.rm_xid
= __RPC_GETXID();
257 call_msg
.rm_call
.cb_prog
= program
;
258 call_msg
.rm_call
.cb_vers
= version
;
259 xdrmem_create(&(cu
->cu_outxdrs
), cu
->cu_outbuf
, sendsz
, XDR_ENCODE
);
260 if (! xdr_callhdr(&(cu
->cu_outxdrs
), &call_msg
)) {
261 rpc_createerr
.cf_stat
= RPC_CANTENCODEARGS
; /* XXX */
262 rpc_createerr
.cf_error
.re_errno
= 0;
265 cu
->cu_xdrpos
= XDR_GETPOS(&(cu
->cu_outxdrs
));
267 /* XXX fvdl - do we still want this? */
269 (void)bindresvport_sa(fd
, (struct sockaddr
*)svcaddr
->buf
);
271 ioctl(fd
, FIONBIO
, (char *)(void *)&one
);
274 * By default, closeit is always FALSE. It is users responsibility
275 * to do a close on it, else the user may use clnt_control
276 * to let clnt_destroy do it for him/her.
278 cu
->cu_closeit
= FALSE
;
280 cu
->cu_pfdp
.fd
= cu
->cu_fd
;
281 cu
->cu_pfdp
.events
= POLLIN
| POLLPRI
| POLLRDNORM
| POLLRDBAND
;
282 cl
->cl_ops
= clnt_dg_ops();
283 cl
->cl_private
= (caddr_t
)(void *)cu
;
284 cl
->cl_auth
= authnone_create();
289 warnx(mem_err_clnt_dg
);
290 rpc_createerr
.cf_stat
= RPC_SYSTEMERROR
;
291 rpc_createerr
.cf_error
.re_errno
= errno
;
294 mem_free(cl
, sizeof (CLIENT
));
296 mem_free(cu
, sizeof (*cu
) + sendsz
+ recvsz
);
301 static enum clnt_stat
302 clnt_dg_call(cl
, proc
, xargs
, argsp
, xresults
, resultsp
, utimeout
)
303 CLIENT
*cl
; /* client handle */
304 rpcproc_t proc
; /* procedure number */
305 xdrproc_t xargs
; /* xdr routine for args */
306 const char * argsp
; /* pointer to args */
307 xdrproc_t xresults
; /* xdr routine for results */
308 caddr_t resultsp
; /* pointer to results */
309 struct timeval utimeout
; /* seconds to wait before giving up */
314 struct rpc_msg reply_msg
;
317 int nrefreshes
= 2; /* number of times to refresh cred */
318 struct timeval timeout
;
319 struct timeval retransmit_time
;
320 struct timeval next_sendtime
, starttime
, time_waited
, tv
;
322 sigset_t mask
, *maskp
= &mask
;
324 sigset_t
*maskp
= NULL
;
331 _DIAGASSERT(cl
!= NULL
);
333 cu
= (struct cu_data
*)cl
->cl_private
;
335 sigfillset(&newmask
);
336 thr_sigsetmask(SIG_SETMASK
, &newmask
, &mask
);
337 mutex_lock(&clnt_fd_lock
);
338 while (dg_fd_locks
[cu
->cu_fd
])
339 cond_wait(&dg_cv
[cu
->cu_fd
], &clnt_fd_lock
);
340 dg_fd_locks
[cu
->cu_fd
] = __rpc_lock_value
;
341 mutex_unlock(&clnt_fd_lock
);
342 if (cu
->cu_total
.tv_usec
== -1) {
343 timeout
= utimeout
; /* use supplied timeout */
345 timeout
= cu
->cu_total
; /* use default timeout */
348 time_waited
.tv_sec
= 0;
349 time_waited
.tv_usec
= 0;
350 retransmit_time
= next_sendtime
= cu
->cu_wait
;
351 gettimeofday(&starttime
, NULL
);
354 xdrs
= &(cu
->cu_outxdrs
);
355 xdrs
->x_op
= XDR_ENCODE
;
356 XDR_SETPOS(xdrs
, cu
->cu_xdrpos
);
358 * the transaction is the first thing in the out buffer
360 (*(u_int32_t
*)(void *)(cu
->cu_outbuf
))++;
361 if ((! XDR_PUTINT32(xdrs
, (int32_t *)&proc
)) ||
362 (! AUTH_MARSHALL(cl
->cl_auth
, xdrs
)) ||
363 (! (*xargs
)(xdrs
, __UNCONST(argsp
)))) {
364 cu
->cu_error
.re_status
= RPC_CANTENCODEARGS
;
367 outlen
= (size_t)XDR_GETPOS(xdrs
);
370 if ((size_t)sendto(cu
->cu_fd
, cu
->cu_outbuf
, outlen
, 0,
371 (struct sockaddr
*)(void *)&cu
->cu_raddr
, (socklen_t
)cu
->cu_rlen
)
373 cu
->cu_error
.re_errno
= errno
;
374 cu
->cu_error
.re_status
= RPC_CANTSEND
;
379 * Hack to provide rpc-based message passing
381 if (timeout
.tv_sec
== 0 && timeout
.tv_usec
== 0) {
382 cu
->cu_error
.re_status
= RPC_TIMEDOUT
;
386 * sub-optimal code appears here because we have
387 * some clock time to spare while the packets are in flight.
388 * (We assume that this is actually only executed once.)
390 reply_msg
.acpted_rply
.ar_verf
= _null_auth
;
391 reply_msg
.acpted_rply
.ar_results
.where
= resultsp
;
392 reply_msg
.acpted_rply
.ar_results
.proc
= xresults
;
396 /* Decide how long to wait. */
397 if (timercmp(&next_sendtime
, &timeout
, <))
398 timersub(&next_sendtime
, &time_waited
, &tv
);
400 timersub(&timeout
, &time_waited
, &tv
);
401 if (tv
.tv_sec
< 0 || tv
.tv_usec
< 0)
402 tv
.tv_sec
= tv
.tv_usec
= 0;
403 TIMEVAL_TO_TIMESPEC(&tv
, &ts
);
405 n
= pollts(&cu
->cu_pfdp
, 1, &ts
, maskp
);
407 /* We have some data now */
409 recvlen
= recvfrom(cu
->cu_fd
, cu
->cu_inbuf
,
410 cu
->cu_recvsz
, 0, NULL
, NULL
);
411 } while (recvlen
< 0 && errno
== EINTR
);
413 if (recvlen
< 0 && errno
!= EWOULDBLOCK
) {
414 cu
->cu_error
.re_errno
= errno
;
415 cu
->cu_error
.re_status
= RPC_CANTRECV
;
418 if (recvlen
>= (ssize_t
)sizeof(uint32_t) &&
419 (*((uint32_t *)(void *)(cu
->cu_inbuf
)) ==
420 *((uint32_t *)(void *)(cu
->cu_outbuf
)))) {
421 /* We now assume we have the proper reply. */
426 cu
->cu_error
.re_errno
= errno
;
427 cu
->cu_error
.re_status
= RPC_CANTRECV
;
431 gettimeofday(&tv
, NULL
);
432 timersub(&tv
, &starttime
, &time_waited
);
434 /* Check for timeout. */
435 if (timercmp(&time_waited
, &timeout
, >)) {
436 cu
->cu_error
.re_status
= RPC_TIMEDOUT
;
440 /* Retransmit if necessary. */
441 if (timercmp(&time_waited
, &next_sendtime
, >)) {
442 /* update retransmit_time */
443 if (retransmit_time
.tv_sec
< RPC_MAX_BACKOFF
)
444 timeradd(&retransmit_time
, &retransmit_time
,
446 timeradd(&next_sendtime
, &retransmit_time
,
453 * now decode and validate the response
456 xdrmem_create(&reply_xdrs
, cu
->cu_inbuf
, (u_int
)recvlen
, XDR_DECODE
);
457 ok
= xdr_replymsg(&reply_xdrs
, &reply_msg
);
458 /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
460 if ((reply_msg
.rm_reply
.rp_stat
== MSG_ACCEPTED
) &&
461 (reply_msg
.acpted_rply
.ar_stat
== SUCCESS
))
462 cu
->cu_error
.re_status
= RPC_SUCCESS
;
464 _seterr_reply(&reply_msg
, &(cu
->cu_error
));
466 if (cu
->cu_error
.re_status
== RPC_SUCCESS
) {
467 if (! AUTH_VALIDATE(cl
->cl_auth
,
468 &reply_msg
.acpted_rply
.ar_verf
)) {
469 cu
->cu_error
.re_status
= RPC_AUTHERROR
;
470 cu
->cu_error
.re_why
= AUTH_INVALIDRESP
;
472 if (reply_msg
.acpted_rply
.ar_verf
.oa_base
!= NULL
) {
473 xdrs
->x_op
= XDR_FREE
;
474 (void) xdr_opaque_auth(xdrs
,
475 &(reply_msg
.acpted_rply
.ar_verf
));
477 } /* end successful completion */
479 * If unsuccesful AND error is an authentication error
480 * then refresh credentials and try again, else break
482 else if (cu
->cu_error
.re_status
== RPC_AUTHERROR
)
483 /* maybe our credentials need to be refreshed ... */
484 if (nrefreshes
> 0 && AUTH_REFRESH(cl
->cl_auth
)) {
488 /* end of unsuccessful completion */
489 } /* end of valid reply message */
491 cu
->cu_error
.re_status
= RPC_CANTDECODERES
;
495 release_fd_lock(cu
->cu_fd
, mask
);
496 return (cu
->cu_error
.re_status
);
500 clnt_dg_geterr(cl
, errp
)
502 struct rpc_err
*errp
;
506 _DIAGASSERT(cl
!= NULL
);
507 _DIAGASSERT(errp
!= NULL
);
509 cu
= (struct cu_data
*)cl
->cl_private
;
510 *errp
= cu
->cu_error
;
514 clnt_dg_freeres(cl
, xdr_res
, res_ptr
)
527 _DIAGASSERT(cl
!= NULL
);
528 cu
= (struct cu_data
*)cl
->cl_private
;
529 xdrs
= &(cu
->cu_outxdrs
);
531 sigfillset(&newmask
);
532 thr_sigsetmask(SIG_SETMASK
, &newmask
, &mask
);
533 mutex_lock(&clnt_fd_lock
);
534 while (dg_fd_locks
[cu
->cu_fd
])
535 cond_wait(&dg_cv
[cu
->cu_fd
], &clnt_fd_lock
);
536 xdrs
->x_op
= XDR_FREE
;
537 dummy
= (*xdr_res
)(xdrs
, res_ptr
);
538 mutex_unlock(&clnt_fd_lock
);
539 thr_sigsetmask(SIG_SETMASK
, &mask
, NULL
);
540 cond_signal(&dg_cv
[cu
->cu_fd
]);
552 clnt_dg_control(cl
, request
, info
)
564 _DIAGASSERT(cl
!= NULL
);
565 /* info is handled below */
567 cu
= (struct cu_data
*)cl
->cl_private
;
569 sigfillset(&newmask
);
570 thr_sigsetmask(SIG_SETMASK
, &newmask
, &mask
);
571 mutex_lock(&clnt_fd_lock
);
572 while (dg_fd_locks
[cu
->cu_fd
])
573 cond_wait(&dg_cv
[cu
->cu_fd
], &clnt_fd_lock
);
574 dg_fd_locks
[cu
->cu_fd
] = __rpc_lock_value
;
575 mutex_unlock(&clnt_fd_lock
);
578 cu
->cu_closeit
= TRUE
;
579 release_fd_lock(cu
->cu_fd
, mask
);
581 case CLSET_FD_NCLOSE
:
582 cu
->cu_closeit
= FALSE
;
583 release_fd_lock(cu
->cu_fd
, mask
);
587 /* for other requests which use info */
589 release_fd_lock(cu
->cu_fd
, mask
);
594 if (time_not_ok((struct timeval
*)(void *)info
)) {
595 release_fd_lock(cu
->cu_fd
, mask
);
598 cu
->cu_total
= *(struct timeval
*)(void *)info
;
601 *(struct timeval
*)(void *)info
= cu
->cu_total
;
603 case CLGET_SERVER_ADDR
: /* Give him the fd address */
604 /* Now obsolete. Only for backward compatibility */
605 (void) memcpy(info
, &cu
->cu_raddr
, (size_t)cu
->cu_rlen
);
607 case CLSET_RETRY_TIMEOUT
:
608 if (time_not_ok((struct timeval
*)(void *)info
)) {
609 release_fd_lock(cu
->cu_fd
, mask
);
612 cu
->cu_wait
= *(struct timeval
*)(void *)info
;
614 case CLGET_RETRY_TIMEOUT
:
615 *(struct timeval
*)(void *)info
= cu
->cu_wait
;
618 *(int *)(void *)info
= cu
->cu_fd
;
621 addr
= (struct netbuf
*)(void *)info
;
622 addr
->buf
= &cu
->cu_raddr
;
623 addr
->len
= cu
->cu_rlen
;
624 addr
->maxlen
= sizeof cu
->cu_raddr
;
626 case CLSET_SVC_ADDR
: /* set to new address */
627 addr
= (struct netbuf
*)(void *)info
;
628 if (addr
->len
< sizeof cu
->cu_raddr
) {
629 release_fd_lock(cu
->cu_fd
, mask
);
632 (void) memcpy(&cu
->cu_raddr
, addr
->buf
, (size_t)addr
->len
);
633 cu
->cu_rlen
= addr
->len
;
637 * use the knowledge that xid is the
638 * first element in the call structure *.
639 * This will get the xid of the PREVIOUS call
641 *(u_int32_t
*)(void *)info
=
642 ntohl(*(u_int32_t
*)(void *)cu
->cu_outbuf
);
646 /* This will set the xid of the NEXT call */
647 *(u_int32_t
*)(void *)cu
->cu_outbuf
=
648 htonl(*(u_int32_t
*)(void *)info
- 1);
649 /* decrement by 1 as clnt_dg_call() increments once */
654 * This RELIES on the information that, in the call body,
655 * the version number field is the fifth field from the
656 * begining of the RPC header. MUST be changed if the
657 * call_struct is changed
659 *(u_int32_t
*)(void *)info
=
660 ntohl(*(u_int32_t
*)(void *)(cu
->cu_outbuf
+
661 4 * BYTES_PER_XDR_UNIT
));
665 *(u_int32_t
*)(void *)(cu
->cu_outbuf
+ 4 * BYTES_PER_XDR_UNIT
)
666 = htonl(*(u_int32_t
*)(void *)info
);
671 * This RELIES on the information that, in the call body,
672 * the program number field is the fourth field from the
673 * begining of the RPC header. MUST be changed if the
674 * call_struct is changed
676 *(u_int32_t
*)(void *)info
=
677 ntohl(*(u_int32_t
*)(void *)(cu
->cu_outbuf
+
678 3 * BYTES_PER_XDR_UNIT
));
682 *(u_int32_t
*)(void *)(cu
->cu_outbuf
+ 3 * BYTES_PER_XDR_UNIT
)
683 = htonl(*(u_int32_t
*)(void *)info
);
687 release_fd_lock(cu
->cu_fd
, mask
);
690 release_fd_lock(cu
->cu_fd
, mask
);
705 _DIAGASSERT(cl
!= NULL
);
707 cu
= (struct cu_data
*)cl
->cl_private
;
710 sigfillset(&newmask
);
711 thr_sigsetmask(SIG_SETMASK
, &newmask
, &mask
);
712 mutex_lock(&clnt_fd_lock
);
713 while (dg_fd_locks
[cu_fd
])
714 cond_wait(&dg_cv
[cu_fd
], &clnt_fd_lock
);
717 XDR_DESTROY(&(cu
->cu_outxdrs
));
718 mem_free(cu
, (sizeof (*cu
) + cu
->cu_sendsz
+ cu
->cu_recvsz
));
719 if (cl
->cl_netid
&& cl
->cl_netid
[0])
720 mem_free(cl
->cl_netid
, strlen(cl
->cl_netid
) +1);
721 if (cl
->cl_tp
&& cl
->cl_tp
[0])
722 mem_free(cl
->cl_tp
, strlen(cl
->cl_tp
) +1);
723 mem_free(cl
, sizeof (CLIENT
));
724 mutex_unlock(&clnt_fd_lock
);
725 thr_sigsetmask(SIG_SETMASK
, &mask
, NULL
);
726 cond_signal(&dg_cv
[cu_fd
]);
729 static struct clnt_ops
*
732 static struct clnt_ops ops
;
734 extern mutex_t ops_lock
;
739 /* VARIABLES PROTECTED BY ops_lock: ops */
741 sigfillset(&newmask
);
742 thr_sigsetmask(SIG_SETMASK
, &newmask
, &mask
);
743 mutex_lock(&ops_lock
);
744 if (ops
.cl_call
== NULL
) {
745 ops
.cl_call
= clnt_dg_call
;
746 ops
.cl_abort
= clnt_dg_abort
;
747 ops
.cl_geterr
= clnt_dg_geterr
;
748 ops
.cl_freeres
= clnt_dg_freeres
;
749 ops
.cl_destroy
= clnt_dg_destroy
;
750 ops
.cl_control
= clnt_dg_control
;
752 mutex_unlock(&ops_lock
);
753 thr_sigsetmask(SIG_SETMASK
, &mask
, NULL
);
758 * Make sure that the time is not garbage. -1 value is allowed.
765 _DIAGASSERT(t
!= NULL
);
767 return (t
->tv_sec
< -1 || t
->tv_sec
> 100000000 ||
768 t
->tv_usec
< -1 || t
->tv_usec
> 1000000);