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

Function state_start

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

This function starts to read incoming client request data from client_vc */

Source from the content-addressed store, hash-verified

152
153/* This function starts to read incoming client request data from client_vc */
154int
155state_start(TSCont contp, TSEvent event ATS_UNUSED, void *data ATS_UNUSED)
156{
157 TxnSM *txn_sm = static_cast<TxnSM *>(TSContDataGet(contp));
158
159 if (!txn_sm->q_client_vc) {
160 return prepare_to_die(contp);
161 }
162
163 txn_sm->q_client_request_buffer = TSIOBufferCreate();
164 if (!txn_sm->q_client_request_buffer) {
165 return prepare_to_die(contp);
166 }
167 txn_sm->q_client_request_buffer_reader = TSIOBufferReaderAlloc(txn_sm->q_client_request_buffer);
168 if (!txn_sm->q_client_request_buffer_reader) {
169 return prepare_to_die(contp);
170 }
171
172 /* Now the IOBuffer and IOBufferReader is ready, the data from
173 client_vc can be read into the IOBuffer. Since we don't know
174 the size of the client request, set the expecting size to be
175 INT64_MAX, so that we will always get TS_EVENT_VCONN_READ_READY
176 event, but never TS_EVENT_VCONN_READ_COMPLETE event. */
177 set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_interface_with_client);
178 txn_sm->q_client_read_vio = TSVConnRead(txn_sm->q_client_vc, contp, txn_sm->q_client_request_buffer, INT64_MAX);
179
180 return TS_SUCCESS;
181}
182
183/* This function is to call proper functions according to the
184 VIO argument. If it's read_vio, which means reading request from

Callers

nothing calls this directly

Calls 5

TSContDataGetFunction · 0.85
prepare_to_dieFunction · 0.85
TSIOBufferCreateFunction · 0.85
TSIOBufferReaderAllocFunction · 0.85
TSVConnReadFunction · 0.85

Tested by

no test coverage detected