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

Method transfer_bytes

src/proxy/PluginVC.cc:431–469  ·  view source on GitHub ↗

int PluginVC::transfer_bytes(MIOBuffer* transfer_to, IOBufferReader* transfer_from, int act_on) Takes care of transferring bytes from a reader to another buffer In the case of large transfers, we move blocks. In the case of small transfers we copy data so as to not build too many buffer blocks Args: transfer_to: buffer to copy to transfer_from: buffer_copy_from act_on: is the max number of by

Source from the content-addressed store, hash-verified

429// Returns number of bytes transferred
430//
431int64_t
432PluginVC::transfer_bytes(MIOBuffer *transfer_to, IOBufferReader *transfer_from, int64_t act_on)
433{
434 int64_t total_added = 0;
435
436 ink_assert(act_on <= transfer_from->read_avail());
437
438 while (act_on > 0) {
439 int64_t block_read_avail = transfer_from->block_read_avail();
440 int64_t to_move = std::min(act_on, block_read_avail);
441 int64_t moved = 0;
442
443 if (to_move <= 0) {
444 break;
445 }
446
447 if (to_move >= MIN_BLOCK_TRANSFER_BYTES) {
448 moved = transfer_to->write(transfer_from, to_move, 0);
449 } else {
450 // We have a really small amount of data. To make
451 // sure we don't get a huge build up of blocks which
452 // can lead to stack overflows if the buffer is destroyed
453 // before we read from it, we need copy over to the new
454 // buffer instead of doing a block transfer
455 moved = transfer_to->write(transfer_from->start(), to_move);
456
457 if (moved == 0) {
458 // We are out of buffer space
459 break;
460 }
461 }
462
463 act_on -= moved;
464 transfer_from->consume(moved);
465 total_added += moved;
466 }
467
468 return total_added;
469}
470
471// void PluginVC::process_write_side()
472//

Callers

nothing calls this directly

Calls 5

block_read_availMethod · 0.80
read_availMethod · 0.45
writeMethod · 0.45
startMethod · 0.45
consumeMethod · 0.45

Tested by

no test coverage detected