18 #include "XProtocol/XProtocol.hh"
19 #include "XrdClient/XrdClientProtocol.hh"
20 #include "XrdClient/XrdClientConst.hh"
21 #include "XrdClient/XrdClientSid.hh"
43 vector<IOPosBuffer> new_buf;
51 return readv(&(new_buf[0]), n);
78 readahead_list read_chunk_list[READV_MAXCHUNKS];
79 char *result_list[READV_MAXCHUNKS];
81 IOSize readv_total_len = 0;
88 ex <<
"XrdFile::readv(name='" <<
m_name <<
"')[" <<
i
89 <<
"].size=" << len <<
" exceeds read size limit 0x7fffffff";
96 char *chunk_data =
static_cast<char *
>(into[
i].
data());
99 IOSize chunk_size = len > READV_MAXCHUNKSIZE ? READV_MAXCHUNKSIZE : len;
101 readv_total_len += chunk_size;
102 read_chunk_list[chunk_off].rlen = chunk_size;
103 read_chunk_list[chunk_off].offset = off;
104 result_list[chunk_off] = chunk_data;
105 chunk_data += chunk_size;
107 memcpy(&(read_chunk_list[chunk_off].fhandle), handle, 4);
109 if (chunk_off == READV_MAXCHUNKS) {
112 IOSize tmp_total_len =
readv_send(result_list, *read_chunk_list, chunk_off, readv_total_len);
113 total_len += tmp_total_len;
114 if (tmp_total_len != readv_total_len)
123 total_len +=
readv_send(result_list, *read_chunk_list, chunk_off, readv_total_len);
143 XrdClientConn *xrdc =
m_client->GetClientConn();
144 ClientRequest readvFileRequest;
145 memset( &readvFileRequest, 0,
sizeof(readvFileRequest) );
148 memcpy(readvFileRequest.header.streamid, &sid,
sizeof(kXR_unt16));
149 readvFileRequest.header.requestid = kXR_readv;
150 readvFileRequest.readv.dlen = n *
sizeof(
struct readahead_list);
152 std::vector<char> res_buf;
153 res_buf.reserve( total_len + (n *
sizeof(
struct readahead_list)) );
156 clientMarshallReadAheadList(&read_chunk_list, readvFileRequest.readv.dlen);
161 success = xrdc->SendGenCommand(&readvFileRequest, &read_chunk_list, 0,
162 (
void *)&(res_buf[0]),
FALSE, (
char *)
"ReadV");
163 data_length = xrdc->LastServerResp.dlen;
165 clientUnMarshallReadAheadList(&read_chunk_list, readvFileRequest.readv.dlen);
170 return readv_unpack(result_list, res_buf, data_length, read_chunk_list, n);
183 IOSize response_offset = 0;
187 if (
unlikely(response_offset +
sizeof(
struct readahead_list) > response_length)) {
189 ex <<
"XrdFile::readv(name='" <<
m_name <<
"')[" <<
i
190 <<
"] returned an incorrectly-sized response (short header)";
198 const readahead_list *response =
reinterpret_cast<struct readahead_list*
>(&result_buf[response_offset]);
199 offset = ntohll(response->offset);
200 rlen = ntohl(response->rlen);
205 if (
unlikely((&read_chunk_list)[
i].offset != offset)) {
207 ex <<
"XrdFile::readv(name='" <<
m_name <<
"')[" <<
i
208 <<
"] returned offset " << offset <<
" does not match requested offset "
209 << (&read_chunk_list)[
i].offset;
214 if (
unlikely((&read_chunk_list)[
i].rlen != rlen)) {
216 ex <<
"XrdFile::readv(name='" <<
m_name <<
"')[" <<
i
217 <<
"] returned size " << rlen <<
" does not match requested size "
218 << (&read_chunk_list)[
i].rlen;
223 if (
unlikely(response_offset + rlen > response_length)) {
225 ex <<
"XrdFile::readv(name='" <<
m_name <<
"')[" <<
i
226 <<
"] returned an incorrectly-sized response (short data)";
231 response_offset +=
sizeof(
struct readahead_list);
234 memcpy(result_list[
i], &result_buf[response_offset], rlen);
235 response_offset += rlen;
static boost::mutex mutex
IOSize readv_send(char **result_buffer, readahead_list &read_chunk_list, IOSize n, IOSize total_len)
virtual IOSize readv(IOBuffer *into, IOSize n)
unsigned int offset(bool)
IOOffset offset(void) const
pthread_mutex_t & m_mutex
virtual IOOffset size(void) const
void addContext(std::string const &context)
pthread_mutex_t m_readv_mutex
IOSize readv_unpack(char **result_buffer, std::vector< char > &res_buf, IOSize datalen, readahead_list &read_chunk_list, IOSize n)
char data[epos_bytes_allocation]
void addConnection(cms::Exception &)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of FALSE
MutexSentry(pthread_mutex_t &mutex)