Entry point for the plugin. - Attaches global hooks for session start and close. - Attaches global hooks for transaction start and close. - Attaches lifecycle hook for communication through traffic_ctl - Initializes all statistics as described in the README */
| 141 | - Initializes all statistics as described in the README |
| 142 | */ |
| 143 | void |
| 144 | TSPluginInit(int /* argc ATS_UNUSED */, const char ** /* argv ATS_UNUSED */) |
| 145 | { |
| 146 | Dbg(dbg_ctl_init, "initializing plugin"); |
| 147 | |
| 148 | TSPluginRegistrationInfo info; |
| 149 | |
| 150 | info.plugin_name = plugin_name; |
| 151 | info.vendor_name = vendor_name; |
| 152 | info.support_email = support_email; |
| 153 | |
| 154 | if (TSPluginRegister(&info) != TS_SUCCESS) { |
| 155 | TSError("[%s] Plugin registration failed. \n", plugin_name); |
| 156 | } |
| 157 | |
| 158 | TSCont contp_1 = TSContCreate(handle_order_1, TSMutexCreate()); |
| 159 | TSCont contp_2 = TSContCreate(handle_order_2, TSMutexCreate()); |
| 160 | TSCont contp = TSContCreate(handle_msg, TSMutexCreate()); |
| 161 | |
| 162 | if (contp_1 == nullptr || contp_2 == nullptr || contp == nullptr) { |
| 163 | // Continuation initialization failed. Unrecoverable, report and exit. |
| 164 | TSError("[%s] could not create continuation", plugin_name); |
| 165 | abort(); |
| 166 | } else { |
| 167 | // Continuation initialization succeeded. |
| 168 | |
| 169 | stat_txn_close_1 = |
| 170 | TSStatCreate("continuations_verify.txn.close.1", TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM); |
| 171 | stat_ssn_close_1 = |
| 172 | TSStatCreate("continuations_verify.ssn.close.1", TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM); |
| 173 | stat_txn_close_2 = |
| 174 | TSStatCreate("continuations_verify.txn.close.2", TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM); |
| 175 | stat_ssn_close_2 = |
| 176 | TSStatCreate("continuations_verify.ssn.close.2", TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM); |
| 177 | stat_test_done = |
| 178 | TSStatCreate("continuations_verify.test.done", TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM); |
| 179 | |
| 180 | // Add all hooks. |
| 181 | TSHttpHookAdd(TS_HTTP_TXN_CLOSE_HOOK, contp_1); |
| 182 | TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, contp_1); |
| 183 | |
| 184 | TSHttpHookAdd(TS_HTTP_TXN_CLOSE_HOOK, contp_2); |
| 185 | TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, contp_2); |
| 186 | |
| 187 | // Respond to a traffic_ctl message |
| 188 | TSLifecycleHookAdd(TS_LIFECYCLE_MSG_HOOK, contp); |
| 189 | } |
| 190 | } |
nothing calls this directly
no test coverage detected