1 /* $NetBSD: clnt_vc.c,v 1.4 2000/07/14 08:40:42 fvdl 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 #if defined(LIBC_SCCS) && !defined(lint)
33 static char *sccsid2 = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
34 static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
35 static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
41 * clnt_tcp.c, Implements a TCP/IP based, client side RPC.
43 * Copyright (C) 1984, Sun Microsystems, Inc.
45 * TCP based RPC supports 'batched calls'.
46 * A sequence of calls may be batched-up in a send buffer. The rpc call
47 * return immediately to the client even though the call was not necessarily
48 * sent. The batching occurs if the results' xdr routine is NULL (0) AND
49 * the rpc timeout value is zero (see clnt.h, rpc).
51 * Clients should NOT casually batch calls that in fact return results; that is,
52 * the server side should be aware that a call is batched and not produce any
53 * return message. Batched calls that produce many result messages can
54 * deadlock (netlock) the client and the server....
56 * Now go hang yourself.
59 #include "namespace.h"
60 #include "reentrant.h"
61 #include <sys/types.h>
63 #include <sys/syslog.h>
64 #include <sys/socket.h>
68 #include <arpa/inet.h>
80 #include <rpc/rpcsec_gss.h>
81 #include "un-namespace.h"
85 #define MCALL_MSG_SIZE 24
89 struct cmsgcred cmcred;
92 static enum clnt_stat clnt_vc_call(CLIENT *, rpcproc_t, xdrproc_t, void *,
93 xdrproc_t, void *, struct timeval);
94 static void clnt_vc_geterr(CLIENT *, struct rpc_err *);
95 static bool_t clnt_vc_freeres(CLIENT *, xdrproc_t, void *);
96 static void clnt_vc_abort(CLIENT *);
97 static bool_t clnt_vc_control(CLIENT *, u_int, void *);
98 static void clnt_vc_destroy(CLIENT *);
99 static struct clnt_ops *clnt_vc_ops(void);
100 static bool_t time_not_ok(struct timeval *);
101 static int read_vc(void *, void *, int);
102 static int write_vc(void *, void *, int);
103 static int __msgwrite(int, void *, size_t);
104 static int __msgread(int, void *, size_t);
107 int ct_fd; /* connection's fd */
108 bool_t ct_closeit; /* close it on destroy */
109 struct timeval ct_wait; /* wait interval in milliseconds */
110 bool_t ct_waitset; /* wait set by clnt_control? */
111 struct netbuf ct_addr; /* remote addr */
112 struct rpc_err ct_error;
114 char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */
117 u_int ct_mpos; /* pos after marshal */
118 XDR ct_xdrs; /* XDR stream */
122 * This machinery implements per-fd locks for MT-safety. It is not
123 * sufficient to do per-CLIENT handle locks for MT-safety because a
124 * user may create more than one CLIENT handle with the same fd behind
125 * it. Therfore, we allocate an array of flags (vc_fd_locks), protected
126 * by the clnt_fd_lock mutex, and an array (vc_cv) of condition variables
127 * similarly protected. Vc_fd_lock[fd] == 1 => a call is activte on some
128 * CLIENT handle created for that fd.
129 * The current implementation holds locks across the entire RPC and reply.
130 * Yes, this is silly, and as soon as this code is proven to work, this
131 * should be the first thing fixed. One step at a time.
133 static int *vc_fd_locks;
134 static cond_t *vc_cv;
135 #define release_fd_lock(fd, mask) { \
136 mutex_lock(&clnt_fd_lock); \
137 vc_fd_locks[fd] = 0; \
138 mutex_unlock(&clnt_fd_lock); \
139 thr_sigsetmask(SIG_SETMASK, &(mask), (sigset_t *) NULL); \
140 cond_signal(&vc_cv[fd]); \
143 static const char clnt_vc_errstr[] = "%s : %s";
144 static const char clnt_vc_str[] = "clnt_vc_create";
145 static const char clnt_read_vc_str[] = "read_vc";
146 static const char __no_mem_str[] = "out of memory";
149 * Create a client handle for a connection.
150 * Default options are set, which the user can change using clnt_control()'s.
151 * The rpc/vc package does buffering similar to stdio, so the client
152 * must pick send and receive buffer sizes, 0 => use the default.
153 * NB: fd is copied into a private area.
154 * NB: The rpch->cl_auth is set null authentication. Caller may wish to
155 * set this something more useful.
157 * fd should be an open socket
160 clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
161 int fd; /* open file descriptor */
162 const struct netbuf *raddr; /* servers address */
163 const rpcprog_t prog; /* program number */
164 const rpcvers_t vers; /* version number */
165 u_int sendsz; /* buffer recv size */
166 u_int recvsz; /* buffer send size */
168 CLIENT *cl; /* client handle */
169 struct ct_data *ct = NULL; /* client handle */
171 struct rpc_msg call_msg;
172 static u_int32_t disrupt;
175 struct sockaddr_storage ss;
177 struct __rpc_sockinfo si;
180 disrupt = (u_int32_t)(long)raddr;
182 cl = (CLIENT *)mem_alloc(sizeof (*cl));
183 ct = (struct ct_data *)mem_alloc(sizeof (*ct));
184 if ((cl == (CLIENT *)NULL) || (ct == (struct ct_data *)NULL)) {
185 (void) syslog(LOG_ERR, clnt_vc_errstr,
186 clnt_vc_str, __no_mem_str);
187 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
188 rpc_createerr.cf_error.re_errno = errno;
191 ct->ct_addr.buf = NULL;
192 sigfillset(&newmask);
193 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
194 mutex_lock(&clnt_fd_lock);
195 if (vc_fd_locks == (int *) NULL) {
196 int cv_allocsz, fd_allocsz;
197 int dtbsize = __rpc_dtbsize();
199 fd_allocsz = dtbsize * sizeof (int);
200 vc_fd_locks = (int *) mem_alloc(fd_allocsz);
201 if (vc_fd_locks == (int *) NULL) {
202 mutex_unlock(&clnt_fd_lock);
203 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
206 memset(vc_fd_locks, '\0', fd_allocsz);
208 assert(vc_cv == (cond_t *) NULL);
209 cv_allocsz = dtbsize * sizeof (cond_t);
210 vc_cv = (cond_t *) mem_alloc(cv_allocsz);
211 if (vc_cv == (cond_t *) NULL) {
212 mem_free(vc_fd_locks, fd_allocsz);
213 vc_fd_locks = (int *) NULL;
214 mutex_unlock(&clnt_fd_lock);
215 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
220 for (i = 0; i < dtbsize; i++)
221 cond_init(&vc_cv[i], 0, (void *) 0);
224 assert(vc_cv != (cond_t *) NULL);
227 * XXX - fvdl connecting while holding a mutex?
230 if (_getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) {
231 if (errno != ENOTCONN) {
232 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
233 rpc_createerr.cf_error.re_errno = errno;
234 mutex_unlock(&clnt_fd_lock);
235 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
238 if (_connect(fd, (struct sockaddr *)raddr->buf, raddr->len) < 0){
239 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
240 rpc_createerr.cf_error.re_errno = errno;
241 mutex_unlock(&clnt_fd_lock);
242 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
246 mutex_unlock(&clnt_fd_lock);
247 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
248 if (!__rpc_fd2sockinfo(fd, &si))
251 ct->ct_closeit = FALSE;
254 * Set up private data struct
257 ct->ct_wait.tv_usec = 0;
258 ct->ct_waitset = FALSE;
259 ct->ct_addr.buf = malloc(raddr->maxlen);
260 if (ct->ct_addr.buf == NULL)
262 memcpy(ct->ct_addr.buf, raddr->buf, raddr->len);
263 ct->ct_addr.len = raddr->maxlen;
264 ct->ct_addr.maxlen = raddr->maxlen;
267 * Initialize call message
269 (void)gettimeofday(&now, NULL);
270 call_msg.rm_xid = ((u_int32_t)++disrupt) ^ __RPC_GETXID(&now);
271 call_msg.rm_direction = CALL;
272 call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
273 call_msg.rm_call.cb_prog = (u_int32_t)prog;
274 call_msg.rm_call.cb_vers = (u_int32_t)vers;
277 * pre-serialize the static part of the call msg and stash it away
279 xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcallc, MCALL_MSG_SIZE,
281 if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
282 if (ct->ct_closeit) {
287 ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs));
288 XDR_DESTROY(&(ct->ct_xdrs));
289 assert(ct->ct_mpos + sizeof(uint32_t) <= MCALL_MSG_SIZE);
292 * Create a client handle which uses xdrrec for serialization
293 * and authnone for authentication.
295 cl->cl_ops = clnt_vc_ops();
297 cl->cl_auth = authnone_create();
298 sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz);
299 recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz);
300 xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz,
301 cl->cl_private, read_vc, write_vc);
308 mem_free(ct->ct_addr.buf, ct->ct_addr.len);
309 mem_free(ct, sizeof (struct ct_data));
312 mem_free(cl, sizeof (CLIENT));
314 return ((CLIENT *)NULL);
317 static enum clnt_stat
318 clnt_vc_call(cl, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
323 xdrproc_t xdr_results;
325 struct timeval timeout;
327 struct ct_data *ct = (struct ct_data *) cl->cl_private;
328 XDR *xdrs = &(ct->ct_xdrs);
329 struct rpc_msg reply_msg;
331 u_int32_t *msg_x_id = &ct->ct_u.ct_mcalli; /* yuk */
334 sigset_t mask, newmask;
340 sigfillset(&newmask);
341 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
342 mutex_lock(&clnt_fd_lock);
343 while (vc_fd_locks[ct->ct_fd])
344 cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
349 vc_fd_locks[ct->ct_fd] = rpc_lock_value;
350 mutex_unlock(&clnt_fd_lock);
351 if (!ct->ct_waitset) {
352 /* If time is not within limits, we ignore it. */
353 if (time_not_ok(&timeout) == FALSE)
354 ct->ct_wait = timeout;
358 (xdr_results == NULL && timeout.tv_sec == 0
359 && timeout.tv_usec == 0) ? FALSE : TRUE;
362 xdrs->x_op = XDR_ENCODE;
363 ct->ct_error.re_status = RPC_SUCCESS;
364 x_id = ntohl(--(*msg_x_id));
366 if (cl->cl_auth->ah_cred.oa_flavor != RPCSEC_GSS) {
367 if ((! XDR_PUTBYTES(xdrs, ct->ct_u.ct_mcallc, ct->ct_mpos)) ||
368 (! XDR_PUTINT32(xdrs, &proc)) ||
369 (! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
370 (! (*xdr_args)(xdrs, args_ptr))) {
371 if (ct->ct_error.re_status == RPC_SUCCESS)
372 ct->ct_error.re_status = RPC_CANTENCODEARGS;
373 (void)xdrrec_endofrecord(xdrs, TRUE);
374 release_fd_lock(ct->ct_fd, mask);
375 return (ct->ct_error.re_status);
378 *(uint32_t *) &ct->ct_u.ct_mcallc[ct->ct_mpos] = htonl(proc);
379 if (! __rpc_gss_wrap(cl->cl_auth, ct->ct_u.ct_mcallc,
380 ct->ct_mpos + sizeof(uint32_t),
381 xdrs, xdr_args, args_ptr)) {
382 if (ct->ct_error.re_status == RPC_SUCCESS)
383 ct->ct_error.re_status = RPC_CANTENCODEARGS;
384 (void)xdrrec_endofrecord(xdrs, TRUE);
385 release_fd_lock(ct->ct_fd, mask);
386 return (ct->ct_error.re_status);
389 if (! xdrrec_endofrecord(xdrs, shipnow)) {
390 release_fd_lock(ct->ct_fd, mask);
391 return (ct->ct_error.re_status = RPC_CANTSEND);
394 release_fd_lock(ct->ct_fd, mask);
395 return (RPC_SUCCESS);
398 * Hack to provide rpc-based message passing
400 if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
401 release_fd_lock(ct->ct_fd, mask);
402 return(ct->ct_error.re_status = RPC_TIMEDOUT);
407 * Keep receiving until we get a valid transaction id
409 xdrs->x_op = XDR_DECODE;
411 reply_msg.acpted_rply.ar_verf = _null_auth;
412 reply_msg.acpted_rply.ar_results.where = NULL;
413 reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
414 if (! xdrrec_skiprecord(xdrs)) {
415 release_fd_lock(ct->ct_fd, mask);
416 return (ct->ct_error.re_status);
418 /* now decode and validate the response header */
419 if (! xdr_replymsg(xdrs, &reply_msg)) {
420 if (ct->ct_error.re_status == RPC_SUCCESS)
422 release_fd_lock(ct->ct_fd, mask);
423 return (ct->ct_error.re_status);
425 if (reply_msg.rm_xid == x_id)
432 _seterr_reply(&reply_msg, &(ct->ct_error));
433 if (ct->ct_error.re_status == RPC_SUCCESS) {
434 if (! AUTH_VALIDATE(cl->cl_auth,
435 &reply_msg.acpted_rply.ar_verf)) {
436 ct->ct_error.re_status = RPC_AUTHERROR;
437 ct->ct_error.re_why = AUTH_INVALIDRESP;
439 if (cl->cl_auth->ah_cred.oa_flavor != RPCSEC_GSS) {
440 reply_stat = (*xdr_results)(xdrs, results_ptr);
442 reply_stat = __rpc_gss_unwrap(cl->cl_auth,
443 xdrs, xdr_results, results_ptr);
446 if (ct->ct_error.re_status == RPC_SUCCESS)
447 ct->ct_error.re_status =
451 /* free verifier ... */
452 if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
453 xdrs->x_op = XDR_FREE;
454 (void)xdr_opaque_auth(xdrs,
455 &(reply_msg.acpted_rply.ar_verf));
457 } /* end successful completion */
459 /* maybe our credentials need to be refreshed ... */
460 if (refreshes-- && AUTH_REFRESH(cl->cl_auth, &reply_msg))
462 } /* end of unsuccessful completion */
463 release_fd_lock(ct->ct_fd, mask);
464 return (ct->ct_error.re_status);
468 clnt_vc_geterr(cl, errp)
470 struct rpc_err *errp;
475 assert(errp != NULL);
477 ct = (struct ct_data *) cl->cl_private;
478 *errp = ct->ct_error;
482 clnt_vc_freeres(cl, xdr_res, res_ptr)
495 ct = (struct ct_data *)cl->cl_private;
496 xdrs = &(ct->ct_xdrs);
498 sigfillset(&newmask);
499 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
500 mutex_lock(&clnt_fd_lock);
501 while (vc_fd_locks[ct->ct_fd])
502 cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
503 xdrs->x_op = XDR_FREE;
504 dummy = (*xdr_res)(xdrs, res_ptr);
505 mutex_unlock(&clnt_fd_lock);
506 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
507 cond_signal(&vc_cv[ct->ct_fd]);
520 clnt_vc_control(cl, request, info)
533 ct = (struct ct_data *)cl->cl_private;
535 sigfillset(&newmask);
536 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
537 mutex_lock(&clnt_fd_lock);
538 while (vc_fd_locks[ct->ct_fd])
539 cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
544 vc_fd_locks[ct->ct_fd] = rpc_lock_value;
545 mutex_unlock(&clnt_fd_lock);
549 ct->ct_closeit = TRUE;
550 release_fd_lock(ct->ct_fd, mask);
552 case CLSET_FD_NCLOSE:
553 ct->ct_closeit = FALSE;
554 release_fd_lock(ct->ct_fd, mask);
560 /* for other requests which use info */
562 release_fd_lock(ct->ct_fd, mask);
567 if (time_not_ok((struct timeval *)info)) {
568 release_fd_lock(ct->ct_fd, mask);
571 ct->ct_wait = *(struct timeval *)infop;
572 ct->ct_waitset = TRUE;
575 *(struct timeval *)infop = ct->ct_wait;
577 case CLGET_SERVER_ADDR:
578 (void) memcpy(info, ct->ct_addr.buf, (size_t)ct->ct_addr.len);
581 *(int *)info = ct->ct_fd;
584 /* The caller should not free this memory area */
585 *(struct netbuf *)info = ct->ct_addr;
587 case CLSET_SVC_ADDR: /* set to new address */
588 release_fd_lock(ct->ct_fd, mask);
592 * use the knowledge that xid is the
593 * first element in the call structure
594 * This will get the xid of the PREVIOUS call
597 ntohl(*(u_int32_t *)(void *)&ct->ct_u.ct_mcalli);
600 /* This will set the xid of the NEXT call */
601 *(u_int32_t *)(void *)&ct->ct_u.ct_mcalli =
602 htonl(*((u_int32_t *)info) + 1);
603 /* increment by 1 as clnt_vc_call() decrements once */
607 * This RELIES on the information that, in the call body,
608 * the version number field is the fifth field from the
609 * begining of the RPC header. MUST be changed if the
610 * call_struct is changed
613 ntohl(*(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
614 4 * BYTES_PER_XDR_UNIT));
618 *(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
619 4 * BYTES_PER_XDR_UNIT) =
620 htonl(*(u_int32_t *)info);
625 * This RELIES on the information that, in the call body,
626 * the program number field is the fourth field from the
627 * begining of the RPC header. MUST be changed if the
628 * call_struct is changed
631 ntohl(*(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
632 3 * BYTES_PER_XDR_UNIT));
636 *(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
637 3 * BYTES_PER_XDR_UNIT) =
638 htonl(*(u_int32_t *)info);
642 release_fd_lock(ct->ct_fd, mask);
645 release_fd_lock(ct->ct_fd, mask);
654 struct ct_data *ct = (struct ct_data *) cl->cl_private;
655 int ct_fd = ct->ct_fd;
661 ct = (struct ct_data *) cl->cl_private;
663 sigfillset(&newmask);
664 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
665 mutex_lock(&clnt_fd_lock);
666 while (vc_fd_locks[ct_fd])
667 cond_wait(&vc_cv[ct_fd], &clnt_fd_lock);
668 if (ct->ct_closeit && ct->ct_fd != -1) {
669 (void)_close(ct->ct_fd);
671 XDR_DESTROY(&(ct->ct_xdrs));
673 free(ct->ct_addr.buf);
674 mem_free(ct, sizeof(struct ct_data));
675 mem_free(cl, sizeof(CLIENT));
676 mutex_unlock(&clnt_fd_lock);
677 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
678 cond_signal(&vc_cv[ct_fd]);
682 * Interface between xdr serializer and tcp connection.
683 * Behaves like the system calls, read & write, but keeps some error state
684 * around for the rpc level.
687 read_vc(ctp, buf, len)
694 struct ct_data *ct = (struct ct_data *)ctp;
696 int milliseconds = (int)((ct->ct_wait.tv_sec * 1000) +
697 (ct->ct_wait.tv_usec / 1000));
704 switch (_poll(&fd, 1, milliseconds)) {
706 ct->ct_error.re_status = RPC_TIMEDOUT;
712 ct->ct_error.re_status = RPC_CANTRECV;
713 ct->ct_error.re_errno = errno;
720 if ((_getpeername(ct->ct_fd, &sa, &sal) == 0) &&
721 (sa.sa_family == AF_LOCAL)) {
722 len = __msgread(ct->ct_fd, buf, (size_t)len);
724 len = _read(ct->ct_fd, buf, (size_t)len);
730 ct->ct_error.re_errno = ECONNRESET;
731 ct->ct_error.re_status = RPC_CANTRECV;
732 len = -1; /* it's really an error */
736 ct->ct_error.re_errno = errno;
737 ct->ct_error.re_status = RPC_CANTRECV;
744 write_vc(ctp, buf, len)
751 struct ct_data *ct = (struct ct_data *)ctp;
755 if ((_getpeername(ct->ct_fd, &sa, &sal) == 0) &&
756 (sa.sa_family == AF_LOCAL)) {
757 for (cnt = len; cnt > 0; cnt -= i, buf = (char *)buf + i) {
758 if ((i = __msgwrite(ct->ct_fd, buf,
759 (size_t)cnt)) == -1) {
760 ct->ct_error.re_errno = errno;
761 ct->ct_error.re_status = RPC_CANTSEND;
766 for (cnt = len; cnt > 0; cnt -= i, buf = (char *)buf + i) {
767 if ((i = _write(ct->ct_fd, buf, (size_t)cnt)) == -1) {
768 ct->ct_error.re_errno = errno;
769 ct->ct_error.re_status = RPC_CANTSEND;
777 static struct clnt_ops *
780 static struct clnt_ops ops;
781 sigset_t mask, newmask;
783 /* VARIABLES PROTECTED BY ops_lock: ops */
785 sigfillset(&newmask);
786 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
787 mutex_lock(&ops_lock);
788 if (ops.cl_call == NULL) {
789 ops.cl_call = clnt_vc_call;
790 ops.cl_abort = clnt_vc_abort;
791 ops.cl_geterr = clnt_vc_geterr;
792 ops.cl_freeres = clnt_vc_freeres;
793 ops.cl_destroy = clnt_vc_destroy;
794 ops.cl_control = clnt_vc_control;
796 mutex_unlock(&ops_lock);
797 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
802 * Make sure that the time is not garbage. -1 value is disallowed.
803 * Note this is different from time_not_ok in clnt_dg.c
809 return (t->tv_sec <= -1 || t->tv_sec > 100000000 ||
810 t->tv_usec <= -1 || t->tv_usec > 1000000);
814 __msgread(sock, buf, cnt)
823 char control[CMSG_SPACE(sizeof(struct cmsgcred))];
826 bzero((char *)&cm, sizeof(cm));
827 iov[0].iov_base = buf;
828 iov[0].iov_len = cnt;
834 msg.msg_control = (caddr_t)&cm;
835 msg.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
838 return(_recvmsg(sock, &msg, 0));
842 __msgwrite(sock, buf, cnt)
851 char control[CMSG_SPACE(sizeof(struct cmsgcred))];
854 bzero((char *)&cm, sizeof(cm));
855 iov[0].iov_base = buf;
856 iov[0].iov_len = cnt;
858 cm.cmsg.cmsg_type = SCM_CREDS;
859 cm.cmsg.cmsg_level = SOL_SOCKET;
860 cm.cmsg.cmsg_len = CMSG_LEN(sizeof(struct cmsgcred));
866 msg.msg_control = (caddr_t)&cm;
867 msg.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
870 return(_sendmsg(sock, &msg, 0));