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

Function TSPluginInit

include/cripts/Epilogue.hpp:703–760  ·  view source on GitHub ↗

This sets up this Cript as a global plugin. This uses the glb_ prefix for all the callbacks. This would only be called if the cript is added to plugins.config.

Source from the content-addressed store, hash-verified

701// This sets up this Cript as a global plugin. This uses the glb_ prefix for all
702// the callbacks. This would only be called if the cript is added to plugins.config.
703void
704TSPluginInit(int argc, const char *argv[])
705{
706 static bool has_glb_txn_start = wrap_glb_txn_start(static_cast<cripts::Context *>(nullptr), false, CaseArg);
707 static unsigned enabled_txn_hooks =
708 (wrap_glb_read_request(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_READ_REQUEST :
709 cripts::Callbacks::NONE) |
710 (wrap_glb_pre_remap(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_PRE_REMAP :
711 cripts::Callbacks::NONE) |
712 (wrap_glb_post_remap(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_POST_REMAP :
713 cripts::Callbacks::NONE) |
714 (wrap_glb_cache_lookup(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_CACHE_LOOKUP :
715 cripts::Callbacks::NONE) |
716 (wrap_glb_send_request(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_SEND_REQUEST :
717 cripts::Callbacks::NONE) |
718 (wrap_glb_read_response(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_READ_RESPONSE :
719 cripts::Callbacks::NONE) |
720 (wrap_glb_send_response(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_SEND_RESPONSE :
721 cripts::Callbacks::NONE) |
722 (wrap_glb_txn_close(static_cast<cripts::Context *>(nullptr), false, CaseArg) ? cripts::Callbacks::GLB_TXN_CLOSE :
723 cripts::Callbacks::NONE);
724 // ToDo: Add more global hooks here in enabled_other_hooks
725
726 TSPluginRegistrationInfo info;
727 auto *inst = new cripts::Instance(argc, argv, false);
728
729 info.plugin_name = (char *)inst->plugin_debug_tag.c_str();
730 info.vendor_name = (char *)"Apache Software Foundation";
731 info.support_email = (char *)"dev@trafficserver.apache.org";
732
733 if (TS_SUCCESS != TSPluginRegister(&info)) {
734 TSError("[%s] plugin registration failed", info.plugin_name);
735 delete inst;
736 return;
737 }
738
739 // ToDo: This InstanceContext should also be usabled / used by other non-HTTP hooks.
740 auto *context = new cripts::InstanceContext(*inst);
741
742 pthread_once(&init_once_control, global_initialization);
743 bool needs_glb_init = wrap_glb_init(context, false, CaseArg);
744
745 if (needs_glb_init) {
746 wrap_glb_init(context, true, CaseArg);
747 }
748
749 if (has_glb_txn_start || enabled_txn_hooks > 0) {
750 auto contp = TSContCreate(global_cont, nullptr);
751
752 inst->NeedCallback(enabled_txn_hooks);
753 TSContDataSet(contp, context);
754 TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, contp); // This acts similarly to the DoRemap callback
755 } else {
756 delete context;
757 delete inst;
758 TSError("[%s] - No global hooks enabled", info.plugin_name);
759 }
760}

Callers

nothing calls this directly

Calls 15

wrap_glb_txn_startFunction · 0.85
wrap_glb_read_requestFunction · 0.85
wrap_glb_pre_remapFunction · 0.85
wrap_glb_post_remapFunction · 0.85
wrap_glb_cache_lookupFunction · 0.85
wrap_glb_send_requestFunction · 0.85
wrap_glb_read_responseFunction · 0.85
wrap_glb_send_responseFunction · 0.85
wrap_glb_txn_closeFunction · 0.85
TSPluginRegisterFunction · 0.85
wrap_glb_initFunction · 0.85
TSContCreateFunction · 0.85

Tested by

no test coverage detected