diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 360f1b2..ebda52a 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -1305,6 +1305,7 @@ static bool fork_domain_child(struct winbindd_child *child) struct winbindd_request request; struct winbindd_response response; struct winbindd_domain *primary_domain = NULL; + struct winbindd_child *c; if (child->domain) { DEBUG(10, ("fork_domain_child called for domain '%s'\n", @@ -1336,8 +1337,18 @@ static bool fork_domain_child(struct winbindd_child *child) /* Parent */ close(fdpair[0]); child->next = child->prev = NULL; - DLIST_ADD(children, child); child->sock = fdpair[1]; + /* + * We need to check duplicate element before + * DLIST_ADD. Otherwise, childlen list be circularly. + */ + for (c = children; c != NULL; c = child->next) { + if (c == child) { + DEBUG(5, ("Already added child in children\n"); + return True; + } + } + DLIST_ADD(children, child); return True; }