Net Processor calls back, if succeeded, the net_vc is returned. Note here, even if the event is TS_EVENT_NET_CONNECT, it doesn't mean the net connection is set up because TSNetConnect is non-blocking. Do VConnWrite to the net_vc, if fails, that means there is no net connection. */
| 507 | Do VConnWrite to the net_vc, if fails, that means there is no net |
| 508 | connection. */ |
| 509 | int |
| 510 | state_connect_to_server(TSCont contp, TSEvent event, TSVConn vc) |
| 511 | { |
| 512 | TxnSM *txn_sm = static_cast<TxnSM *>(TSContDataGet(contp)); |
| 513 | |
| 514 | Dbg(dbg_ctl, "enter state_connect_to_server"); |
| 515 | |
| 516 | /* TSNetConnect failed. */ |
| 517 | if (event != TS_EVENT_NET_CONNECT) { |
| 518 | return prepare_to_die(contp); |
| 519 | } |
| 520 | txn_sm->q_pending_action = nullptr; |
| 521 | |
| 522 | txn_sm->q_server_vc = vc; |
| 523 | |
| 524 | /* server_vc will be used to write request and read response. */ |
| 525 | set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_send_request_to_server); |
| 526 | |
| 527 | /* Actively write the request to the net_vc. */ |
| 528 | txn_sm->q_server_write_vio = |
| 529 | TSVConnWrite(txn_sm->q_server_vc, contp, txn_sm->q_server_request_buffer_reader, strlen(txn_sm->q_client_request)); |
| 530 | return TS_SUCCESS; |
| 531 | } |
| 532 | |
| 533 | /* Net Processor calls back, if write complete, wait for the response |
| 534 | coming in, otherwise, reenable the write_vio. */ |
nothing calls this directly
no test coverage detected