From 106064e3968df9702ca9841f00703be9736a00bb Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 3 Jun 2016 13:06:06 -0400 Subject: src: more experiments --- src/uv_link_t.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/uv_link_t.c') diff --git a/src/uv_link_t.c b/src/uv_link_t.c index 9058b55..59b5fa7 100644 --- a/src/uv_link_t.c +++ b/src/uv_link_t.c @@ -87,14 +87,17 @@ void uv_link_close(uv_link_t* link, uv_link_close_cb cb) { void uv_link_maybe_close(uv_link_t* link) { uv_link_close_cb cb; + uv_link_t* source; - if (link->saved_close_cb == NULL) + if (link->pending_close_cb == NULL) return; - cb = link->saved_close_cb; + cb = link->pending_close_cb; + source = link->pending_close_source; - link->saved_close_cb = NULL; - return uv_link_propagate_close(link, link, cb); + link->pending_close_cb = NULL; + link->pending_close_source = NULL; + return uv_link_propagate_close(link, source, cb); } @@ -139,7 +142,12 @@ void uv_link_propagate_close(uv_link_t* link, uv_link_t* source, if (child != NULL) CHECK_EQ(uv_link_unchain(root, child), 0, "close unchain"); - root->methods->close(root, source, uv_link_close_join); + if (root->close_depth == 0) { + root->methods->close(root, source, uv_link_close_join); + } else { + root->pending_close_cb = uv_link_close_join; + root->pending_close_source = source; + } root = child; } } -- cgit 1.4.1-2-gfad0