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

Function TSPluginInit

tests/tools/plugins/continuations_verify.cc:143–190  ·  view source on GitHub ↗

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 */

Source from the content-addressed store, hash-verified

141 - Initializes all statistics as described in the README
142*/
143void
144TSPluginInit(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}

Callers

nothing calls this directly

Calls 8

TSPluginRegisterFunction · 0.85
TSContCreateFunction · 0.85
TSMutexCreateFunction · 0.85
abortFunction · 0.85
TSStatCreateFunction · 0.85
TSHttpHookAddFunction · 0.85
TSLifecycleHookAddFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected