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

Method initInstance

src/proxy/http/remap/RemapPluginInfo.cc:165–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165bool
166RemapPluginInfo::initInstance(int argc, char **argv, void **ih, std::string &error)
167{
168 TSReturnCode res = TS_SUCCESS;
169 bool result = true;
170
171 PluginDbg(_dbg_ctl(), "started initializing instance of plugin '%s'", _configPath.c_str());
172
173 /* A buffer to get the error from the plugin instance init function, be defensive here. */
174 char tmpbuf[2048];
175 ink_zero(tmpbuf);
176
177 if (new_instance_cb) {
178#if defined(freebsd) || defined(darwin)
179 optreset = 1;
180#endif
181#if defined(__GLIBC__)
182 optind = 0;
183#else
184 optind = 1;
185#endif
186 opterr = 0;
187 optarg = nullptr;
188
189 setPluginContext();
190
191 res = new_instance_cb(argc, argv, ih, tmpbuf, sizeof(tmpbuf) - 1);
192
193 resetPluginContext();
194
195 if (TS_SUCCESS != res) {
196 error.assign("failed to create instance for plugin ")
197 .append(_configPath.string())
198 .append(": ")
199 .append(tmpbuf[0] ? tmpbuf : "Unknown plugin error");
200 result = false;
201 }
202 }
203
204 PluginDbg(_dbg_ctl(), "finished initializing instance of plugin '%s'", _configPath.c_str());
205
206 return result;
207}
208
209void
210RemapPluginInfo::doneInstance(void *ih)

Callers 2

initMethod · 0.80

Calls 5

ink_zeroFunction · 0.85
c_strMethod · 0.45
appendMethod · 0.45
assignMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected