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

Function transformHandler

plugins/esi/esi.cc:901–1030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

899}
900
901static int
902transformHandler(TSCont contp, TSEvent event, void *edata)
903{
904 TSVIO input_vio;
905 ContData *cont_data;
906 cont_data = static_cast<ContData *>(TSContDataGet(contp));
907
908 // we need these later, but declaring now avoid compiler warning w.r.t. goto
909 bool process_event = true;
910 bool shutdown, is_fetch_event;
911
912 if (!cont_data->initialized) {
913 if (!cont_data->init()) {
914 TSError("[esi][%s] Could not initialize continuation data; shutting down transformation", __FUNCTION__);
915 goto lShutdown;
916 }
917 CONT_DATA_DBG(cont_data, "[%s] initialized continuation data", __FUNCTION__);
918 }
919
920 cont_data->checkXformStatus();
921
922 is_fetch_event = cont_data->data_fetcher->isFetchEvent(event);
923
924 if (cont_data->xform_closed) {
925 CONT_DATA_DBG(cont_data, "[%s] Transformation closed, post-processing", __FUNCTION__);
926 if (cont_data->curr_state == ContData::PROCESSING_COMPLETE) {
927 CONT_DATA_DBG(cont_data, "[%s] Processing is complete, not processing current event %d", __FUNCTION__, event);
928 process_event = false;
929 } else if (cont_data->curr_state == ContData::READING_ESI_DOC) {
930 CONT_DATA_DBG(cont_data, "[%s] Parsing is incomplete, will force end of input", __FUNCTION__);
931 cont_data->curr_state = ContData::FETCHING_DATA;
932 }
933 if (cont_data->curr_state == ContData::FETCHING_DATA) { // retest as it may be modified in prev. if block
934 if (cont_data->data_fetcher->isFetchComplete()) {
935 CONT_DATA_DBG(cont_data, "[%s] Requested data has been fetched; will skip event and marking processing as complete ",
936 __FUNCTION__);
937 cont_data->curr_state = ContData::PROCESSING_COMPLETE;
938 process_event = false;
939 } else {
940 if (is_fetch_event) {
941 CONT_DATA_DBG(cont_data, "[%s] Going to process received data", __FUNCTION__);
942 } else {
943 // transformation is over, but data hasn't been fetched;
944 // let's wait for data to be fetched - we will be called
945 // by Fetch API and go through this loop again
946 CONT_DATA_DBG(cont_data, "[%s] Ignoring event %d; Will wait for pending data", __FUNCTION__, event);
947 process_event = false;
948 }
949 }
950 }
951 }
952
953 if (process_event) {
954 switch (event) {
955 case TS_EVENT_ERROR:
956 // doubt: what is this code doing?
957 input_vio = TSVConnWriteVIOGet(contp);
958 if (!input_vio) {

Callers

nothing calls this directly

Calls 15

TSContDataGetFunction · 0.85
TSVConnWriteVIOGetFunction · 0.85
TSContCallFunction · 0.85
TSVIOContGetFunction · 0.85
transformDataFunction · 0.85
TSVConnShutdownFunction · 0.85
TSContScheduleOnPoolFunction · 0.85
TSContDestroyFunction · 0.85
checkXformStatusMethod · 0.80
isFetchEventMethod · 0.80
isFetchCompleteMethod · 0.80

Tested by

no test coverage detected