Lines Matching refs:ct

143 	struct ct_data *ct;  member
179 set_blocking_connection(struct ct_data *ct, bool_t blocking) in set_blocking_connection() argument
187 if (ct->ct_is_blocking == blocking) in set_blocking_connection()
190 if ((flag = fcntl(ct->ct_fd, F_GETFL, 0)) < 0) { in set_blocking_connection()
197 if (fcntl(ct->ct_fd, F_SETFL, flag) != 0) { in set_blocking_connection()
202 ct->ct_is_blocking = blocking; in set_blocking_connection()
241 struct ct_data *ct; /* private data */ in _clnt_vc_create_timed() local
248 if ((ct = malloc(sizeof (*ct))) != NULL) in _clnt_vc_create_timed()
249 ct->ct_addr.buf = NULL; in _clnt_vc_create_timed()
251 if ((cl == NULL) || (ct == NULL)) { in _clnt_vc_create_timed()
278 ct->ct_io_mode = RPC_CL_BLOCKING; in _clnt_vc_create_timed()
279 ct->ct_blocking_mode = RPC_CL_BLOCKING_FLUSH; in _clnt_vc_create_timed()
281 ct->ct_buffer = NULL; /* We allocate the buffer when needed. */ in _clnt_vc_create_timed()
282 ct->ct_bufferSize = DEFAULT_PENDING_ZONE_MAX_SIZE; in _clnt_vc_create_timed()
283 ct->ct_bufferPendingSize = 0; in _clnt_vc_create_timed()
284 ct->ct_bufferWritePtr = NULL; in _clnt_vc_create_timed()
285 ct->ct_bufferReadPtr = NULL; in _clnt_vc_create_timed()
296 ct->ct_is_blocking = flag & O_NONBLOCK ? FALSE : TRUE; in _clnt_vc_create_timed()
298 if (set_up_connection(fd, svcaddr, ct, tp) == FALSE) { in _clnt_vc_create_timed()
305 ct->ct_fd = fd; in _clnt_vc_create_timed()
309 ct->ct_wait = 30000; in _clnt_vc_create_timed()
310 ct->ct_waitset = FALSE; in _clnt_vc_create_timed()
316 ct->ct_closeit = FALSE; in _clnt_vc_create_timed()
329 xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, XDR_ENCODE); in _clnt_vc_create_timed()
330 if (!xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { in _clnt_vc_create_timed()
333 ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); in _clnt_vc_create_timed()
334 XDR_DESTROY(&(ct->ct_xdrs)); in _clnt_vc_create_timed()
353 ct->ct_tsdu = tinfo.tsdu; in _clnt_vc_create_timed()
358 ct->ct_xdrs.x_ops = NULL; in _clnt_vc_create_timed()
359 xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, (caddr_t)ct, in _clnt_vc_create_timed()
361 if (ct->ct_xdrs.x_ops == NULL) { in _clnt_vc_create_timed()
368 cl->cl_private = (caddr_t)ct; in _clnt_vc_create_timed()
375 if (ct) { in _clnt_vc_create_timed()
376 free(ct->ct_addr.buf); in _clnt_vc_create_timed()
377 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
465 ct->ct_addr.len = 0; in set_up_connection()
600 if (ct->ct_addr.buf) in set_up_connection()
601 free(ct->ct_addr.buf); in set_up_connection()
602 ct->ct_addr = rcvcall->addr; /* To get the new address */ in set_up_connection()
614 ct->ct_addr.len = 0; in set_up_connection()
616 ct->ct_addr.buf = malloc(svcaddr->len); in set_up_connection()
617 if (ct->ct_addr.buf == NULL) { in set_up_connection()
625 (void) memcpy(ct->ct_addr.buf, svcaddr->buf, in set_up_connection()
627 ct->ct_addr.len = ct->ct_addr.maxlen = svcaddr->len; in set_up_connection()
641 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_call() local
642 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_call()
645 uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ in clnt_vc_call()
649 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_call()
652 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
656 ct->ct_is_oneway = FALSE; in clnt_vc_call()
657 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_call()
658 if (do_flush(ct, RPC_CL_BLOCKING_FLUSH) != 0) { in clnt_vc_call()
659 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
664 if (!ct->ct_waitset) { in clnt_vc_call()
667 ct->ct_wait = __rpc_timeval_to_msec(&timeout); in clnt_vc_call()
669 timeout.tv_sec = (ct->ct_wait / 1000); in clnt_vc_call()
670 timeout.tv_usec = (ct->ct_wait % 1000) * 1000; in clnt_vc_call()
686 if ((!XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || in clnt_vc_call()
693 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
697 uint32_t *u = (uint32_t *)&ct->ct_mcall[ct->ct_mpos]; in clnt_vc_call()
699 if (!__rpc_gss_wrap(cl->cl_auth, ct->ct_mcall, in clnt_vc_call()
700 ((char *)u) - ct->ct_mcall, xdrs, xdr_args, args_ptr)) { in clnt_vc_call()
704 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
709 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
713 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
720 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
734 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
741 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
797 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_call()
804 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_send() local
805 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_send()
807 uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ in clnt_vc_send()
809 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_send()
812 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
816 ct->ct_is_oneway = TRUE; in clnt_vc_send()
828 if ((!XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || in clnt_vc_send()
835 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
839 uint32_t *u = (uint32_t *)&ct->ct_mcall[ct->ct_mpos]; in clnt_vc_send()
841 if (!__rpc_gss_wrap(cl->cl_auth, ct->ct_mcall, in clnt_vc_send()
842 ((char *)u) - ct->ct_mcall, xdrs, xdr_args, args_ptr)) { in clnt_vc_send()
846 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
859 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_send()
873 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_freeres() local
874 XDR *xdrs = &(ct->ct_xdrs); in clnt_vc_freeres()
877 (void) rpc_fd_lock(vctbl, ct->ct_fd); in clnt_vc_freeres()
880 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_freeres()
893 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_control() local
895 if (rpc_fd_lock(vctbl, ct->ct_fd)) { in clnt_vc_control()
896 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
902 ct->ct_closeit = TRUE; in clnt_vc_control()
903 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
906 ct->ct_closeit = FALSE; in clnt_vc_control()
907 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
910 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_control()
912 res = do_flush(ct, (info == NULL || in clnt_vc_control()
914 ct->ct_blocking_mode: *(int *)info); in clnt_vc_control()
919 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
925 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
931 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
934 ct->ct_wait = __rpc_timeval_to_msec((struct timeval *)info); in clnt_vc_control()
935 ct->ct_waitset = TRUE; in clnt_vc_control()
938 ((struct timeval *)info)->tv_sec = ct->ct_wait / 1000; in clnt_vc_control()
939 ((struct timeval *)info)->tv_usec = (ct->ct_wait % 1000) * 1000; in clnt_vc_control()
942 (void) memcpy(info, ct->ct_addr.buf, (size_t)ct->ct_addr.len); in clnt_vc_control()
945 *(int *)info = ct->ct_fd; in clnt_vc_control()
949 *(struct netbuf *)info = ct->ct_addr; in clnt_vc_control()
958 if (t_snddis(ct->ct_fd, NULL) == -1) { in clnt_vc_control()
962 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
965 ret = set_up_connection(ct->ct_fd, (struct netbuf *)info, in clnt_vc_control()
966 ct, NULL); in clnt_vc_control()
967 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
970 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
979 *(uint32_t *)info = ntohl(*(uint32_t *)ct->ct_mcall); in clnt_vc_control()
983 *(uint32_t *)ct->ct_mcall = htonl(*(uint32_t *)info + 1); in clnt_vc_control()
993 *(uint32_t *)info = ntohl(*(uint32_t *)(ct->ct_mcall + in clnt_vc_control()
998 *(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()
1014 *(uint32_t *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT) = in clnt_vc_control()
1019 if (!set_io_mode(ct, *(int *)info)) { in clnt_vc_control()
1020 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1026 if (!set_flush_mode(ct, *(int *)info)) { in clnt_vc_control()
1027 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1032 *(rpcflushmode_t *)info = ct->ct_blocking_mode; in clnt_vc_control()
1036 *(rpciomode_t *)info = ct->ct_io_mode; in clnt_vc_control()
1044 *(int *)info = ct->ct_bufferPendingSize; in clnt_vc_control()
1049 if (ct->ct_bufferPendingSize != 0) { in clnt_vc_control()
1050 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1057 if (ct->ct_bufferSize == *(uint_t *)info) in clnt_vc_control()
1060 ct->ct_bufferSize = *(uint_t *)info; in clnt_vc_control()
1061 if (ct->ct_buffer) { in clnt_vc_control()
1062 free(ct->ct_buffer); in clnt_vc_control()
1063 ct->ct_buffer = NULL; in clnt_vc_control()
1064 ct->ct_bufferReadPtr = ct->ct_bufferWritePtr = NULL; in clnt_vc_control()
1073 *(uint_t *)info = ct->ct_bufferSize; in clnt_vc_control()
1077 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1080 rpc_fd_unlock(vctbl, ct->ct_fd); in clnt_vc_control()
1087 struct ct_data *ct = (struct ct_data *)cl->cl_private; in clnt_vc_destroy() local
1088 int ct_fd = ct->ct_fd; in clnt_vc_destroy()
1092 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in clnt_vc_destroy()
1093 (void) do_flush(ct, RPC_CL_BLOCKING_FLUSH); in clnt_vc_destroy()
1094 (void) unregister_nb(ct); in clnt_vc_destroy()
1097 if (ct->ct_closeit) in clnt_vc_destroy()
1099 XDR_DESTROY(&(ct->ct_xdrs)); in clnt_vc_destroy()
1100 if (ct->ct_addr.buf) in clnt_vc_destroy()
1101 free(ct->ct_addr.buf); in clnt_vc_destroy()
1102 free(ct); in clnt_vc_destroy()
1122 struct ct_data *ct = ct_tmp; in read_vc() local
1152 pfdp[0].fd = ct->ct_fd; in read_vc()
1155 poll_time = ct->ct_wait; in read_vc()
1263 switch (len = t_rcvall(ct->ct_fd, buf, len)) { in read_vc()
1285 struct ct_data *ct = ct_tmp; in write_vc() local
1289 maxsz = ct->ct_tsdu; in write_vc()
1292 if (ct->ct_is_oneway && ct->ct_io_mode == RPC_CL_NONBLOCKING) { in write_vc()
1306 len = nb_send(ct, buf, (unsigned)len); in write_vc()
1326 if ((len = t_snd(ct->ct_fd, buf, (unsigned)len, 0)) == -1) { in write_vc()
1339 if ((i = t_snd(ct->ct_fd, buf, (unsigned)MIN(cnt, maxsz), in write_vc()
1424 #define REMAIN_BYTES(p) (ct->ct_bufferSize-(ct->ct_##p - ct->ct_buffer))
1427 addInBuffer(struct ct_data *ct, char *dataToAdd, unsigned int nBytes) in addInBuffer() argument
1429 if (NULL == ct->ct_buffer) { in addInBuffer()
1433 buffer = malloc(ct->ct_bufferSize); in addInBuffer()
1440 ct->ct_buffer = buffer; in addInBuffer()
1441 ct->ct_bufferReadPtr = buffer; in addInBuffer()
1442 ct->ct_bufferWritePtr = buffer + nBytes; in addInBuffer()
1443 ct->ct_bufferPendingSize = nBytes; in addInBuffer()
1454 ct->ct_bufferPendingSize += nBytes; in addInBuffer()
1456 (void) memcpy(ct->ct_bufferWritePtr, dataToAdd, len); in addInBuffer()
1457 ct->ct_bufferWritePtr += len; in addInBuffer()
1466 if (ct->ct_bufferWritePtr == in addInBuffer()
1467 (ct->ct_buffer + ct->ct_bufferSize)) { in addInBuffer()
1468 ct->ct_bufferWritePtr = ct->ct_buffer; in addInBuffer()
1478 (void) memcpy(ct->ct_buffer, dataToAdd, nBytes); in addInBuffer()
1479 ct->ct_bufferWritePtr = ct->ct_buffer + nBytes; in addInBuffer()
1486 consumeFromBuffer(struct ct_data *ct, unsigned int nBytes) in consumeFromBuffer() argument
1488 ct->ct_bufferPendingSize -= nBytes; in consumeFromBuffer()
1489 if (ct->ct_bufferPendingSize == 0) { in consumeFromBuffer()
1494 ct->ct_bufferReadPtr = ct->ct_bufferWritePtr = ct->ct_buffer; in consumeFromBuffer()
1496 ct->ct_bufferReadPtr += nBytes; in consumeFromBuffer()
1497 if (ct->ct_bufferReadPtr > in consumeFromBuffer()
1498 ct->ct_buffer + ct->ct_bufferSize) { in consumeFromBuffer()
1499 ct->ct_bufferReadPtr -= ct->ct_bufferSize; in consumeFromBuffer()
1505 iovFromBuffer(struct ct_data *ct, struct iovec *iov) in iovFromBuffer() argument
1509 if (ct->ct_bufferPendingSize == 0) in iovFromBuffer()
1513 if (l < ct->ct_bufferPendingSize) { in iovFromBuffer()
1515 iov[0].iov_base = ct->ct_bufferReadPtr; in iovFromBuffer()
1518 iov[1].iov_base = ct->ct_buffer; in iovFromBuffer()
1519 iov[1].iov_len = ct->ct_bufferPendingSize - l; in iovFromBuffer()
1523 iov[0].iov_base = ct->ct_bufferReadPtr; in iovFromBuffer()
1524 iov[0].iov_len = ct->ct_bufferPendingSize; in iovFromBuffer()
1530 set_flush_mode(struct ct_data *ct, int mode) in set_flush_mode() argument
1539 ct->ct_blocking_mode = mode; in set_flush_mode()
1547 set_io_mode(struct ct_data *ct, int ioMode) in set_io_mode() argument
1551 if (ct->ct_io_mode == RPC_CL_NONBLOCKING) { in set_io_mode()
1552 if (NULL != ct->ct_buffer) { in set_io_mode()
1557 (void) do_flush(ct, RPC_CL_BLOCKING_FLUSH); in set_io_mode()
1558 free(ct->ct_buffer); in set_io_mode()
1559 ct->ct_buffer = NULL; in set_io_mode()
1561 (void) unregister_nb(ct); in set_io_mode()
1562 ct->ct_io_mode = ioMode; in set_io_mode()
1566 if (ct->ct_io_mode == RPC_CL_BLOCKING) { in set_io_mode()
1567 if (-1 == register_nb(ct)) { in set_io_mode()
1570 ct->ct_io_mode = ioMode; in set_io_mode()
1580 do_flush(struct ct_data *ct, uint_t flush_mode) in do_flush() argument
1583 if (ct->ct_bufferPendingSize == 0) { in do_flush()
1589 if (!set_blocking_connection(ct, TRUE)) { in do_flush()
1592 while (ct->ct_bufferPendingSize > 0) { in do_flush()
1594 ct->ct_bufferPendingSize) { in do_flush()
1596 (void) iovFromBuffer(ct, iov); in do_flush()
1597 result = writev(ct->ct_fd, iov, 2); in do_flush()
1599 result = t_snd(ct->ct_fd, ct->ct_bufferReadPtr, in do_flush()
1600 ct->ct_bufferPendingSize, 0); in do_flush()
1605 consumeFromBuffer(ct, result); in do_flush()
1611 (void) set_blocking_connection(ct, FALSE); in do_flush()
1612 if (REMAIN_BYTES(bufferReadPtr) < ct->ct_bufferPendingSize) { in do_flush()
1614 (void) iovFromBuffer(ct, iov); in do_flush()
1615 result = writev(ct->ct_fd, iov, 2); in do_flush()
1617 result = t_snd(ct->ct_fd, ct->ct_bufferReadPtr, in do_flush()
1618 ct->ct_bufferPendingSize, 0); in do_flush()
1628 consumeFromBuffer(ct, result); in do_flush()
1645 nb_send(struct ct_data *ct, void *buff, unsigned int nBytes) in nb_send() argument
1658 if (nBytes > (ct->ct_bufferSize - ct->ct_bufferPendingSize)) { in nb_send()
1660 (void) do_flush(ct, RPC_CL_BESTEFFORT_FLUSH); in nb_send()
1663 if (nBytes > (ct->ct_bufferSize - ct->ct_bufferPendingSize)) in nb_send()
1667 (void) set_blocking_connection(ct, FALSE); in nb_send()
1673 if (ct->ct_bufferPendingSize == 0) { in nb_send()
1674 result = t_snd(ct->ct_fd, buff, nBytes, 0); in nb_send()
1688 if (addInBuffer(ct, (char *)buff + result, in nb_send()
1699 int i = iovFromBuffer(ct, &iov[0]); in nb_send()
1704 result = writev(ct->ct_fd, iov, i+1); in nb_send()
1718 if (result <= ct->ct_bufferPendingSize) { in nb_send()
1720 consumeFromBuffer(ct, result); in nb_send()
1721 if (addInBuffer(ct, buff, nBytes) == -1) { in nb_send()
1730 int len = result - ct->ct_bufferPendingSize; in nb_send()
1733 ct->ct_bufferReadPtr = ct->ct_buffer; in nb_send()
1734 ct->ct_bufferWritePtr = ct->ct_buffer; in nb_send()
1735 ct->ct_bufferPendingSize = 0; in nb_send()
1739 if (addInBuffer(ct, (char *)buff + len, in nb_send()
1759 (void) do_flush(node->ct, RPC_CL_BLOCKING_FLUSH); in flush_registered_clients()
1786 register_nb(struct ct_data *ct) in register_nb() argument
1805 node->ct = ct; in register_nb()
1814 unregister_nb(struct ct_data *ct) in unregister_nb() argument
1823 if (node->next->ct == ct) { in unregister_nb()
1828 n->ct = NULL; in unregister_nb()