neovim/neovim — pull request #556 by tarruda (2014-04-17 15:35:09+00:00)
Title: [WIP] More stream abstractions and improvements

This PR will add more fixes and improvements to how we deal with non-blocking reads/writes. I'm refactoring mainly because I want to reuse the same code for:

- Reading/writing msgpack-rpc(or any other protocol we may add in the future) from/to pipes and/or sockets
- Reading/writing job data

I will also add an abstraction for non-blocking write streams(wstream.c) but still need to decide how to handle some egde cases:

- For writing, should we use a static buffer that when filled will return an error(`jobwrite` could fail for example) or dynamic buffers?
- If using dynamic buffers(what is being done right now), what to do with failed allocations? Exiting vim with `xmalloc` is not acceptable, since that can happen when a external process hangs for long enough while vimscript constantly feeds it with data. I'm thinking freeing the `WStream` and killing the associated job/connection is the best approach, but suggestions are welcome.