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

Function state_interface_with_server

example/plugins/c-api/protocol/TxnSM.cc:560–633  ·  view source on GitHub ↗

Call correct handler according to the vio type. */

Source from the content-addressed store, hash-verified

558
559/* Call correct handler according to the vio type. */
560int
561state_interface_with_server(TSCont contp, TSEvent event, TSVIO vio)
562{
563 TxnSM *txn_sm = static_cast<TxnSM *>(TSContDataGet(contp));
564
565 Dbg(dbg_ctl, "enter state_interface_with_server");
566
567 txn_sm->q_pending_action = nullptr;
568
569 switch (event) {
570 /* This is returned from cache_vc. */
571 case TS_EVENT_VCONN_WRITE_READY:
572 case TS_EVENT_VCONN_WRITE_COMPLETE:
573 return state_write_to_cache(contp, event, vio);
574 /* Otherwise, handle events from server. */
575 case TS_EVENT_VCONN_READ_READY:
576 /* Actually, we shouldn't get READ_COMPLETE because we set bytes
577 count to be INT64_MAX. */
578 case TS_EVENT_VCONN_READ_COMPLETE:
579 return state_read_response_from_server(contp, event, vio);
580
581 /* all data of the response come in. */
582 case TS_EVENT_VCONN_EOS:
583 Dbg(dbg_ctl, "get server eos");
584 /* There is no more use of server_vc, close it. */
585 if (txn_sm->q_server_vc) {
586 TSVConnClose(txn_sm->q_server_vc);
587 txn_sm->q_server_vc = nullptr;
588 }
589 txn_sm->q_server_read_vio = nullptr;
590 txn_sm->q_server_write_vio = nullptr;
591
592 /* Check if the response is good */
593 if (txn_sm->q_server_response_length == 0) {
594 /* This is the bad response. Close client_vc. */
595 if (txn_sm->q_client_vc) {
596 TSVConnClose(txn_sm->q_client_vc);
597 txn_sm->q_client_vc = nullptr;
598 }
599 txn_sm->q_client_read_vio = nullptr;
600 txn_sm->q_client_write_vio = nullptr;
601
602 /* Close cache_vc as well. */
603 if (txn_sm->q_cache_vc) {
604 TSVConnClose(txn_sm->q_cache_vc);
605 txn_sm->q_cache_vc = nullptr;
606 }
607 txn_sm->q_cache_write_vio = nullptr;
608 return state_done(contp, TS_EVENT_NONE, nullptr);
609 }
610
611 if (txn_sm->q_cache_response_length >= txn_sm->q_server_response_length) {
612 /* Write is complete, close the cache_vc. */
613 TSVConnClose(txn_sm->q_cache_vc);
614 txn_sm->q_cache_vc = nullptr;
615 txn_sm->q_cache_write_vio = nullptr;
616 TSIOBufferReaderFree(txn_sm->q_cache_response_buffer_reader);
617

Callers

nothing calls this directly

Calls 8

TSContDataGetFunction · 0.85
state_write_to_cacheFunction · 0.85
TSVConnCloseFunction · 0.85
state_doneFunction · 0.85
TSIOBufferReaderFreeFunction · 0.85
TSCacheReadFunction · 0.85
TSVIOReenableFunction · 0.85

Tested by

no test coverage detected