void TSPluginInit(int argc, const char *argv[]) { TSPluginRegistrationInfo info; TSThread init_thread; TSCont cont; info.plugin_name = (char *)"ironbee"; info.vendor_name = (char *)"Qualys, Inc"; info.support_email = (char *)"*****@*****.**"; if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) { TSError("[ironbee] Plugin registration failed. IronBee disabled"); return; } if (!check_ts_version()) { TSError("[ironbee] Plugin requires Traffic Server 3.0 or later. IronBee disabled"); return; } if (read_ibconf(&module_data, argc, argv) != IB_OK) { TSError("[ironbee] Bad Ironbee options. IronBee disabled"); return; } if (tsib_pre_init(&cont) != IB_OK) { TSError("[ironbee] Pre-config failed. IronBee disabled"); return; } /* Launch potentially-slow config in its own thread */ init_thread = TSThreadCreate(ibinit, cont); assert(init_thread != NULL); }
/*------------------------------------------------------------------------- TSPluginInit Function called at plugin init time Input: argc number of args argv list vof args Output : Return Value: -------------------------------------------------------------------------*/ void TSPluginInit(int argc, const char *argv[]) { TSPluginRegistrationInfo info; int i; TSReturnCode retval; info.plugin_name = "psi"; info.vendor_name = "Apache"; info.support_email = ""; if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) { TSError("Plugin registration failed.\n"); } if (!check_ts_version()) { TSError("Plugin requires Traffic Server 3.0 or later\n"); return; } /* Initialize the psi directory = <plugin_path>/include */ sprintf(psi_directory, "%s/%s", TSPluginDirGet(), PSI_PATH); /* create an TSTextLogObject to log any psi include */ retval = TSTextLogObjectCreate("psi", TS_LOG_MODE_ADD_TIMESTAMP, &log); if (retval == TS_ERROR) { TSError("Failed creating log for psi plugin"); log = NULL; } /* Create working threads */ thread_init(); init_queue(&job_queue); for (i = 0; i < NB_THREADS; i++) { char *thread_name = (char *) TSmalloc(64); sprintf(thread_name, "Thread[%d]", i); if (!TSThreadCreate((TSThreadFunc) thread_loop, thread_name)) { TSError("[TSPluginInit] Error while creating threads"); return; } } TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(read_response_handler, TSMutexCreate())); TSDebug(DBG_TAG, "Plugin started"); }
static int thread_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata) { switch (event) { case TS_EVENT_HTTP_OS_DNS: /** * Check if the thread has been created successfully or not. * If the thread has not been created successfully, assert. */ if (!TSThreadCreate(reenable_txn, edata)) { TSReleaseAssert(!"Failure in thread creation"); } return 0; default: break; } return 0; }
/* Initialize the plugin / global continuation hook */ void TSPluginInit(int argc, const char *argv[]) { TSPluginRegistrationInfo info; if (2 != argc) { TSError("Must specify a configuration file.\n"); return; } info.plugin_name = "health_checks"; info.vendor_name = "Apache Software Foundation"; info.support_email = "*****@*****.**"; if (TS_SUCCESS != TSPluginRegister(TS_SDK_VERSION_3_0, &info)) { TSError("Plugin registration failed. \n"); return; } if (!check_ts_version()) { TSError("Plugin requires Traffic Server 3.0 or later\n"); return; } /* This will update the global configuration file, and is not reloaded at run time */ /* ToDo: Support reloading with traffic_line -x ? */ if (NULL == (g_config = parse_configs(argv[1]))) { TSError("Unable to read / parse %s config file", argv[1]); return; } /* Setup the background thread */ if (!TSThreadCreate(hc_thread, NULL)) { TSError("Failure in thread creation"); return; } /* Create a continuation with a mutex as there is a shared global structure containing the headers to add */ TSDebug(PLUGIN_NAME, "Started %s plugin", PLUGIN_NAME); TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(health_check_origin, NULL)); }