MCPcopy Create free account
hub / github.com/apache/trafficserver / read_all

Method read_all

src/mgmt/rpc/server/IPCSocketServer.cc:395–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395std::tuple<bool, std::string>
396IPCSocketServer::Client::read_all(Buffer &bw) const
397{
398 std::string buff;
399 while (true) {
400 auto ret = read({bw.writable_data(), bw.available()});
401 if (ret < 0) {
402 if (check_for_transient_errors()) {
403 continue;
404 } else {
405 return {false, swoc::bwprint(buff, "Error reading the socket: {}", swoc::bwf::Errno{})};
406 }
407 }
408
409 if (ret == 0) {
410 if (bw.stored()) {
411 return {false, swoc::bwprint(buff, "Peer disconnected after reading {} bytes.", bw.stored())};
412 }
413 return {false, swoc::bwprint(buff, "Peer disconnected. EOF")};
414 }
415 bw.save(ret);
416 if (_max_req_size - bw.stored() > 0) { // we can still read more.
417 using namespace std::chrono_literals;
418 if (!this->poll_for_data(1ms)) {
419 return {true, buff};
420 }
421 continue;
422 } else {
423 swoc::bwprint(buff, "Buffer is full, we hit the limit: {}", _max_req_size);
424 break;
425 }
426 }
427
428 return {false, buff};
429}
430
431void
432IPCSocketServer::Client::write(std::string const &data, std::error_code &ec) const

Callers 2

runMethod · 0.45
queryMethod · 0.45

Calls 7

poll_for_dataMethod · 0.95
writable_dataMethod · 0.80
availableMethod · 0.80
storedMethod · 0.80
saveMethod · 0.80
readFunction · 0.50

Tested by 1

queryMethod · 0.36