-------------------------------------------------------------------------
| 279 | |
| 280 | //------------------------------------------------------------------------- |
| 281 | void |
| 282 | TSPluginInit(int argc, const char *argv[]) |
| 283 | { |
| 284 | Dbg(dbg_ctl, "TSPluginInit"); |
| 285 | |
| 286 | // register the plugin |
| 287 | TSPluginRegistrationInfo info; |
| 288 | info.plugin_name = "block_errors"; |
| 289 | info.vendor_name = "Apache Software Foundation"; |
| 290 | info.support_email = "dev@trafficserver.apache.org"; |
| 291 | |
| 292 | if (TSPluginRegister(&info) != TS_SUCCESS) { |
| 293 | TSError("Plugin registration failed"); |
| 294 | } |
| 295 | |
| 296 | // set the reset and timeout values |
| 297 | if (argc == 5) { |
| 298 | RESET_LIMIT = atoi(argv[1]); |
| 299 | TIMEOUT_CYCLES = atoi(argv[2]); |
| 300 | shutdown_connection = static_cast<bool>(atoi(argv[3])); |
| 301 | enabled = static_cast<bool>(atoi(argv[4])); |
| 302 | } else if (argc > 1 && argc < 5) { |
| 303 | Dbg(dbg_ctl, "block_errors: invalid number of arguments, using the defaults - usage: block_errors.so <reset limit> <timeout " |
| 304 | "cycles> <shutdown connection> <enabled>"); |
| 305 | TSError("block_errors: invalid number of arguments, using the defaults - usage: block_errors.so <reset limit> <timeout cycles> " |
| 306 | "<shutdown connection> <enabled>"); |
| 307 | } |
| 308 | |
| 309 | Dbg(dbg_ctl, "reset limit: %d per minute, timeout limit: %d minutes, shutdown connection: %d enabled: %d", RESET_LIMIT, |
| 310 | TIMEOUT_CYCLES, shutdown_connection, enabled); |
| 311 | |
| 312 | // create a stat counter |
| 313 | StatCountBlocks = TSStatCreate("block_errors.count", TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_COUNT); |
| 314 | |
| 315 | // register the hooks |
| 316 | TSHttpHookAdd(TS_VCONN_START_HOOK, TSContCreate(reinterpret_cast<TSEventFunc>(handle_start_hook), nullptr)); |
| 317 | TSHttpHookAdd(TS_HTTP_TXN_CLOSE_HOOK, TSContCreate(reinterpret_cast<TSEventFunc>(handle_close_hook), nullptr)); |
| 318 | TSLifecycleHookAdd(TS_LIFECYCLE_MSG_HOOK, TSContCreate(reinterpret_cast<TSEventFunc>(msg_hook), nullptr)); |
| 319 | |
| 320 | // schedule cleanup on task thread every 60 seconds |
| 321 | TSContScheduleEveryOnPool(TSContCreate((TSEventFunc)clean_table, TSMutexCreate()), 60 * 1000, TS_THREAD_POOL_TASK); |
| 322 | } |
nothing calls this directly
no test coverage detected