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

Method net_write_io

src/iocore/net/UnixNetVConnection.cc:635–850  ·  view source on GitHub ↗

Write the data for a UnixNetVConnection. Rescheduling the UnixNetVConnection when necessary.

Source from the content-addressed store, hash-verified

633// Rescheduling the UnixNetVConnection when necessary.
634//
635void
636UnixNetVConnection::net_write_io(NetHandler *nh)
637{
638 Metrics::Counter::increment(net_rsb.calls_to_writetonet);
639 NetState *s = &this->write;
640 Continuation *c = this->write.vio.cont;
641
642 if (c == nullptr) {
643 // If Continuation to callback is nullptr, we can do nothing
644 return;
645 }
646
647 MUTEX_TRY_LOCK(lock, s->vio.mutex, thread);
648
649 if (!lock.is_locked() || lock.get_mutex() != s->vio.mutex.get()) {
650 write_reschedule(nh, this);
651 return;
652 }
653
654 if (this->has_error()) {
655 this->lerrno = this->error;
656 write_signal_and_update(VC_EVENT_ERROR, this);
657 return;
658 }
659
660 // This function will always return true unless
661 // this vc is an SSLNetVConnection.
662 if (!this->getSSLHandShakeComplete()) {
663 if (this->trackFirstHandshake()) {
664 // Eat the first write-ready. Until the TLS handshake is complete,
665 // we should still be under the connect timeout and shouldn't bother
666 // the state machine until the TLS handshake is complete
667 this->write.triggered = 0;
668 nh->write_ready_list.remove(this);
669 }
670
671 int err, ret;
672
673 if (this->get_context() == NET_VCONNECTION_OUT) {
674 ret = this->sslStartHandShake(SSL_EVENT_CLIENT, err);
675 } else {
676 ret = this->sslStartHandShake(SSL_EVENT_SERVER, err);
677 }
678
679 if (ret == EVENT_ERROR) {
680 this->write.triggered = 0;
681 write_signal_error(nh, this, err);
682 } else if (ret == SSL_HANDSHAKE_WANT_READ || ret == SSL_HANDSHAKE_WANT_ACCEPT) {
683 this->read.triggered = 0;
684 nh->read_ready_list.remove(this);
685 read_reschedule(nh, this);
686 } else if (ret == SSL_HANDSHAKE_WANT_CONNECT || ret == SSL_HANDSHAKE_WANT_WRITE) {
687 this->write.triggered = 0;
688 nh->write_ready_list.remove(this);
689 write_reschedule(nh, this);
690 } else if (ret == EVENT_DONE) {
691 this->write.triggered = 1;
692 if (this->write.enabled) {

Callers 2

reenable_reMethod · 0.95
process_ready_listMethod · 0.80

Calls 15

trackFirstHandshakeMethod · 0.95
sslStartHandShakeMethod · 0.95
readSignalDoneMethod · 0.95
load_buffer_and_writeMethod · 0.95
netActivityMethod · 0.95
incrementFunction · 0.85
write_rescheduleFunction · 0.85
write_signal_and_updateFunction · 0.85
write_signal_errorFunction · 0.85
read_rescheduleFunction · 0.85
write_disableFunction · 0.85

Tested by

no test coverage detected