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

Function TSPluginInit

example/plugins/c-api/thread_pool/psi.cc:961–1001  ·  view source on GitHub ↗

------------------------------------------------------------------------- TSPluginInit Function called at plugin init time Input: argc number of args argv list vof args Output : Return Value: -------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

959 Return Value:
960 -------------------------------------------------------------------------*/
961void
962TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
963{
964 TSPluginRegistrationInfo info;
965 int i;
966 TSReturnCode retval;
967
968 info.plugin_name = "psi";
969 info.vendor_name = "Apache";
970 info.support_email = "";
971
972 if (TSPluginRegister(&info) != TS_SUCCESS) {
973 TSError("[%s] Plugin registration failed", PLUGIN_NAME);
974 }
975
976 /* Initialize the psi directory = <plugin_path>/include */
977 snprintf(psi_directory, sizeof(psi_directory), "%s/%s", TSPluginDirGet(), PSI_PATH);
978
979 /* create an TSTextLogObject to log any psi include */
980 retval = TSTextLogObjectCreate("psi", TS_LOG_MODE_ADD_TIMESTAMP, &ts_log);
981 if (retval == TS_ERROR) {
982 TSError("[%s] Failed creating log for psi plugin", PLUGIN_NAME);
983 ts_log = nullptr;
984 }
985
986 /* Create working threads */
987 thread_init();
988 init_queue(&job_queue);
989
990 for (i = 0; i < NB_THREADS; i++) {
991 char *thread_name = static_cast<char *>(TSmalloc(64));
992 snprintf(thread_name, 64, "Thread[%d]", i);
993 if (!TSThreadCreate(thread_loop, thread_name)) {
994 TSError("[%s] Failed creating threads", PLUGIN_NAME);
995 return;
996 }
997 }
998
999 TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(read_response_handler, TSMutexCreate()));
1000 Dbg(dbg_ctl, "Plugin started");
1001}

Callers

nothing calls this directly

Calls 11

TSPluginRegisterFunction · 0.85
TSPluginDirGetFunction · 0.85
TSTextLogObjectCreateFunction · 0.85
thread_initFunction · 0.85
init_queueFunction · 0.85
TSmallocFunction · 0.85
TSThreadCreateFunction · 0.85
TSHttpHookAddFunction · 0.85
TSContCreateFunction · 0.85
TSMutexCreateFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected