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

Function ts_lua_sleep

plugins/lua/ts_lua_misc.cc:432–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432static int
433ts_lua_sleep(lua_State *L)
434{
435 int sec;
436 TSAction action;
437 TSCont contp;
438 ts_lua_async_item *ai;
439 ts_lua_cont_info *ci;
440
441 ci = ts_lua_get_cont_info(L);
442 if (ci == nullptr) {
443 TSError("[ts_lua][%s] no cont info found", __FUNCTION__);
444 TSReleaseAssert(!"Unexpected fetch of cont info");
445 return 0;
446 }
447
448 sec = luaL_checknumber(L, 1);
449 if (sec < 1) {
450 sec = 1;
451 }
452
453 contp = TSContCreate(ts_lua_sleep_handler, ci->mutex);
454 action = TSContScheduleOnPool(contp, sec * 1000, TS_THREAD_POOL_NET);
455
456 ai = ts_lua_async_create_item(contp, ts_lua_sleep_cleanup, (void *)action, ci);
457 TSContDataSet(contp, ai);
458
459 return lua_yield(L, 0);
460}
461
462static int
463ts_lua_sleep_handler(TSCont contp, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)

Callers

nothing calls this directly

Calls 6

ts_lua_get_cont_infoFunction · 0.85
TSContCreateFunction · 0.85
TSContScheduleOnPoolFunction · 0.85
ts_lua_async_create_itemFunction · 0.85
TSContDataSetFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected