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

Method milestone_update_api_time

src/proxy/http/HttpSM.cc:8862–8892  ·  view source on GitHub ↗

Update the milestone state given the milestones and timer.

Source from the content-addressed store, hash-verified

8860
8861/// Update the milestone state given the milestones and timer.
8862void
8863HttpSM::milestone_update_api_time()
8864{
8865 // Bit of funkiness - we set @a api_timer to be the negative value when we're tracking
8866 // non-active API time. In that case we need to make a note of it and flip the value back
8867 // to positive.
8868 if (api_timer) {
8869 ink_hrtime delta;
8870 bool active = api_timer >= 0;
8871 if (!active) {
8872 api_timer = -api_timer;
8873 }
8874 // Zero or negative time is a problem because we want to signal *something* happened
8875 // vs. no API activity at all. This can happen due to graininess or real time
8876 // clock adjustment.
8877 delta = std::max<ink_hrtime>(1, ink_get_hrtime() - api_timer);
8878 api_timer = 0;
8879
8880 if (0 == milestones[TS_MILESTONE_PLUGIN_TOTAL]) {
8881 milestones[TS_MILESTONE_PLUGIN_TOTAL] = milestones[TS_MILESTONE_SM_START];
8882 }
8883 milestones[TS_MILESTONE_PLUGIN_TOTAL] += delta;
8884 if (active) {
8885 if (0 == milestones[TS_MILESTONE_PLUGIN_ACTIVE]) {
8886 milestones[TS_MILESTONE_PLUGIN_ACTIVE] = milestones[TS_MILESTONE_SM_START];
8887 }
8888 milestones[TS_MILESTONE_PLUGIN_ACTIVE] += delta;
8889 }
8890 this_ethread()->metrics.record_api_time(delta);
8891 }
8892}

Callers 2

state_api_callbackMethod · 0.95
state_api_calloutMethod · 0.95

Calls 3

ink_get_hrtimeFunction · 0.85
this_ethreadFunction · 0.85
record_api_timeMethod · 0.80

Tested by

no test coverage detected