Lines Matching refs:ct

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