]> git.lizzy.rs Git - rust.git/commit
Auto merge of #35975 - jonathandturner:error_buffering, r=alexcrichton
authorbors <bors@rust-lang.org>
Fri, 26 Aug 2016 10:29:45 +0000 (03:29 -0700)
committerGitHub <noreply@github.com>
Fri, 26 Aug 2016 10:29:45 +0000 (03:29 -0700)
commitd00c2454157713e77729989c715b96ee31c6b278
tree4ef9ccf3d4eac5a0468cbf79442fb4083caee374
parenteaf71f8d1034f16140791f566cab3f3c9a0bf96a
parenta65b201d94422eb81addef4bed2d37211e39661b
Auto merge of #35975 - jonathandturner:error_buffering, r=alexcrichton

Buffer unix and lock windows to prevent message interleaving

When cargo does a build on multiple processes, multiple crates may error at the same time.  If this happens, currently you'll see interleaving of the error messages, which makes for an unreadable message.

Example:

```
    --> --> src/bin/multithread-unix.rs:16:35src/bin/singlethread.rs:16:24

      ||

1616  | |     Server::new(&addr).workers(8).    Server::new(&addr).serveserve(|r: Request| {(|r: Request| {

      | |                                                          ^^^^^^^^^^ expected struct `std::io::Error`, found () expected struct `std::io::Error`, found ()

      ||

      = = notenote: expected type `std::io::Error`: expected type `std::io::Error`

      = = notenote:    found type `()`:    found type `()`

      = = notenote: required because of the requirements on the impl of `futures_minihttp::Service<futures_minihttp::Request, futures_minihttp::Response>` for `[closure@src/bin/multithread-unix.rs:16:41: 22:6]`: required because of the requirements on the impl of `futures_minihttp::Service<futures_minihttp::Request, futures_minihttp::Response>` for `[closure@src/bin/singlethread.rs:16:30: 22:6]`

error: aborting due to previous error

error: aborting due to previous error
```

This patch uses two techniques to prevent this interleaving.  On Unix systems, since they use the text-based ANSI protocol for coloring, we can safely buffer up whole messages before we emit.  This PR does this buffering, and emits the whole message at once.

On Windows, term must use the Windows terminal API to color the output.  This disallows us from using the same buffering technique.  Instead, here we grab a Windows mutex (thanks to @alexcrichton for the lock code).  This lock only works in Windows and will hold a mutex for the duration of a message output.

r? @nikomatsakis