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

Function TSRemapInit

tests/gold_tests/pluginTest/tsapi/test_tsapi.cc:253–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251} // end anonymous namespace
252
253TSReturnCode
254TSRemapInit(TSRemapInterface *api_info, char * /* errbuf ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */)
255{
256 Dbg(dbg_ctl, "TSRemapInit()");
257
258 SpecificDbg(true, off_dbg_ctl, "Should see this");
259 SpecificDbg(false, dbg_ctl, "Should see this");
260 SpecificDbg(false, off_dbg_ctl, "Should NOT see this");
261
262 TSReleaseAssert(api_info != nullptr);
263 TSReleaseAssert(api_info->size == sizeof(TSRemapInterface));
264 TSReleaseAssert(api_info->tsremap_version == TSREMAP_VERSION);
265
266 const char *fileSpec = std::getenv("OUTPUT_FILE");
267
268 if (nullptr == fileSpec) {
269 TSError(PINAME ": Environment variable OUTPUT_FILE not found.");
270
271 return TS_ERROR;
272 }
273
274 // Disable output buffering for logFile, so that explicit flushing is not necessary.
275 logFile.rdbuf()->pubsetbuf(nullptr, 0);
276
277 logFile.open(fileSpec, std::ios::out);
278 if (!logFile.is_open()) {
279 TSError(PINAME ": could not open log file \"%s\"", fileSpec);
280
281 return TS_ERROR;
282 }
283
284 // Mutex to protect the logFile object.
285 //
286 TSMutex mtx = TSMutexCreate();
287
288 gCont = TSContCreate(globalContFunc, mtx);
289
290 TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, gCont);
291 TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, gCont);
292 TSHttpHookAdd(TS_HTTP_SEND_REQUEST_HDR_HOOK, gCont);
293
294 tCont = TSContCreate(transactionContFunc, mtx);
295 return TS_SUCCESS;
296}
297
298TSReturnCode
299TSRemapNewInstance(int argc, char *argv[], void **instance, char *errbuf, int errbuf_size)

Callers

nothing calls this directly

Calls 6

TSMutexCreateFunction · 0.85
TSContCreateFunction · 0.85
TSHttpHookAddFunction · 0.85
TSErrorFunction · 0.50
openMethod · 0.45
is_openMethod · 0.45

Tested by

no test coverage detected