| 669 | */ |
| 670 | |
| 671 | static int init_mod_child( struct sr_module* m, int rank, char *type, |
| 672 | int skip_others) |
| 673 | { |
| 674 | struct sr_module_dep *dep; |
| 675 | |
| 676 | if (!m || m->init_child_done) |
| 677 | return 0; |
| 678 | |
| 679 | /* iterate through the list; if error occurs, |
| 680 | propagate it up the stack */ |
| 681 | if (!skip_others && init_mod_child(m->next, rank, type, 0) != 0) |
| 682 | return -1; |
| 683 | |
| 684 | for (dep = m->sr_deps_cinit; dep; dep = dep->next) |
| 685 | if (!dep->mod->init_child_done) |
| 686 | if (init_mod_child(dep->mod, rank, type, 1) != 0) |
| 687 | return -1; |
| 688 | |
| 689 | if (m->init_child_done) |
| 690 | return 0; |
| 691 | |
| 692 | if (m->exports && m->exports->init_child_f) { |
| 693 | LM_DBG("type=%s, rank=%d, module=%s\n", |
| 694 | type, rank, m->exports->name); |
| 695 | if (m->exports->init_child_f(rank)<0) { |
| 696 | LM_ERR("failed to initializing module %s, rank %d\n", |
| 697 | m->exports->name,rank); |
| 698 | return -1; |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | m->init_child_done = 1; |
| 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | |
| 707 | /* |