win,tty: support uv_try_write
All windows console writes are synchronous anyway, so there's no reason for uv_try_write() to do nothing. PR: https://github.com/libuv/libuv/pull/127 Reviewed-by: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
85a293430f
commit
55ea37125e
@ -213,6 +213,8 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb,
|
||||
int uv_tty_read_stop(uv_tty_t* handle);
|
||||
int uv_tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle,
|
||||
const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb);
|
||||
int uv__tty_try_write(uv_tty_t* handle, const uv_buf_t bufs[],
|
||||
unsigned int nbufs);
|
||||
void uv_tty_close(uv_tty_t* handle);
|
||||
|
||||
void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
|
||||
@ -193,6 +193,7 @@ int uv_try_write(uv_stream_t* stream,
|
||||
case UV_TCP:
|
||||
return uv__tcp_try_write((uv_tcp_t*) stream, bufs, nbufs);
|
||||
case UV_TTY:
|
||||
return uv__tty_try_write((uv_tty_t*) stream, bufs, nbufs);
|
||||
case UV_NAMED_PIPE:
|
||||
return UV_EAGAIN;
|
||||
default:
|
||||
|
||||
@ -1878,6 +1878,21 @@ int uv_tty_write(uv_loop_t* loop,
|
||||
}
|
||||
|
||||
|
||||
int uv__tty_try_write(uv_tty_t* handle,
|
||||
const uv_buf_t bufs[],
|
||||
unsigned int nbufs) {
|
||||
DWORD error;
|
||||
|
||||
if (handle->write_reqs_pending > 0)
|
||||
return UV_EAGAIN;
|
||||
|
||||
if (uv_tty_write_bufs(handle, bufs, nbufs, &error))
|
||||
return uv_translate_sys_error(error);
|
||||
|
||||
return uv__count_bufs(bufs, nbufs);
|
||||
}
|
||||
|
||||
|
||||
void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
uv_write_t* req) {
|
||||
int err;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user