Lines Matching refs:ct
137 struct ct_data *ct; member
173 set_blocking_connection(struct ct_data *ct, bool_t blocking) in set_blocking_connection() argument
181 if (ct->ct_is_blocking == blocking) in set_blocking_connection()
184 if ((flag = fcntl(ct->ct_fd, F_GETFL, 0)) < 0) { in set_blocking_connection()
191 if (fcntl(ct->ct_fd, F_SETFL, flag) != 0) { in set_blocking_connection()
196 ct->ct_is_blocking = blocking; in set_blocking_connection()
235 struct ct_data *ct; /* private data */ in _clnt_vc_create_timed() local
242 ct = malloc(sizeof (*ct)); in _clnt_vc_create_timed()
243 if ((cl == NULL) || (ct == NULL)) { in _clnt_vc_create_timed()
251 ct->ct_addr.buf = NULL; in _clnt_vc_create_timed()
271 ct->ct_io_mode = RPC_CL_BLOCKING; in _clnt_vc_create_timed()
272 ct->ct_blocking_mode = RPC_CL_BLOCKING_FLUSH; in _clnt_vc_create_timed()
274 ct->ct_buffer = NULL; /* We allocate the buffer when needed. */ in _clnt_vc_create_timed()
275 ct->ct_bufferSize = DEFAULT_PENDING_ZONE_MAX_SIZE; in _clnt_vc_create_timed()
276 ct->ct_bufferPendingSize = 0; in _clnt_vc_create_timed()
277 ct->ct_bufferWritePtr = NULL; in _clnt_vc_create_timed()
278 ct->ct_bufferReadPtr = NULL; in _clnt_vc_create_timed()
289 ct->ct_is_blocking = flag & O_NONBLOCK ? FALSE : TRUE; in _clnt_vc_create_timed()
291 if (set_up_connection(fd, svcaddr, ct, tp) == FALSE) { in _clnt_vc_create_timed()
298 ct->ct_fd = fd; in _clnt_vc_create_timed()
302 ct->ct_wait = 30000; in _clnt_vc_create_timed()
303 ct->ct_waitset = FALSE; in _clnt_vc_create_timed()
309 ct->ct_closeit = FALSE; in _clnt_vc_create_timed()
322 xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, XDR_ENCODE); in _clnt_vc_create_timed()
323 if (!xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { in _clnt_vc_create_timed()
326 ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); in _clnt_vc_create_timed()
327 XDR_DESTROY(&(ct->ct_xdrs)); in _clnt_vc_create_timed()
346 ct->ct_tsdu = tinfo.tsdu; in _clnt_vc_create_timed()
351 ct->ct_xdrs.x_ops = NULL; in _clnt_vc_create_timed()
352 xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, (caddr_t)ct, in _clnt_vc_create_timed()
354 if (ct->ct_xdrs.x_ops == NULL) { in _clnt_vc_create_timed()
361 cl->cl_private = (caddr_t)ct; in _clnt_vc_create_timed()
369 if (ct) { in _clnt_vc_create_timed()
370 if (ct->ct_addr.len) in _clnt_vc_create_timed()
371 free(ct->ct_addr.buf); in _clnt_vc_create_timed()
372 free(ct); in _clnt_vc_create_timed()
454 set_up_connection(int fd, struct netbuf *svcaddr, struct ct_data *ct, in set_up_connection() argument
463 ct->ct_addr.len = 0; in set_up_connection()
579 if (ct->ct_addr.buf) in set_up_connection()
580 free(ct->ct_addr.buf); in set_up_connection()
581 ct->ct_addr = rcvcall->addr; /* To get the new address */ in set_up_connection()
593 ct->ct_addr.len = 0; in set_up_connection()
595 ct->ct_addr.buf = malloc(svcaddr->len); in set_up_connection()
596 if (ct->ct_addr.buf == NULL) { in set_up_connection()
604 (void) memcpy(ct->ct_addr.buf, svcaddr->buf, in set_up_connection()
606 ct->ct_addr.len = ct->ct_addr.maxlen = svcaddr->len; in set_up_connection()
621 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_call() local
622 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_call()
626 uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ in clnt_vc_call()
630 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_call()
633 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
637 ct->ct_is_oneway = FALSE; in clnt_vc_call()
638 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_call()
639 if (do_flush(ct, RPC_CL_BLOCKING_FLUSH) != 0) { in clnt_vc_call()
640 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
645 if (!ct->ct_waitset) { in clnt_vc_call()
648 ct->ct_wait = __rpc_timeval_to_msec(&timeout); in clnt_vc_call()
650 timeout.tv_sec = (ct->ct_wait / 1000); in clnt_vc_call()
651 timeout.tv_usec = (ct->ct_wait % 1000) * 1000; in clnt_vc_call()
667 if ((!XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || in clnt_vc_call()
674 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
679 uint32_t *u = (uint32_t *)&ct->ct_mcall[ct->ct_mpos]; in clnt_vc_call()
681 if (!__rpc_gss_wrap(cl->cl_auth, ct->ct_mcall, in clnt_vc_call()
682 ((char *)u) - ct->ct_mcall, xdrs, xdr_args, args_ptr)) { in clnt_vc_call()
686 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
691 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
695 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
702 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
716 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
723 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
778 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
786 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_send() local
787 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_send()
790 uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ in clnt_vc_send()
792 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_send()
795 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
799 ct->ct_is_oneway = TRUE; in clnt_vc_send()
811 if ((!XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || in clnt_vc_send()
818 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
823 uint32_t *u = (uint32_t *)&ct->ct_mcall[ct->ct_mpos]; in clnt_vc_send()
825 if (!__rpc_gss_wrap(cl->cl_auth, ct->ct_mcall, in clnt_vc_send()
826 ((char *)u) - ct->ct_mcall, xdrs, xdr_args, args_ptr)) { in clnt_vc_send()
830 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
843 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
858 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_freeres() local
859 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_freeres()
862 (void) rpc_fd_lock(vctbl, ct->ct_fd); in clnt_vc_freeres()
865 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_freeres()
880 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_control() local
882 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_control()
883 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
889 ct->ct_closeit = TRUE; in clnt_vc_control()
890 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
893 ct->ct_closeit = FALSE; in clnt_vc_control()
894 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
897 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_control()
899 res = do_flush(ct, (info == NULL || in clnt_vc_control()
903 ct->ct_blocking_mode: *(int *)info); in clnt_vc_control()
906 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
912 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
919 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
923 ct->ct_wait = __rpc_timeval_to_msec((struct timeval *)info); in clnt_vc_control()
924 ct->ct_waitset = TRUE; in clnt_vc_control()
928 ((struct timeval *)info)->tv_sec = ct->ct_wait / 1000; in clnt_vc_control()
931 (ct->ct_wait % 1000) * 1000; in clnt_vc_control()
934 (void) memcpy(info, ct->ct_addr.buf, (size_t)ct->ct_addr.len); in clnt_vc_control()
938 *(int *)info = ct->ct_fd; in clnt_vc_control()
943 *(struct netbuf *)info = ct->ct_addr; in clnt_vc_control()
952 if (t_snddis(ct->ct_fd, NULL) == -1) { in clnt_vc_control()
956 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
959 ret = set_up_connection(ct->ct_fd, (struct netbuf *)info, in clnt_vc_control()
960 ct, NULL)); in clnt_vc_control()
961 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
964 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
974 *(uint32_t *)info = ntohl(*(uint32_t *)ct->ct_mcall); in clnt_vc_control()
979 *(uint32_t *)ct->ct_mcall = htonl(*(uint32_t *)info + 1); in clnt_vc_control()
990 *(uint32_t *)info = ntohl(*(uint32_t *)(ct->ct_mcall + in clnt_vc_control()
996 *(uint32_t *)(ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT) = in clnt_vc_control()
1009 *(uint32_t *)info = ntohl(*(uint32_t *)(ct->ct_mcall + in clnt_vc_control()
1015 *(uint32_t *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT) = in clnt_vc_control()
1022 if (!set_io_mode(ct, *(int *)info)) { in clnt_vc_control()
1023 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1030 if (!set_flush_mode(ct, *(int *)info)) { in clnt_vc_control()
1031 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1037 *(rpcflushmode_t *)info = ct->ct_blocking_mode; in clnt_vc_control()
1042 *(rpciomode_t *)info = ct->ct_io_mode; in clnt_vc_control()
1051 *(int *)info = ct->ct_bufferPendingSize; in clnt_vc_control()
1056 if (ct->ct_bufferPendingSize != 0) { in clnt_vc_control()
1057 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1065 if (ct->ct_bufferSize == *(uint_t *)info) in clnt_vc_control()
1069 ct->ct_bufferSize = *(uint_t *)info; in clnt_vc_control()
1070 if (ct->ct_buffer) { in clnt_vc_control()
1071 free(ct->ct_buffer); in clnt_vc_control()
1072 ct->ct_buffer = NULL; in clnt_vc_control()
1073 ct->ct_bufferReadPtr = ct->ct_bufferWritePtr = NULL; in clnt_vc_control()
1083 *(uint_t *)info = ct->ct_bufferSize; in clnt_vc_control()
1087 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1090 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1098 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_destroy() local
1099 int ct_fd = ct->ct_fd; in clnt_vc_destroy()
1103 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_destroy()
1104 (void) do_flush(ct, RPC_CL_BLOCKING_FLUSH); in clnt_vc_destroy()
1105 (void) unregister_nb(ct); in clnt_vc_destroy()
1108 if (ct->ct_closeit) in clnt_vc_destroy()
1110 XDR_DESTROY(&(ct->ct_xdrs)); in clnt_vc_destroy()
1111 if (ct->ct_addr.buf) in clnt_vc_destroy()
1112 free(ct->ct_addr.buf); in clnt_vc_destroy()
1113 free(ct); in clnt_vc_destroy()
1133 struct ct_data *ct = ct_tmp; in read_vc() local
1163 pfdp[0].fd = ct->ct_fd; in read_vc()
1166 poll_time = ct->ct_wait; in read_vc()
1275 switch (len = t_rcvall(ct->ct_fd, buf, len)) { in read_vc()
1297 struct ct_data *ct = ct_tmp; in write_vc() local
1301 maxsz = ct->ct_tsdu; in write_vc()
1304 if (ct->ct_is_oneway && ct->ct_io_mode == RPC_CL_NONBLOCKING) { in write_vc()
1318 len = nb_send(ct, buf, (unsigned)len); in write_vc()
1338 if ((len = t_snd(ct->ct_fd, buf, (unsigned)len, 0)) == -1) { in write_vc()
1351 if ((i = t_snd(ct->ct_fd, buf, (unsigned)MIN(cnt, maxsz), in write_vc()
1436 #define REMAIN_BYTES(p) (ct->ct_bufferSize-(ct->ct_##p - ct->ct_buffer))
1439 addInBuffer(struct ct_data *ct, char *dataToAdd, unsigned int nBytes) in addInBuffer() argument
1441 if (NULL == ct->ct_buffer) { in addInBuffer()
1445 buffer = malloc(ct->ct_bufferSize); in addInBuffer()
1452 ct->ct_buffer = buffer; in addInBuffer()
1453 ct->ct_bufferReadPtr = buffer; in addInBuffer()
1454 ct->ct_bufferWritePtr = buffer + nBytes; in addInBuffer()
1455 ct->ct_bufferPendingSize = nBytes; in addInBuffer()
1466 ct->ct_bufferPendingSize += nBytes; in addInBuffer()
1468 (void) memcpy(ct->ct_bufferWritePtr, dataToAdd, len); in addInBuffer()
1469 ct->ct_bufferWritePtr += len; in addInBuffer()
1478 if (ct->ct_bufferWritePtr == in addInBuffer()
1479 (ct->ct_buffer + ct->ct_bufferSize)) { in addInBuffer()
1480 ct->ct_bufferWritePtr = ct->ct_buffer; in addInBuffer()
1490 (void) memcpy(ct->ct_buffer, dataToAdd, nBytes); in addInBuffer()
1491 ct->ct_bufferWritePtr = ct->ct_buffer + nBytes; in addInBuffer()
1498 consumeFromBuffer(struct ct_data *ct, unsigned int nBytes) in consumeFromBuffer() argument
1500 ct->ct_bufferPendingSize -= nBytes; in consumeFromBuffer()
1501 if (ct->ct_bufferPendingSize == 0) { in consumeFromBuffer()
1506 ct->ct_bufferReadPtr = ct->ct_bufferWritePtr = ct->ct_buffer; in consumeFromBuffer()
1508 ct->ct_bufferReadPtr += nBytes; in consumeFromBuffer()
1509 if (ct->ct_bufferReadPtr > in consumeFromBuffer()
1510 ct->ct_buffer + ct->ct_bufferSize) { in consumeFromBuffer()
1511 ct->ct_bufferReadPtr -= ct->ct_bufferSize; in consumeFromBuffer()
1517 iovFromBuffer(struct ct_data *ct, struct iovec *iov) in iovFromBuffer() argument
1521 if (ct->ct_bufferPendingSize == 0) in iovFromBuffer()
1525 if (l < ct->ct_bufferPendingSize) { in iovFromBuffer()
1527 iov[0].iov_base = ct->ct_bufferReadPtr; in iovFromBuffer()
1530 iov[1].iov_base = ct->ct_buffer; in iovFromBuffer()
1531 iov[1].iov_len = ct->ct_bufferPendingSize - l; in iovFromBuffer()
1535 iov[0].iov_base = ct->ct_bufferReadPtr; in iovFromBuffer()
1536 iov[0].iov_len = ct->ct_bufferPendingSize; in iovFromBuffer()
1542 set_flush_mode(struct ct_data *ct, int mode) in set_flush_mode() argument
1551 ct->ct_blocking_mode = mode; in set_flush_mode()
1559 set_io_mode(struct ct_data *ct, int ioMode) in set_io_mode() argument
1563 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in set_io_mode()
1564 if (NULL != ct->ct_buffer) { in set_io_mode()
1569 (void) do_flush(ct, RPC_CL_BLOCKING_FLUSH); in set_io_mode()
1570 free(ct->ct_buffer); in set_io_mode()
1571 ct->ct_buffer = NULL; in set_io_mode()
1573 (void) unregister_nb(ct); in set_io_mode()
1574 ct->ct_io_mode = ioMode; in set_io_mode()
1578 if (ct->ct_io_mode == RPC_CL_BLOCKING) { in set_io_mode()
1579 if (-1 == register_nb(ct)) { in set_io_mode()
1582 ct->ct_io_mode = ioMode; in set_io_mode()
1592 do_flush(struct ct_data *ct, uint_t flush_mode) in do_flush() argument
1595 if (ct->ct_bufferPendingSize == 0) { in do_flush()
1601 if (!set_blocking_connection(ct, TRUE)) { in do_flush()
1604 while (ct->ct_bufferPendingSize > 0) { in do_flush()
1606 ct->ct_bufferPendingSize) { in do_flush()
1608 (void) iovFromBuffer(ct, iov); in do_flush()
1609 result = writev(ct->ct_fd, iov, 2); in do_flush()
1611 result = t_snd(ct->ct_fd, ct->ct_bufferReadPtr, in do_flush()
1612 ct->ct_bufferPendingSize, 0); in do_flush()
1617 consumeFromBuffer(ct, result); in do_flush()
1623 (void) set_blocking_connection(ct, FALSE); in do_flush()
1624 if (REMAIN_BYTES(bufferReadPtr) < ct->ct_bufferPendingSize) { in do_flush()
1626 (void) iovFromBuffer(ct, iov); in do_flush()
1627 result = writev(ct->ct_fd, iov, 2); in do_flush()
1629 result = t_snd(ct->ct_fd, ct->ct_bufferReadPtr, in do_flush()
1630 ct->ct_bufferPendingSize, 0); in do_flush()
1640 consumeFromBuffer(ct, result); in do_flush()
1651 nb_send(struct ct_data *ct, void *buff, unsigned int nBytes) in nb_send() argument
1664 if (nBytes > (ct->ct_bufferSize - ct->ct_bufferPendingSize)) { in nb_send()
1666 (void) do_flush(ct, RPC_CL_BESTEFFORT_FLUSH); in nb_send()
1669 if (nBytes > (ct->ct_bufferSize - ct->ct_bufferPendingSize)) in nb_send()
1673 (void) set_blocking_connection(ct, FALSE); in nb_send()
1679 if (ct->ct_bufferPendingSize == 0) { in nb_send()
1680 result = t_snd(ct->ct_fd, buff, nBytes, 0); in nb_send()
1694 if (addInBuffer(ct, (char *)buff + result, in nb_send()
1705 int i = iovFromBuffer(ct, &iov[0]); in nb_send()
1710 result = writev(ct->ct_fd, iov, i+1); in nb_send()
1724 if (result <= ct->ct_bufferPendingSize) { in nb_send()
1726 consumeFromBuffer(ct, result); in nb_send()
1727 if (addInBuffer(ct, buff, nBytes) == -1) { in nb_send()
1736 int len = result - ct->ct_bufferPendingSize; in nb_send()
1739 ct->ct_bufferReadPtr = ct->ct_buffer; in nb_send()
1740 ct->ct_bufferWritePtr = ct->ct_buffer; in nb_send()
1741 ct->ct_bufferPendingSize = 0; in nb_send()
1745 if (addInBuffer(ct, (char *)buff + len, in nb_send()
1765 (void) do_flush(node->ct, RPC_CL_BLOCKING_FLUSH); in flush_registered_clients()
1792 register_nb(struct ct_data *ct) in register_nb() argument
1811 node->ct = ct; in register_nb()
1820 unregister_nb(struct ct_data *ct) in unregister_nb() argument
1829 if (node->next->ct == ct) { in unregister_nb()
1834 n->ct = NULL; in unregister_nb()