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

Function handleEvents

src/tscpp/api/InterceptPlugin.cc:356–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354};
355
356int
357handleEvents(TSCont cont, TSEvent pristine_event, void *pristine_edata)
358{
359 // Separating pristine and mutable data helps debugging
360 TSEvent event = pristine_event;
361 void *edata = pristine_edata;
362
363 InterceptPlugin::State *state = static_cast<InterceptPlugin::State *>(TSContDataGet(cont));
364 if (!state) { // plugin is done, return.
365 return 0;
366 }
367
368 TryLockGuard scopedTryLock(*(state->plugin_mutex_));
369 if (!scopedTryLock.isLocked()) {
370 LOG_ERROR("Couldn't get plugin lock. Will retry");
371 if (event != TS_EVENT_TIMEOUT) { // save only "non-retry" info
372 state->saved_event_ = event;
373 state->saved_edata_ = edata;
374 }
375 state->timeout_action_ = TSContScheduleOnPool(cont, 1, TS_THREAD_POOL_NET);
376 return 0;
377 }
378 if (event == TS_EVENT_TIMEOUT) { // we have a saved event to restore
379 state->timeout_action_ = nullptr;
380 if (state->plugin_io_done_) { // plugin is done, so can't send it saved event
381 event = TS_EVENT_VCONN_EOS; // fake completion
382 edata = nullptr;
383 } else {
384 event = state->saved_event_;
385 edata = state->saved_edata_;
386 }
387 }
388 if (state->plugin_) {
389 utils::internal::dispatchInterceptEvent(state->plugin_, event, edata);
390 } else { // plugin was destroyed before intercept was completed; cleaning up here
391 LOG_DEBUG("Cleaning up as intercept plugin is already destroyed");
392 destroyCont(state);
393 TSContDataSet(cont, nullptr);
394 delete state;
395 }
396 return 0;
397}
398
399void
400destroyCont(InterceptPlugin::State *state)

Callers

nothing calls this directly

Calls 5

TSContDataGetFunction · 0.85
TSContScheduleOnPoolFunction · 0.85
destroyContFunction · 0.85
TSContDataSetFunction · 0.85
isLockedMethod · 0.80

Tested by

no test coverage detected