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

Function ts_lua_host_lookup

plugins/lua/ts_lua_misc.cc:493–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493static int
494ts_lua_host_lookup(lua_State *L)
495{
496 const char *host;
497 size_t host_len = 0;
498 TSAction action;
499 TSCont contp;
500 ts_lua_async_item *ai;
501 ts_lua_cont_info *ci;
502
503 ci = ts_lua_get_cont_info(L);
504 if (ci == nullptr) {
505 TSError("[ts_lua][%s] no cont info found", __FUNCTION__);
506 TSReleaseAssert(!"Unexpected fetch of cont info");
507 return 0;
508 }
509
510 if (lua_gettop(L) != 1) {
511 TSError("[ts_lua][%s] ts.host_lookup need at least one parameter", __FUNCTION__);
512 return 0;
513 }
514
515 host = luaL_checklstring(L, 1, &host_len);
516
517 contp = TSContCreate(ts_lua_host_lookup_handler, ci->mutex);
518 ai = ts_lua_async_create_item(contp, ts_lua_host_lookup_cleanup, nullptr, ci);
519
520 TSContDataSet(contp, ai);
521 action = TSHostLookup(contp, host, host_len);
522 if (!TSActionDone(action)) {
523 ai->data = (void *)action;
524 return lua_yield(L, 0);
525 }
526
527 return 1;
528}
529
530static int
531ts_lua_host_lookup_handler(TSCont contp, TSEvent event, void *edata)

Callers

nothing calls this directly

Calls 7

ts_lua_get_cont_infoFunction · 0.85
TSContCreateFunction · 0.85
ts_lua_async_create_itemFunction · 0.85
TSContDataSetFunction · 0.85
TSHostLookupFunction · 0.85
TSActionDoneFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected