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

Function TSRemapNewInstance

include/cripts/Epilogue.hpp:796–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794}
795
796TSReturnCode
797TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSED */
798 ,
799 int /* errbuf_size ATS_UNUSED */)
800{
801 auto *inst = new cripts::Instance(argc, const_cast<const char **>(argv));
802 cripts::InstanceContext context(*inst);
803 bool needs_create_instance = wrap_create_instance(&context, false, CaseArg);
804
805 if (needs_create_instance) {
806 wrap_create_instance(&context, true, CaseArg);
807 }
808
809 if (!inst->Failed()) {
810 std::vector<cripts::Bundle::Error> errors;
811
812 for (auto &bundle : inst->bundles) {
813 // Collect all the callbacks needed from all bundles, and validate them
814 if (bundle->Validate(errors)) {
815 inst->NeedCallback(bundle->Callbacks());
816 }
817 }
818
819 if (!errors.empty()) {
820 TSError("[Cript: %s] - Failed to validate callbacks for the following bundles:", inst->plugin_debug_tag.c_str());
821
822 for (auto &err : errors) {
823 TSError("[Cript: %s] \tIn Bundle %.*s, option %.*s()", inst->plugin_debug_tag.c_str(),
824 static_cast<int>(err.Bundle().size()), err.Bundle().data(), static_cast<int>(err.Option().size()),
825 err.Option().data());
826 TSError("[Cript: %s] \t\t-> %.*s", inst->plugin_debug_tag.c_str(), static_cast<int>(err.Message().size()),
827 err.Message().data());
828 }
829 delete inst;
830 return TS_ERROR;
831 }
832
833 *ih = static_cast<void *>(inst);
834
835 inst->debug("Created a new instance for Cript = {}", inst->plugin_debug_tag);
836 inst->debug("The context data size = {}", sizeof(cripts::Context));
837
838 return TS_SUCCESS;
839 } else {
840 delete inst; // Cleanup the instance data, which can't be used now
841 return TS_ERROR;
842 }
843}
844
845void
846TSRemapDeleteInstance(void *ih)

Callers

nothing calls this directly

Calls 14

wrap_create_instanceFunction · 0.85
BundleMethod · 0.80
TSErrorFunction · 0.50
FailedMethod · 0.45
ValidateMethod · 0.45
NeedCallbackMethod · 0.45
CallbacksMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
OptionMethod · 0.45

Tested by

no test coverage detected