]> git.lizzy.rs Git - rust.git/commit
Cache a task's stderr logger
authorAlex Crichton <alex@alexcrichton.com>
Sun, 24 Nov 2013 18:55:17 +0000 (10:55 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 25 Nov 2013 05:22:19 +0000 (21:22 -0800)
commit9fe8fc8836284643f13e148e3e8a09b643f3ff28
tree019e6d9c264802e986c7082f53bd1d3d9e7bee6a
parent01b53817033ba3a3ec01685d30e4a8e7ce14ba0c
Cache a task's stderr logger

This is both useful for performance (otherwise logging is unbuffered), but also
useful for correctness. Because when a task is destroyed we can't block the task
waiting for the logger to close, loggers are opened with a 'CloseAsynchronously'
specification. This causes libuv do defer the call to close() until the next
turn of the event loop.

If you spin in a tight loop around printing, you never yield control back to the
libuv event loop, meaning that you simply enqueue a large number of close
requests but nothing is actually closed. This queue ends up never getting
closed, meaning that if you keep trying to create handles one will eventually
fail, which the runtime will attempt to print the failure, causing mass
destruction.

Caching will provide better performance as well as prevent creation of too many
handles.

Closes #10626
src/libstd/logging.rs
src/test/run-pass/issue-10626.rs [new file with mode: 0644]