diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-11 16:52:04 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-11 16:52:04 +0200 |
commit | 6d98e06592f1adcb70a99a2d9fd604a1b81ec5ab (patch) | |
tree | 6718c1b1a472066c0acadabe4c1a774a31d0a9f2 /thread.c | |
parent | aa08ae31a07c06eac641d037ea63a22c5c6256b0 (diff) | |
download | mblaze-6d98e06592f1adcb70a99a2d9fd604a1b81ec5ab.tar.gz mblaze-6d98e06592f1adcb70a99a2d9fd604a1b81ec5ab.tar.xz mblaze-6d98e06592f1adcb70a99a2d9fd604a1b81ec5ab.zip |
thread: slay a few loops
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/thread.c b/thread.c index 6384a1b..931fafe 100644 --- a/thread.c +++ b/thread.c @@ -102,12 +102,15 @@ store_id(char *file, struct message *msg) int reachable(struct container *child, struct container *parent) { + int r = 0; + if (strcmp(child->mid, parent->mid) == 0) return 1; - else if (parent->child) - return reachable(child, parent->child); - else - return 0; + if (child->child) + r |= reachable(child->child, parent); + if (child->next) + r |= reachable(child->next, parent); + return r; } void @@ -185,6 +188,8 @@ out: } else if (c->parent) { // if we already have a wrong parent, orphan us first + if (c->parent->child == c) // first in list + c->parent->child = c->next; for (r = c->parent->child; r; r = r->next) { if (r->next == c) r->next = c->next; |