diff options
author | Volker Lendecke <vl@samba.org> | 2018-02-26 12:59:06 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-03-01 09:53:45 +0100 |
commit | 94c02211f92000d84efabac98cc6f3341a49ae76 (patch) | |
tree | 64757caeb5a4f6ddd32c036d66597e60fafc33d9 /source3 | |
parent | 4f76a1deae60f7725f7e4307549de3d097a59236 (diff) | |
download | samba-94c02211f92000d84efabac98cc6f3341a49ae76.tar.gz |
winbind: Use forall_children in winbind_child_died()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13309
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/winbindd/winbindd_dual.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index d3453346ef1..3c949d943f9 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -772,29 +772,42 @@ void setup_child(struct winbindd_domain *domain, struct winbindd_child *child, } } -void winbind_child_died(pid_t pid) -{ +struct winbind_child_died_state { + pid_t pid; struct winbindd_child *child; +}; - for (child = winbindd_children; child != NULL; child = child->next) { - if (child->pid == pid) { - break; - } +static bool winbind_child_died_fn(struct winbindd_child *child, + void *private_data) +{ + struct winbind_child_died_state *state = private_data; + + if (child->pid == state->pid) { + state->child = child; + return false; } + return true; +} - if (child == NULL) { +void winbind_child_died(pid_t pid) +{ + struct winbind_child_died_state state = { .pid = pid }; + + forall_children(winbind_child_died_fn, &state); + + if (state.child == NULL) { DEBUG(5, ("Already reaped child %u died\n", (unsigned int)pid)); return; } /* This will be re-added in fork_domain_child() */ - DLIST_REMOVE(winbindd_children, child); - child->pid = 0; + DLIST_REMOVE(winbindd_children, state.child); + state.child->pid = 0; - if (child->sock != -1) { - close(child->sock); - child->sock = -1; + if (state.child->sock != -1) { + close(state.child->sock); + state.child->sock = -1; } } |