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

Function TSPluginInit

plugins/stats_over_http/stats_over_http.cc:841–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841void
842TSPluginInit(int argc, const char *argv[])
843{
844 TSPluginRegistrationInfo info;
845
846 static const char usage[] = PLUGIN_NAME ".so [--integer-counters] [PATH]";
847 static const struct option longopts[] = {
848 {(char *)("integer-counters"), no_argument, nullptr, 'i'},
849 {(char *)("wrap-counters"), no_argument, nullptr, 'w'},
850 {nullptr, 0, nullptr, 0 }
851 };
852 TSCont main_cont, config_cont;
853 config_holder_t *config_holder;
854
855 info.plugin_name = PLUGIN_NAME;
856 info.vendor_name = "Apache Software Foundation";
857 info.support_email = "dev@trafficserver.apache.org";
858
859 if (TSPluginRegister(&info) != TS_SUCCESS) {
860 TSError("[%s] registration failed", PLUGIN_NAME);
861 goto done;
862 }
863
864 for (;;) {
865 switch (getopt_long(argc, (char *const *)argv, "iw", longopts, nullptr)) {
866 case 'i':
867 integer_counters = true;
868 break;
869 case 'w':
870 wrap_counters = true;
871 break;
872 case -1:
873 goto init;
874 default:
875 TSError("[%s] usage: %s", PLUGIN_NAME, usage);
876 }
877 }
878
879init:
880 argc -= optind;
881 argv += optind;
882
883 config_holder = new_config_holder(argc > 0 ? argv[0] : nullptr);
884
885 /* Path was not set during load, so the param was not a config file, we also
886 have an argument so it must be the path, set it here. Otherwise if no argument
887 then use the default _stats path */
888 if ((config_holder->config != nullptr) && (config_holder->config->stats_path.empty()) && (argc > 0) &&
889 (config_holder->config_path == nullptr)) {
890 config_holder->config->stats_path = argv[0] + ('/' == argv[0][0] ? 1 : 0);
891 } else if ((config_holder->config != nullptr) && (config_holder->config->stats_path.empty())) {
892 config_holder->config->stats_path = DEFAULT_URL_PATH;
893 }
894
895 /* Create a continuation with a mutex as there is a shared global structure
896 containing the headers to add */
897 main_cont = TSContCreate(stats_origin, nullptr);
898 TSContDataSet(main_cont, (void *)config_holder);

Callers

nothing calls this directly

Calls 10

TSPluginRegisterFunction · 0.85
new_config_holderFunction · 0.85
TSContCreateFunction · 0.85
TSContDataSetFunction · 0.85
TSHttpHookAddFunction · 0.85
TSMutexCreateFunction · 0.85
TSMgmtUpdateRegisterFunction · 0.85
TSErrorFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected