This code was pulled out of write_to_net so I could overwrite it for the SSL implementation (SSL read does not support overlapped i/o) without duplicating all the code in write_to_net.
| 854 | // (SSL read does not support overlapped i/o) |
| 855 | // without duplicating all the code in write_to_net. |
| 856 | int64_t |
| 857 | UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf, int64_t &total_written, int &needs) |
| 858 | { |
| 859 | int64_t r = 0; |
| 860 | int64_t try_to_write = 0; |
| 861 | IOBufferReader *tmp_reader = buf.reader()->clone(); |
| 862 | |
| 863 | do { |
| 864 | IOVec tiovec[NET_MAX_IOV]; |
| 865 | unsigned niov = 0; |
| 866 | try_to_write = 0; |
| 867 | |
| 868 | while (niov < NET_MAX_IOV) { |
| 869 | int64_t wavail = towrite - total_written - try_to_write; |
| 870 | int64_t len = tmp_reader->block_read_avail(); |
| 871 | |
| 872 | // Check if we have done this block. |
| 873 | if (len <= 0) { |
| 874 | break; |
| 875 | } |
| 876 | |
| 877 | // Check if the amount to write exceeds that in this buffer. |
| 878 | if (len > wavail) { |
| 879 | len = wavail; |
| 880 | } |
| 881 | |
| 882 | if (len == 0) { |
| 883 | break; |
| 884 | } |
| 885 | |
| 886 | // build an iov entry |
| 887 | tiovec[niov].iov_len = len; |
| 888 | tiovec[niov].iov_base = tmp_reader->start(); |
| 889 | niov++; |
| 890 | |
| 891 | try_to_write += len; |
| 892 | tmp_reader->consume(len); |
| 893 | } |
| 894 | |
| 895 | ink_assert(niov > 0); |
| 896 | ink_assert(niov <= countof(tiovec)); |
| 897 | |
| 898 | // If the platform doesn't support TCP Fast Open, verify that we |
| 899 | // correctly disabled support in the socket option configuration. |
| 900 | ink_assert(MSG_FASTOPEN != 0 || this->options.f_tcp_fastopen == false); |
| 901 | struct msghdr msg; |
| 902 | |
| 903 | ink_zero(msg); |
| 904 | if (!ats_is_unix(this->get_local_addr())) { |
| 905 | msg.msg_name = const_cast<sockaddr *>(this->get_remote_addr()); |
| 906 | msg.msg_namelen = ats_ip_size(this->get_remote_addr()); |
| 907 | } |
| 908 | msg.msg_iov = &tiovec[0]; |
| 909 | msg.msg_iovlen = niov; |
| 910 | int flags = 0; |
| 911 | |
| 912 | if (!this->con.is_connected && this->options.f_tcp_fastopen) { |
| 913 | Metrics::Counter::increment(net_rsb.fastopen_attempts); |
no test coverage detected