MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / solve_module_dependencies

Function solve_module_dependencies

sr_module_deps.c:277–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277int solve_module_dependencies(struct sr_module *modules)
278{
279 struct sr_module_dep *md, *it;
280 struct sr_module *this, *mod;
281 enum module_type mod_type;
282 unsigned int dep_type;
283 int dep_solved;
284
285 /*
286 * now that we've loaded all shared libraries,
287 * we can attempt to solve each dependency
288 */
289 for (it = unsolved_deps.next; it; ) {
290 md = it;
291 it = it->next;
292
293 LM_DBG("solving dependency %s -> %s %.*s\n", md->mod->exports->name,
294 mod_type_to_string(md->mod_type), md->dep.len, md->dep.s);
295
296 this = md->mod;
297 dep_type = md->type;
298 int byname = !!md->dep.s;
299 mod_type = md->mod_type;
300
301 /*
302 * for generic dependencies (e.g. dialog depends on MOD_TYPE_SQLDB),
303 * first load all modules of given type
304 *
305 * re-purpose this @md structure by linking it into a module's
306 * list of dependencies (will be used at init time)
307 *
308 * md->mod used to point to (highlighted with []):
309 * [sr_module A] ---> "mod_name"
310 *
311 * now, the dependency is solved. md->mod will point to:
312 * sr_module A ---> [sr_module B]
313 */
314
315 for (dep_solved = 0, mod = modules; mod; mod = mod->next) {
316 if (!byname) {
317 if (mod == this || mod->exports->type != mod_type)
318 continue;
319 } else {
320 if (strcmp(mod->exports->name, md->dep.s) != 0)
321 continue;
322 if (mod->exports->type != mod_type)
323 LM_BUG("[%.*s %d] -> [%s %d]\n", md->dep.len, md->dep.s,
324 mod_type, mod->exports->name,
325 mod->exports->type);
326 }
327
328 if (!make_dep(md, dep_type, DEP_REVERSE_MINIT, this, mod))
329 return -1;
330 md = NULL;
331
332 if (!make_dep(NULL, dep_type, DEP_REVERSE_DESTROY, mod, this))
333 return -1;
334

Callers 2

mainFunction · 0.85
init_unit_testsFunction · 0.85

Calls 1

make_depFunction · 0.85

Tested by 1

init_unit_testsFunction · 0.68