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

Method state_api_callout

src/proxy/ProxySession.cc:90–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88};
89
90int
91ProxySession::state_api_callout(int event, void *data)
92{
93 Event *e = static_cast<Event *>(data);
94 if (e == schedule_event) {
95 schedule_event = nullptr;
96 }
97
98 switch (event) {
99 case EVENT_NONE:
100 case EVENT_INTERVAL:
101 case TS_EVENT_HTTP_CONTINUE:
102 if (nullptr == cur_hook) {
103 /// Get the next hook to invoke from HttpHookState
104 cur_hook = hook_state.getNext();
105 }
106 if (nullptr != cur_hook) {
107 APIHook const *hook = cur_hook;
108
109 WEAK_MUTEX_TRY_LOCK(lock, hook->m_cont->mutex, mutex->thread_holding);
110
111 // Have a mutex but didn't get the lock, reschedule
112 if (!lock.is_locked()) {
113 SET_HANDLER(&ProxySession::state_api_callout);
114 if (!schedule_event) { // Don't bother if there is already one
115 schedule_event = mutex->thread_holding->schedule_in(this, HRTIME_MSECONDS(10));
116 }
117 return -1;
118 }
119
120 cur_hook = nullptr; // mark current callback at dispatched.
121 hook->invoke(eventmap[hook_state.id()], this);
122
123 return 0;
124 }
125
126 handle_api_return(event);
127 break;
128
129 case TS_EVENT_HTTP_ERROR:
130 this->handle_api_return(event);
131 break;
132
133 // coverity[unterminated_default]
134 default:
135 ink_release_assert(false);
136 }
137
138 return 0;
139}
140
141int
142ProxySession::do_api_callout(TSHttpHookID id)

Callers 1

do_api_calloutMethod · 0.95

Calls 5

handle_api_returnMethod · 0.95
getNextMethod · 0.45
schedule_inMethod · 0.45
invokeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected