Lines Matching refs:ct

142 	struct ct_data *ct;  member
178 set_blocking_connection(struct ct_data *ct, bool_t blocking) in set_blocking_connection() argument
186 if (ct->ct_is_blocking == blocking) in set_blocking_connection()
189 if ((flag = fcntl(ct->ct_fd, F_GETFL, 0)) < 0) { in set_blocking_connection()
196 if (fcntl(ct->ct_fd, F_SETFL, flag) != 0) { in set_blocking_connection()
201 ct->ct_is_blocking = blocking; in set_blocking_connection()
240 struct ct_data *ct; /* private data */ in _clnt_vc_create_timed() local
247 if ((ct = malloc(sizeof (*ct))) != NULL) in _clnt_vc_create_timed()
248 ct->ct_addr.buf = NULL; in _clnt_vc_create_timed()
250 if ((cl == NULL) || (ct == NULL)) { in _clnt_vc_create_timed()
277 ct->ct_io_mode = RPC_CL_BLOCKING; in _clnt_vc_create_timed()
278 ct->ct_blocking_mode = RPC_CL_BLOCKING_FLUSH; in _clnt_vc_create_timed()
280 ct->ct_buffer = NULL; /* We allocate the buffer when needed. */ in _clnt_vc_create_timed()
281 ct->ct_bufferSize = DEFAULT_PENDING_ZONE_MAX_SIZE; in _clnt_vc_create_timed()
282 ct->ct_bufferPendingSize = 0; in _clnt_vc_create_timed()
283 ct->ct_bufferWritePtr = NULL; in _clnt_vc_create_timed()
284 ct->ct_bufferReadPtr = NULL; in _clnt_vc_create_timed()
295 ct->ct_is_blocking = flag & O_NONBLOCK ? FALSE : TRUE; in _clnt_vc_create_timed()
297 if (set_up_connection(fd, svcaddr, ct, tp) == FALSE) { in _clnt_vc_create_timed()
304 ct->ct_fd = fd; in _clnt_vc_create_timed()
308 ct->ct_wait = 30000; in _clnt_vc_create_timed()
309 ct->ct_waitset = FALSE; in _clnt_vc_create_timed()
315 ct->ct_closeit = FALSE; in _clnt_vc_create_timed()
328 xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, XDR_ENCODE); in _clnt_vc_create_timed()
329 if (!xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { in _clnt_vc_create_timed()
332 ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); in _clnt_vc_create_timed()
333 XDR_DESTROY(&(ct->ct_xdrs)); in _clnt_vc_create_timed()
352 ct->ct_tsdu = tinfo.tsdu; in _clnt_vc_create_timed()
357 ct->ct_xdrs.x_ops = NULL; in _clnt_vc_create_timed()
358 xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, (caddr_t)ct, in _clnt_vc_create_timed()
360 if (ct->ct_xdrs.x_ops == NULL) { in _clnt_vc_create_timed()
367 cl->cl_private = (caddr_t)ct; in _clnt_vc_create_timed()
374 if (ct) { in _clnt_vc_create_timed()
375 free(ct->ct_addr.buf); in _clnt_vc_create_timed()
376 free(ct); in _clnt_vc_create_timed()
458 set_up_connection(int fd, struct netbuf *svcaddr, struct ct_data *ct, in set_up_connection() argument
469 ct->ct_addr.len = 0; in set_up_connection()
605 if (ct->ct_addr.buf) in set_up_connection()
606 free(ct->ct_addr.buf); in set_up_connection()
607 ct->ct_addr = rcvcall->addr; /* To get the new address */ in set_up_connection()
619 ct->ct_addr.len = 0; in set_up_connection()
621 ct->ct_addr.buf = malloc(svcaddr->len); in set_up_connection()
622 if (ct->ct_addr.buf == NULL) { in set_up_connection()
630 (void) memcpy(ct->ct_addr.buf, svcaddr->buf, in set_up_connection()
632 ct->ct_addr.len = ct->ct_addr.maxlen = svcaddr->len; in set_up_connection()
647 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_call() local
648 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_call()
652 uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ in clnt_vc_call()
656 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_call()
659 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
663 ct->ct_is_oneway = FALSE; in clnt_vc_call()
664 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_call()
665 if (do_flush(ct, RPC_CL_BLOCKING_FLUSH) != 0) { in clnt_vc_call()
666 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
671 if (!ct->ct_waitset) { in clnt_vc_call()
674 ct->ct_wait = __rpc_timeval_to_msec(&timeout); in clnt_vc_call()
676 timeout.tv_sec = (ct->ct_wait / 1000); in clnt_vc_call()
677 timeout.tv_usec = (ct->ct_wait % 1000) * 1000; in clnt_vc_call()
693 if ((!XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || in clnt_vc_call()
700 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
705 uint32_t *u = (uint32_t *)&ct->ct_mcall[ct->ct_mpos]; in clnt_vc_call()
707 if (!__rpc_gss_wrap(cl->cl_auth, ct->ct_mcall, in clnt_vc_call()
708 ((char *)u) - ct->ct_mcall, xdrs, xdr_args, args_ptr)) { in clnt_vc_call()
712 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
717 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
721 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
728 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
742 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
749 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
805 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
813 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_send() local
814 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_send()
817 uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ in clnt_vc_send()
819 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_send()
822 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
826 ct->ct_is_oneway = TRUE; in clnt_vc_send()
838 if ((!XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || in clnt_vc_send()
845 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
850 uint32_t *u = (uint32_t *)&ct->ct_mcall[ct->ct_mpos]; in clnt_vc_send()
852 if (!__rpc_gss_wrap(cl->cl_auth, ct->ct_mcall, in clnt_vc_send()
853 ((char *)u) - ct->ct_mcall, xdrs, xdr_args, args_ptr)) { in clnt_vc_send()
857 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
870 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
885 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_freeres() local
886 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_freeres()
889 (void) rpc_fd_lock(vctbl, ct->ct_fd); in clnt_vc_freeres()
892 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_freeres()
907 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_control() local
909 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_control()
910 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
916 ct->ct_closeit = TRUE; in clnt_vc_control()
917 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
920 ct->ct_closeit = FALSE; in clnt_vc_control()
921 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
924 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_control()
926 res = do_flush(ct, (info == NULL || in clnt_vc_control()
930 ct->ct_blocking_mode: *(int *)info); in clnt_vc_control()
935 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
941 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
948 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
952 ct->ct_wait = __rpc_timeval_to_msec((struct timeval *)info); in clnt_vc_control()
953 ct->ct_waitset = TRUE; in clnt_vc_control()
957 ((struct timeval *)info)->tv_sec = ct->ct_wait / 1000; in clnt_vc_control()
959 ((struct timeval *)info)->tv_usec = (ct->ct_wait % 1000) * 1000; in clnt_vc_control()
962 (void) memcpy(info, ct->ct_addr.buf, (size_t)ct->ct_addr.len); in clnt_vc_control()
966 *(int *)info = ct->ct_fd; in clnt_vc_control()
971 *(struct netbuf *)info = ct->ct_addr; in clnt_vc_control()
980 if (t_snddis(ct->ct_fd, NULL) == -1) { in clnt_vc_control()
984 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
987 ret = set_up_connection(ct->ct_fd, (struct netbuf *)info, in clnt_vc_control()
988 ct, NULL); in clnt_vc_control()
989 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
992 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1002 *(uint32_t *)info = ntohl(*(uint32_t *)ct->ct_mcall); in clnt_vc_control()
1007 *(uint32_t *)ct->ct_mcall = htonl(*(uint32_t *)info + 1); in clnt_vc_control()
1018 *(uint32_t *)info = ntohl(*(uint32_t *)(ct->ct_mcall + in clnt_vc_control()
1024 *(uint32_t *)(ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT) = in clnt_vc_control()
1037 *(uint32_t *)info = ntohl(*(uint32_t *)(ct->ct_mcall + in clnt_vc_control()
1043 *(uint32_t *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT) = in clnt_vc_control()
1050 if (!set_io_mode(ct, *(int *)info)) { in clnt_vc_control()
1051 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1058 if (!set_flush_mode(ct, *(int *)info)) { in clnt_vc_control()
1059 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1065 *(rpcflushmode_t *)info = ct->ct_blocking_mode; in clnt_vc_control()
1070 *(rpciomode_t *)info = ct->ct_io_mode; in clnt_vc_control()
1079 *(int *)info = ct->ct_bufferPendingSize; in clnt_vc_control()
1084 if (ct->ct_bufferPendingSize != 0) { in clnt_vc_control()
1085 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1093 if (ct->ct_bufferSize == *(uint_t *)info) in clnt_vc_control()
1097 ct->ct_bufferSize = *(uint_t *)info; in clnt_vc_control()
1098 if (ct->ct_buffer) { in clnt_vc_control()
1099 free(ct->ct_buffer); in clnt_vc_control()
1100 ct->ct_buffer = NULL; in clnt_vc_control()
1101 ct->ct_bufferReadPtr = ct->ct_bufferWritePtr = NULL; in clnt_vc_control()
1111 *(uint_t *)info = ct->ct_bufferSize; in clnt_vc_control()
1115 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1118 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1126 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_destroy() local
1127 int ct_fd = ct->ct_fd; in clnt_vc_destroy()
1131 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_destroy()
1132 (void) do_flush(ct, RPC_CL_BLOCKING_FLUSH); in clnt_vc_destroy()
1133 (void) unregister_nb(ct); in clnt_vc_destroy()
1136 if (ct->ct_closeit) in clnt_vc_destroy()
1138 XDR_DESTROY(&(ct->ct_xdrs)); in clnt_vc_destroy()
1139 if (ct->ct_addr.buf) in clnt_vc_destroy()
1140 free(ct->ct_addr.buf); in clnt_vc_destroy()
1141 free(ct); in clnt_vc_destroy()
1161 struct ct_data *ct = ct_tmp; in read_vc() local
1191 pfdp[0].fd = ct->ct_fd; in read_vc()
1194 poll_time = ct->ct_wait; in read_vc()
1302 switch (len = t_rcvall(ct->ct_fd, buf, len)) { in read_vc()
1324 struct ct_data *ct = ct_tmp; in write_vc() local
1328 maxsz = ct->ct_tsdu; in write_vc()
1331 if (ct->ct_is_oneway && ct->ct_io_mode == RPC_CL_NONBLOCKING) { in write_vc()
1345 len = nb_send(ct, buf, (unsigned)len); in write_vc()
1365 if ((len = t_snd(ct->ct_fd, buf, (unsigned)len, 0)) == -1) { in write_vc()
1378 if ((i = t_snd(ct->ct_fd, buf, (unsigned)MIN(cnt, maxsz), in write_vc()
1463 #define REMAIN_BYTES(p) (ct->ct_bufferSize-(ct->ct_##p - ct->ct_buffer))
1466 addInBuffer(struct ct_data *ct, char *dataToAdd, unsigned int nBytes) in addInBuffer() argument
1468 if (NULL == ct->ct_buffer) { in addInBuffer()
1472 buffer = malloc(ct->ct_bufferSize); in addInBuffer()
1479 ct->ct_buffer = buffer; in addInBuffer()
1480 ct->ct_bufferReadPtr = buffer; in addInBuffer()
1481 ct->ct_bufferWritePtr = buffer + nBytes; in addInBuffer()
1482 ct->ct_bufferPendingSize = nBytes; in addInBuffer()
1493 ct->ct_bufferPendingSize += nBytes; in addInBuffer()
1495 (void) memcpy(ct->ct_bufferWritePtr, dataToAdd, len); in addInBuffer()
1496 ct->ct_bufferWritePtr += len; in addInBuffer()
1505 if (ct->ct_bufferWritePtr == in addInBuffer()
1506 (ct->ct_buffer + ct->ct_bufferSize)) { in addInBuffer()
1507 ct->ct_bufferWritePtr = ct->ct_buffer; in addInBuffer()
1517 (void) memcpy(ct->ct_buffer, dataToAdd, nBytes); in addInBuffer()
1518 ct->ct_bufferWritePtr = ct->ct_buffer + nBytes; in addInBuffer()
1525 consumeFromBuffer(struct ct_data *ct, unsigned int nBytes) in consumeFromBuffer() argument
1527 ct->ct_bufferPendingSize -= nBytes; in consumeFromBuffer()
1528 if (ct->ct_bufferPendingSize == 0) { in consumeFromBuffer()
1533 ct->ct_bufferReadPtr = ct->ct_bufferWritePtr = ct->ct_buffer; in consumeFromBuffer()
1535 ct->ct_bufferReadPtr += nBytes; in consumeFromBuffer()
1536 if (ct->ct_bufferReadPtr > in consumeFromBuffer()
1537 ct->ct_buffer + ct->ct_bufferSize) { in consumeFromBuffer()
1538 ct->ct_bufferReadPtr -= ct->ct_bufferSize; in consumeFromBuffer()
1544 iovFromBuffer(struct ct_data *ct, struct iovec *iov) in iovFromBuffer() argument
1548 if (ct->ct_bufferPendingSize == 0) in iovFromBuffer()
1552 if (l < ct->ct_bufferPendingSize) { in iovFromBuffer()
1554 iov[0].iov_base = ct->ct_bufferReadPtr; in iovFromBuffer()
1557 iov[1].iov_base = ct->ct_buffer; in iovFromBuffer()
1558 iov[1].iov_len = ct->ct_bufferPendingSize - l; in iovFromBuffer()
1562 iov[0].iov_base = ct->ct_bufferReadPtr; in iovFromBuffer()
1563 iov[0].iov_len = ct->ct_bufferPendingSize; in iovFromBuffer()
1569 set_flush_mode(struct ct_data *ct, int mode) in set_flush_mode() argument
1578 ct->ct_blocking_mode = mode; in set_flush_mode()
1586 set_io_mode(struct ct_data *ct, int ioMode) in set_io_mode() argument
1590 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in set_io_mode()
1591 if (NULL != ct->ct_buffer) { in set_io_mode()
1596 (void) do_flush(ct, RPC_CL_BLOCKING_FLUSH); in set_io_mode()
1597 free(ct->ct_buffer); in set_io_mode()
1598 ct->ct_buffer = NULL; in set_io_mode()
1600 (void) unregister_nb(ct); in set_io_mode()
1601 ct->ct_io_mode = ioMode; in set_io_mode()
1605 if (ct->ct_io_mode == RPC_CL_BLOCKING) { in set_io_mode()
1606 if (-1 == register_nb(ct)) { in set_io_mode()
1609 ct->ct_io_mode = ioMode; in set_io_mode()
1619 do_flush(struct ct_data *ct, uint_t flush_mode) in do_flush() argument
1622 if (ct->ct_bufferPendingSize == 0) { in do_flush()
1628 if (!set_blocking_connection(ct, TRUE)) { in do_flush()
1631 while (ct->ct_bufferPendingSize > 0) { in do_flush()
1633 ct->ct_bufferPendingSize) { in do_flush()
1635 (void) iovFromBuffer(ct, iov); in do_flush()
1636 result = writev(ct->ct_fd, iov, 2); in do_flush()
1638 result = t_snd(ct->ct_fd, ct->ct_bufferReadPtr, in do_flush()
1639 ct->ct_bufferPendingSize, 0); in do_flush()
1644 consumeFromBuffer(ct, result); in do_flush()
1650 (void) set_blocking_connection(ct, FALSE); in do_flush()
1651 if (REMAIN_BYTES(bufferReadPtr) < ct->ct_bufferPendingSize) { in do_flush()
1653 (void) iovFromBuffer(ct, iov); in do_flush()
1654 result = writev(ct->ct_fd, iov, 2); in do_flush()
1656 result = t_snd(ct->ct_fd, ct->ct_bufferReadPtr, in do_flush()
1657 ct->ct_bufferPendingSize, 0); in do_flush()
1667 consumeFromBuffer(ct, result); in do_flush()
1678 nb_send(struct ct_data *ct, void *buff, unsigned int nBytes) in nb_send() argument
1691 if (nBytes > (ct->ct_bufferSize - ct->ct_bufferPendingSize)) { in nb_send()
1693 (void) do_flush(ct, RPC_CL_BESTEFFORT_FLUSH); in nb_send()
1696 if (nBytes > (ct->ct_bufferSize - ct->ct_bufferPendingSize)) in nb_send()
1700 (void) set_blocking_connection(ct, FALSE); in nb_send()
1706 if (ct->ct_bufferPendingSize == 0) { in nb_send()
1707 result = t_snd(ct->ct_fd, buff, nBytes, 0); in nb_send()
1721 if (addInBuffer(ct, (char *)buff + result, in nb_send()
1732 int i = iovFromBuffer(ct, &iov[0]); in nb_send()
1737 result = writev(ct->ct_fd, iov, i+1); in nb_send()
1751 if (result <= ct->ct_bufferPendingSize) { in nb_send()
1753 consumeFromBuffer(ct, result); in nb_send()
1754 if (addInBuffer(ct, buff, nBytes) == -1) { in nb_send()
1763 int len = result - ct->ct_bufferPendingSize; in nb_send()
1766 ct->ct_bufferReadPtr = ct->ct_buffer; in nb_send()
1767 ct->ct_bufferWritePtr = ct->ct_buffer; in nb_send()
1768 ct->ct_bufferPendingSize = 0; in nb_send()
1772 if (addInBuffer(ct, (char *)buff + len, in nb_send()
1792 (void) do_flush(node->ct, RPC_CL_BLOCKING_FLUSH); in flush_registered_clients()
1819 register_nb(struct ct_data *ct) in register_nb() argument
1838 node->ct = ct; in register_nb()
1847 unregister_nb(struct ct_data *ct) in unregister_nb() argument
1856 if (node->next->ct == ct) { in unregister_nb()
1861 n->ct = NULL; in unregister_nb()