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

Method net_read_io

src/iocore/net/UnixNetVConnection.cc:475–629  ·  view source on GitHub ↗

Read the data for a UnixNetVConnection. Rescheduling the UnixNetVConnection by moving the VC onto or off of the ready_list.

Source from the content-addressed store, hash-verified

473// Rescheduling the UnixNetVConnection by moving the VC
474// onto or off of the ready_list.
475void
476UnixNetVConnection::net_read_io(NetHandler *nh)
477{
478 NetState *s = &this->read;
479 int64_t r = 0;
480
481 MUTEX_TRY_LOCK(lock, s->vio.mutex, thread);
482
483 if (!lock.is_locked()) {
484 read_reschedule(nh, this);
485 return;
486 }
487
488 // It is possible that the closed flag got set from HttpSessionManager in the
489 // global session pool case. If so, the closed flag should be stable once we get the
490 // s->vio.mutex (the global session pool mutex).
491 if (this->closed) {
492 this->nh->free_netevent(this);
493 return;
494 }
495 // if it is not enabled.
496 if (!s->enabled || s->vio.op != VIO::READ || s->vio.is_disabled()) {
497 read_disable(nh, this);
498 return;
499 }
500
501 MIOBufferAccessor &buf = s->vio.buffer;
502 ink_assert(buf.writer());
503
504 // if there is nothing to do, disable connection
505 int64_t ntodo = s->vio.ntodo();
506 if (ntodo <= 0) {
507 read_disable(nh, this);
508 return;
509 }
510 int64_t toread = buf.writer()->write_avail();
511 if (toread > ntodo) {
512 toread = ntodo;
513 }
514
515 // read data
516 int64_t rattempted = 0, total_read = 0;
517 unsigned niov = 0;
518 IOVec tiovec[NET_MAX_IOV];
519 if (toread) {
520 IOBufferBlock *b = buf.writer()->first_write_block();
521 do {
522 niov = 0;
523 rattempted = 0;
524 while (b && niov < NET_MAX_IOV) {
525 int64_t a = b->write_avail();
526 if (a > 0) {
527 tiovec[niov].iov_base = b->_end;
528 int64_t togo = toread - total_read - rattempted;
529 if (a > togo) {
530 a = togo;
531 }
532 tiovec[niov].iov_len = a;

Callers

nothing calls this directly

Calls 15

netActivityMethod · 0.95
read_rescheduleFunction · 0.85
read_disableFunction · 0.85
ink_zeroFunction · 0.85
ats_ip_sizeFunction · 0.85
incrementFunction · 0.85
read_signal_doneFunction · 0.85
read_signal_errorFunction · 0.85
read_signal_and_updateFunction · 0.85
free_neteventMethod · 0.80
is_disabledMethod · 0.80
ntodoMethod · 0.80

Tested by

no test coverage detected