@@ -98,41 +98,6 @@ using lbw = ts::LocalBufferWriter<256>;
9898
9999namespace
100100{
101- // / Update the milestone state given the milestones and timer.
102- inline void
103- milestone_update_api_time (TransactionMilestones &milestones, ink_hrtime &api_timer)
104- {
105- // Bit of funkiness - we set @a api_timer to be the negative value when we're tracking
106- // non-active API time. In that case we need to make a note of it and flip the value back
107- // to positive.
108- if (api_timer) {
109- ink_hrtime delta;
110- bool active = api_timer >= 0 ;
111- if (!active) {
112- api_timer = -api_timer;
113- }
114- delta = Thread::get_hrtime_updated () - api_timer;
115- api_timer = 0 ;
116- // Zero or negative time is a problem because we want to signal *something* happened
117- // vs. no API activity at all. This can happen due to graininess or real time
118- // clock adjustment.
119- if (delta <= 0 ) {
120- delta = 1 ;
121- }
122-
123- if (0 == milestones[TS_MILESTONE_PLUGIN_TOTAL]) {
124- milestones[TS_MILESTONE_PLUGIN_TOTAL] = milestones[TS_MILESTONE_SM_START];
125- }
126- milestones[TS_MILESTONE_PLUGIN_TOTAL] += delta;
127- if (active) {
128- if (0 == milestones[TS_MILESTONE_PLUGIN_ACTIVE]) {
129- milestones[TS_MILESTONE_PLUGIN_ACTIVE] = milestones[TS_MILESTONE_SM_START];
130- }
131- milestones[TS_MILESTONE_PLUGIN_ACTIVE] += delta;
132- }
133- }
134- }
135-
136101// Unique state machine identifier
137102std::atomic<int64_t > next_sm_id (0 );
138103
@@ -1449,7 +1414,7 @@ HttpSM::state_common_wait_for_transform_read(HttpTransformInfo *t_info, HttpSMHa
14491414// with setting and changing the default_handler
14501415// function. As such, this is an entry point
14511416// and needs to handle the reentrancy counter and
1452- // deallocation the state machine if necessary
1417+ // deallocation of the state machine if necessary
14531418//
14541419int
14551420HttpSM::state_api_callback (int event, void *data)
@@ -1459,7 +1424,7 @@ HttpSM::state_api_callback(int event, void *data)
14591424 ink_assert (reentrancy_count >= 0 );
14601425 reentrancy_count++;
14611426
1462- milestone_update_api_time (milestones, api_timer );
1427+ this -> milestone_update_api_time ();
14631428
14641429 STATE_ENTER (&HttpSM::state_api_callback, event);
14651430
@@ -1509,7 +1474,7 @@ HttpSM::state_api_callout(int event, void *data)
15091474 // the transaction got an event without the plugin calling TsHttpTxnReenable().
15101475 // The call chain does not recurse here if @a api_timer < 0 which means this call
15111476 // is the first from an event dispatch in this case.
1512- milestone_update_api_time (milestones, api_timer );
1477+ this -> milestone_update_api_time ();
15131478 }
15141479
15151480 switch (event) {
@@ -1586,7 +1551,7 @@ plugins required to work with sni_routing.
15861551
15871552 hook->invoke (TS_EVENT_HTTP_READ_REQUEST_HDR + cur_hook_id, this );
15881553 if (api_timer > 0 ) { // true if the hook did not call TxnReenable()
1589- milestone_update_api_time (milestones, api_timer );
1554+ this -> milestone_update_api_time ();
15901555 api_timer = -Thread::get_hrtime (); // set in order to track non-active callout duration
15911556 // which means that if we get back from the invoke with api_timer < 0 we're already
15921557 // tracking a non-complete callout from a chain so just let it ride. It will get cleaned
@@ -8514,3 +8479,38 @@ HttpSM::get_server_version(HTTPHdr &hdr) const
85148479{
85158480 return this ->server_txn ->get_proxy_ssn ()->get_version (hdr);
85168481}
8482+
8483+ // / Update the milestone state given the milestones and timer.
8484+ void
8485+ HttpSM::milestone_update_api_time ()
8486+ {
8487+ // Bit of funkiness - we set @a api_timer to be the negative value when we're tracking
8488+ // non-active API time. In that case we need to make a note of it and flip the value back
8489+ // to positive.
8490+ if (api_timer) {
8491+ ink_hrtime delta;
8492+ bool active = api_timer >= 0 ;
8493+ if (!active) {
8494+ api_timer = -api_timer;
8495+ }
8496+ delta = Thread::get_hrtime_updated () - api_timer;
8497+ api_timer = 0 ;
8498+ // Zero or negative time is a problem because we want to signal *something* happened
8499+ // vs. no API activity at all. This can happen due to graininess or real time
8500+ // clock adjustment.
8501+ if (delta <= 0 ) {
8502+ delta = 1 ;
8503+ }
8504+
8505+ if (0 == milestones[TS_MILESTONE_PLUGIN_TOTAL]) {
8506+ milestones[TS_MILESTONE_PLUGIN_TOTAL] = milestones[TS_MILESTONE_SM_START];
8507+ }
8508+ milestones[TS_MILESTONE_PLUGIN_TOTAL] += delta;
8509+ if (active) {
8510+ if (0 == milestones[TS_MILESTONE_PLUGIN_ACTIVE]) {
8511+ milestones[TS_MILESTONE_PLUGIN_ACTIVE] = milestones[TS_MILESTONE_SM_START];
8512+ }
8513+ milestones[TS_MILESTONE_PLUGIN_ACTIVE] += delta;
8514+ }
8515+ }
8516+ }
0 commit comments