| 828 | } |
| 829 | |
| 830 | void |
| 831 | TSPluginInit(int argc, const char *argv[]) |
| 832 | { |
| 833 | TSPluginRegistrationInfo info; |
| 834 | |
| 835 | info.plugin_name = "ts_lua"; |
| 836 | info.vendor_name = "Apache Software Foundation"; |
| 837 | info.support_email = "dev@trafficserver.apache.org"; |
| 838 | |
| 839 | if (TSPluginRegister(&info) != TS_SUCCESS) { |
| 840 | TSError("[ts_lua][%s] Plugin registration failed", __FUNCTION__); |
| 841 | } |
| 842 | |
| 843 | if (nullptr == ts_lua_g_main_ctx_array) { |
| 844 | ts_lua_g_main_ctx_array = create_lua_vms(); |
| 845 | if (nullptr != ts_lua_g_main_ctx_array) { |
| 846 | pthread_key_create(&lua_g_state_key, nullptr); |
| 847 | |
| 848 | TSCont const contp = TSContCreate(lifecycleHandler, TSMutexCreate()); |
| 849 | TSContDataSet(contp, ts_lua_g_main_ctx_array); |
| 850 | TSLifecycleHookAdd(TS_LIFECYCLE_MSG_HOOK, contp); |
| 851 | |
| 852 | ts_lua_plugin_stats *const plugin_stats = create_plugin_stats(ts_lua_g_main_ctx_array, ts_lua_g_stat_strs); |
| 853 | |
| 854 | if (nullptr != plugin_stats) { |
| 855 | TSCont const scontp = TSContCreate(statsHandler, TSMutexCreate()); |
| 856 | TSContDataSet(scontp, plugin_stats); |
| 857 | TSContScheduleOnPool(scontp, TS_LUA_STATS_TIMEOUT, TS_THREAD_POOL_TASK); |
| 858 | } |
| 859 | } else { |
| 860 | return; |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | int states = ts_lua_max_state_count; |
| 865 | |
| 866 | int jit = 1; |
| 867 | int reload = 0; |
| 868 | static const struct option longopt[] = { |
| 869 | {"states", required_argument, 0, 's'}, |
| 870 | {"jit", required_argument, 0, 'j'}, |
| 871 | {"enable-reload", no_argument, 0, 'r'}, |
| 872 | {0, 0, 0, 0 }, |
| 873 | }; |
| 874 | |
| 875 | for (;;) { |
| 876 | int opt; |
| 877 | |
| 878 | opt = getopt_long(argc, (char *const *)argv, "", longopt, nullptr); |
| 879 | switch (opt) { |
| 880 | case 's': |
| 881 | states = atoi(optarg); |
| 882 | // set state |
| 883 | break; |
| 884 | case 'j': |
| 885 | jit = atoi(optarg); |
| 886 | if (jit == 0) { |
| 887 | Dbg(dbg_ctl, "[%s] disable JIT mode", __FUNCTION__); |
nothing calls this directly
no test coverage detected