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

Function TSRemapInit

plugins/lua/ts_lua.cc:306–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306TSReturnCode
307TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
308{
309 if (!api_info || api_info->size < sizeof(TSRemapInterface)) {
310 strncpy(errbuf, "[TSRemapInit] - Incorrect size of TSRemapInterface structure", errbuf_size - 1);
311 errbuf[errbuf_size - 1] = '\0';
312 return TS_ERROR;
313 }
314
315 if (nullptr == ts_lua_main_ctx_array) {
316 ts_lua_main_ctx_array = create_lua_vms();
317 if (nullptr != ts_lua_main_ctx_array) {
318 pthread_key_create(&lua_state_key, nullptr);
319
320 TSCont const lcontp = TSContCreate(lifecycleHandler, TSMutexCreate());
321 TSContDataSet(lcontp, ts_lua_main_ctx_array);
322 TSLifecycleHookAdd(TS_LIFECYCLE_MSG_HOOK, lcontp);
323
324 ts_lua_plugin_stats *const plugin_stats = create_plugin_stats(ts_lua_main_ctx_array, ts_lua_stat_strs);
325
326 // start the stats management
327 if (nullptr != plugin_stats) {
328 Dbg(dbg_ctl, "Starting up stats management continuation");
329 TSCont const scontp = TSContCreate(statsHandler, TSMutexCreate());
330 TSContDataSet(scontp, plugin_stats);
331 TSContScheduleOnPool(scontp, TS_LUA_STATS_TIMEOUT, TS_THREAD_POOL_TASK);
332 }
333 } else {
334 return TS_ERROR;
335 }
336 }
337
338 return TS_SUCCESS;
339}
340
341TSReturnCode
342TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size)

Callers

nothing calls this directly

Calls 7

create_lua_vmsFunction · 0.85
TSContCreateFunction · 0.85
TSMutexCreateFunction · 0.85
TSContDataSetFunction · 0.85
TSLifecycleHookAddFunction · 0.85
TSContScheduleOnPoolFunction · 0.85
create_plugin_statsFunction · 0.70

Tested by

no test coverage detected