clnt_dg.c (74462) | clnt_dg.c (74879) |
---|---|
1/* $NetBSD: clnt_dg.c,v 1.4 2000/07/14 08:40:41 fvdl Exp $ */ | 1/* $NetBSD: clnt_dg.c,v 1.4 2000/07/14 08:40:41 fvdl Exp $ */ |
2/* $FreeBSD: head/lib/libc/rpc/clnt_dg.c 74462 2001-03-19 12:50:13Z alfred $ */ | 2/* $FreeBSD: head/lib/libc/rpc/clnt_dg.c 74879 2001-03-27 21:27:33Z wpaul $ */ |
3 4/* 5 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 6 * unrestricted use provided that this legend is included on all tape 7 * media and as a part of the software program in whole or part. Users 8 * may copy or modify Sun RPC without charge, but are not authorized 9 * to license or distribute it to anyone else except as part of a product or 10 * program developed by the user. --- 110 unchanged lines hidden (view full) --- 121 struct timeval cu_total; /* total time for the call */ 122 struct rpc_err cu_error; 123 XDR cu_outxdrs; 124 u_int cu_xdrpos; 125 u_int cu_sendsz; /* send size */ 126 char *cu_outbuf; 127 u_int cu_recvsz; /* recv size */ 128 struct pollfd pfdp; | 3 4/* 5 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 6 * unrestricted use provided that this legend is included on all tape 7 * media and as a part of the software program in whole or part. Users 8 * may copy or modify Sun RPC without charge, but are not authorized 9 * to license or distribute it to anyone else except as part of a product or 10 * program developed by the user. --- 110 unchanged lines hidden (view full) --- 121 struct timeval cu_total; /* total time for the call */ 122 struct rpc_err cu_error; 123 XDR cu_outxdrs; 124 u_int cu_xdrpos; 125 u_int cu_sendsz; /* send size */ 126 char *cu_outbuf; 127 u_int cu_recvsz; /* recv size */ 128 struct pollfd pfdp; |
129 int cu_async; |
|
129 char cu_inbuf[1]; 130}; 131 132/* 133 * Connection less client creation returns with client handle parameters. 134 * Default options are set, which the user can change using clnt_control(). 135 * fd should be open and bound. 136 * NB: The rpch->cl_auth is initialized to null authentication. --- 96 unchanged lines hidden (view full) --- 233 cu->cu_outbuf = &cu->cu_inbuf[recvsz]; 234 /* Other values can also be set through clnt_control() */ 235 cu->cu_wait.tv_sec = 15; /* heuristically chosen */ 236 cu->cu_wait.tv_usec = 0; 237 cu->cu_total.tv_sec = -1; 238 cu->cu_total.tv_usec = -1; 239 cu->cu_sendsz = sendsz; 240 cu->cu_recvsz = recvsz; | 130 char cu_inbuf[1]; 131}; 132 133/* 134 * Connection less client creation returns with client handle parameters. 135 * Default options are set, which the user can change using clnt_control(). 136 * fd should be open and bound. 137 * NB: The rpch->cl_auth is initialized to null authentication. --- 96 unchanged lines hidden (view full) --- 234 cu->cu_outbuf = &cu->cu_inbuf[recvsz]; 235 /* Other values can also be set through clnt_control() */ 236 cu->cu_wait.tv_sec = 15; /* heuristically chosen */ 237 cu->cu_wait.tv_usec = 0; 238 cu->cu_total.tv_sec = -1; 239 cu->cu_total.tv_usec = -1; 240 cu->cu_sendsz = sendsz; 241 cu->cu_recvsz = recvsz; |
242 cu->cu_async = FALSE; |
|
241 (void) gettimeofday(&now, NULL); 242 call_msg.rm_xid = __RPC_GETXID(&now); 243 call_msg.rm_call.cb_prog = program; 244 call_msg.rm_call.cb_vers = version; 245 xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); 246 if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { 247 rpc_createerr.cf_stat = RPC_CANTENCODEARGS; /* XXX */ 248 rpc_createerr.cf_error.re_errno = 0; --- 58 unchanged lines hidden (view full) --- 307 struct timeval startime, curtime; 308 int firsttimeout = 1; 309 int dtbsize = __rpc_dtbsize(); 310 sigset_t mask; 311 sigset_t newmask; 312 socklen_t fromlen, inlen; 313 ssize_t recvlen = 0; 314 int rpc_lock_value; | 243 (void) gettimeofday(&now, NULL); 244 call_msg.rm_xid = __RPC_GETXID(&now); 245 call_msg.rm_call.cb_prog = program; 246 call_msg.rm_call.cb_vers = version; 247 xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); 248 if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { 249 rpc_createerr.cf_stat = RPC_CANTENCODEARGS; /* XXX */ 250 rpc_createerr.cf_error.re_errno = 0; --- 58 unchanged lines hidden (view full) --- 309 struct timeval startime, curtime; 310 int firsttimeout = 1; 311 int dtbsize = __rpc_dtbsize(); 312 sigset_t mask; 313 sigset_t newmask; 314 socklen_t fromlen, inlen; 315 ssize_t recvlen = 0; 316 int rpc_lock_value; |
317 u_int32_t xid; |
|
315 316 sigfillset(&newmask); 317 thr_sigsetmask(SIG_SETMASK, &newmask, &mask); 318 mutex_lock(&clnt_fd_lock); 319 while (dg_fd_locks[cu->cu_fd]) 320 cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock); 321 if (__isthreaded) 322 rpc_lock_value = 1; --- 8 unchanged lines hidden (view full) --- 331 } 332 333 time_waited.tv_sec = 0; 334 time_waited.tv_usec = 0; 335 retransmit_time = cu->cu_wait; 336 337call_again: 338 xdrs = &(cu->cu_outxdrs); | 318 319 sigfillset(&newmask); 320 thr_sigsetmask(SIG_SETMASK, &newmask, &mask); 321 mutex_lock(&clnt_fd_lock); 322 while (dg_fd_locks[cu->cu_fd]) 323 cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock); 324 if (__isthreaded) 325 rpc_lock_value = 1; --- 8 unchanged lines hidden (view full) --- 334 } 335 336 time_waited.tv_sec = 0; 337 time_waited.tv_usec = 0; 338 retransmit_time = cu->cu_wait; 339 340call_again: 341 xdrs = &(cu->cu_outxdrs); |
342 if (cu->cu_async == TRUE && xargs == NULL) 343 goto get_reply; |
|
339 xdrs->x_op = XDR_ENCODE; 340 XDR_SETPOS(xdrs, cu->cu_xdrpos); 341 /* 342 * the transaction is the first thing in the out buffer | 344 xdrs->x_op = XDR_ENCODE; 345 XDR_SETPOS(xdrs, cu->cu_xdrpos); 346 /* 347 * the transaction is the first thing in the out buffer |
348 * XXX Yes, and it's in network byte order, so we should to 349 * be careful when we increment it, shouldn't we. |
|
343 */ | 350 */ |
344 (*(u_int32_t *)(void *)(cu->cu_outbuf))++; | 351 xid = ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf)); 352 xid++; 353 *(u_int32_t *)(void *)(cu->cu_outbuf) = htonl(xid); 354 |
345 if ((! XDR_PUTINT32(xdrs, &proc)) || 346 (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || 347 (! (*xargs)(xdrs, argsp))) { 348 release_fd_lock(cu->cu_fd, mask); 349 return (cu->cu_error.re_status = RPC_CANTENCODEARGS); 350 } 351 outlen = (size_t)XDR_GETPOS(xdrs); 352 --- 8 unchanged lines hidden (view full) --- 361 362 /* 363 * Hack to provide rpc-based message passing 364 */ 365 if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { 366 release_fd_lock(cu->cu_fd, mask); 367 return (cu->cu_error.re_status = RPC_TIMEDOUT); 368 } | 355 if ((! XDR_PUTINT32(xdrs, &proc)) || 356 (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || 357 (! (*xargs)(xdrs, argsp))) { 358 release_fd_lock(cu->cu_fd, mask); 359 return (cu->cu_error.re_status = RPC_CANTENCODEARGS); 360 } 361 outlen = (size_t)XDR_GETPOS(xdrs); 362 --- 8 unchanged lines hidden (view full) --- 371 372 /* 373 * Hack to provide rpc-based message passing 374 */ 375 if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { 376 release_fd_lock(cu->cu_fd, mask); 377 return (cu->cu_error.re_status = RPC_TIMEDOUT); 378 } |
379 380get_reply: 381 |
|
369 /* 370 * sub-optimal code appears here because we have 371 * some clock time to spare while the packets are in flight. 372 * (We assume that this is actually only executed once.) 373 */ 374 reply_msg.acpted_rply.ar_verf = _null_auth; 375 reply_msg.acpted_rply.ar_results.where = resultsp; 376 reply_msg.acpted_rply.ar_results.proc = xresults; --- 113 unchanged lines hidden (view full) --- 490 continue; 491 cu->cu_error.re_errno = errno; 492 release_fd_lock(cu->cu_fd, mask); 493 return (cu->cu_error.re_status = RPC_CANTRECV); 494 } 495 if (recvlen < sizeof (u_int32_t)) 496 continue; 497 /* see if reply transaction id matches sent id */ | 382 /* 383 * sub-optimal code appears here because we have 384 * some clock time to spare while the packets are in flight. 385 * (We assume that this is actually only executed once.) 386 */ 387 reply_msg.acpted_rply.ar_verf = _null_auth; 388 reply_msg.acpted_rply.ar_results.where = resultsp; 389 reply_msg.acpted_rply.ar_results.proc = xresults; --- 113 unchanged lines hidden (view full) --- 503 continue; 504 cu->cu_error.re_errno = errno; 505 release_fd_lock(cu->cu_fd, mask); 506 return (cu->cu_error.re_status = RPC_CANTRECV); 507 } 508 if (recvlen < sizeof (u_int32_t)) 509 continue; 510 /* see if reply transaction id matches sent id */ |
498 if (*((u_int32_t *)(void *)(cu->cu_inbuf)) != | 511 if (cu->cu_async == FALSE && 512 *((u_int32_t *)(void *)(cu->cu_inbuf)) != |
499 *((u_int32_t *)(void *)(cu->cu_outbuf))) 500 continue; 501 /* we now assume we have the proper reply */ 502 break; 503 } 504 inlen = (socklen_t)recvlen; 505 506 /* --- 210 unchanged lines hidden (view full) --- 717 ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf + 718 3 * BYTES_PER_XDR_UNIT)); 719 break; 720 721 case CLSET_PROG: 722 *(u_int32_t *)(void *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT) 723 = htonl(*(u_int32_t *)(void *)info); 724 break; | 513 *((u_int32_t *)(void *)(cu->cu_outbuf))) 514 continue; 515 /* we now assume we have the proper reply */ 516 break; 517 } 518 inlen = (socklen_t)recvlen; 519 520 /* --- 210 unchanged lines hidden (view full) --- 731 ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf + 732 3 * BYTES_PER_XDR_UNIT)); 733 break; 734 735 case CLSET_PROG: 736 *(u_int32_t *)(void *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT) 737 = htonl(*(u_int32_t *)(void *)info); 738 break; |
725 | 739 case CLSET_ASYNC: 740 cu->cu_async = *(int *)(void *)info; 741 break; |
726 default: 727 release_fd_lock(cu->cu_fd, mask); 728 return (FALSE); 729 } 730 release_fd_lock(cu->cu_fd, mask); 731 return (TRUE); 732} 733 --- 88 unchanged lines hidden --- | 742 default: 743 release_fd_lock(cu->cu_fd, mask); 744 return (FALSE); 745 } 746 release_fd_lock(cu->cu_fd, mask); 747 return (TRUE); 748} 749 --- 88 unchanged lines hidden --- |