unix: remove UV_HANDLE_READING flag
This commit is contained in:
parent
a19ceeb13a
commit
cb2d5f3ffe
@ -930,7 +930,6 @@ static void uv__write_callbacks(uv_stream_t* stream) {
|
|||||||
|
|
||||||
static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) {
|
static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) {
|
||||||
stream->flags |= UV_HANDLE_READ_EOF;
|
stream->flags |= UV_HANDLE_READ_EOF;
|
||||||
stream->flags &= ~UV_HANDLE_READING;
|
|
||||||
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
|
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
|
||||||
uv__handle_stop(stream);
|
uv__handle_stop(stream);
|
||||||
uv__stream_osx_interrupt_select(stream);
|
uv__stream_osx_interrupt_select(stream);
|
||||||
@ -1037,11 +1036,7 @@ static void uv__read(uv_stream_t* stream) {
|
|||||||
|
|
||||||
is_ipc = stream->type == UV_NAMED_PIPE && ((uv_pipe_t*) stream)->ipc;
|
is_ipc = stream->type == UV_NAMED_PIPE && ((uv_pipe_t*) stream)->ipc;
|
||||||
|
|
||||||
/* XXX: Maybe instead of having UV_HANDLE_READING we just test if
|
|
||||||
* tcp->read_cb is NULL or not?
|
|
||||||
*/
|
|
||||||
while (stream->read_cb
|
while (stream->read_cb
|
||||||
&& (stream->flags & UV_HANDLE_READING)
|
|
||||||
&& (count-- > 0)) {
|
&& (count-- > 0)) {
|
||||||
assert(stream->alloc_cb != NULL);
|
assert(stream->alloc_cb != NULL);
|
||||||
|
|
||||||
@ -1082,7 +1077,7 @@ static void uv__read(uv_stream_t* stream) {
|
|||||||
/* Error */
|
/* Error */
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
/* Wait for the next one. */
|
/* Wait for the next one. */
|
||||||
if (stream->flags & UV_HANDLE_READING) {
|
if (stream->read_cb != NULL) {
|
||||||
uv__io_start(stream->loop, &stream->io_watcher, POLLIN);
|
uv__io_start(stream->loop, &stream->io_watcher, POLLIN);
|
||||||
uv__stream_osx_interrupt_select(stream);
|
uv__stream_osx_interrupt_select(stream);
|
||||||
}
|
}
|
||||||
@ -1096,8 +1091,9 @@ static void uv__read(uv_stream_t* stream) {
|
|||||||
/* Error. User should call uv_close(). */
|
/* Error. User should call uv_close(). */
|
||||||
stream->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
|
stream->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
|
||||||
stream->read_cb(stream, UV__ERR(errno), &buf);
|
stream->read_cb(stream, UV__ERR(errno), &buf);
|
||||||
if (stream->flags & UV_HANDLE_READING) {
|
if (stream->read_cb != NULL) {
|
||||||
stream->flags &= ~UV_HANDLE_READING;
|
stream->read_cb = NULL;
|
||||||
|
stream->alloc_cb = NULL;
|
||||||
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
|
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
|
||||||
uv__handle_stop(stream);
|
uv__handle_stop(stream);
|
||||||
uv__stream_osx_interrupt_select(stream);
|
uv__stream_osx_interrupt_select(stream);
|
||||||
@ -1220,7 +1216,7 @@ void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
|
|||||||
*/
|
*/
|
||||||
if ((events & POLLHUP) &&
|
if ((events & POLLHUP) &&
|
||||||
!(events & POLLIN) &&
|
!(events & POLLIN) &&
|
||||||
(stream->flags & UV_HANDLE_READING) &&
|
(stream->read_cb != NULL) &&
|
||||||
!(stream->flags & UV_HANDLE_READ_EOF)) {
|
!(stream->flags & UV_HANDLE_READ_EOF)) {
|
||||||
uv_buf_t buf = { NULL, 0 };
|
uv_buf_t buf = { NULL, 0 };
|
||||||
uv__stream_eof(stream, &buf);
|
uv__stream_eof(stream, &buf);
|
||||||
@ -1450,9 +1446,6 @@ int uv__read_start(uv_stream_t* stream,
|
|||||||
assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
|
assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
|
||||||
stream->type == UV_TTY);
|
stream->type == UV_TTY);
|
||||||
|
|
||||||
/* The UV_HANDLE_READING flag is irrelevant of the state of the stream - it
|
|
||||||
* just expresses the desired state of the user. */
|
|
||||||
stream->flags |= UV_HANDLE_READING;
|
|
||||||
stream->flags &= ~UV_HANDLE_READ_EOF;
|
stream->flags &= ~UV_HANDLE_READ_EOF;
|
||||||
|
|
||||||
/* TODO: try to do the read inline? */
|
/* TODO: try to do the read inline? */
|
||||||
@ -1471,10 +1464,9 @@ int uv__read_start(uv_stream_t* stream,
|
|||||||
|
|
||||||
|
|
||||||
int uv_read_stop(uv_stream_t* stream) {
|
int uv_read_stop(uv_stream_t* stream) {
|
||||||
if (!(stream->flags & UV_HANDLE_READING))
|
if (stream->read_cb == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
stream->flags &= ~UV_HANDLE_READING;
|
|
||||||
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
|
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
|
||||||
uv__handle_stop(stream);
|
uv__handle_stop(stream);
|
||||||
uv__stream_osx_interrupt_select(stream);
|
uv__stream_osx_interrupt_select(stream);
|
||||||
|
|||||||
@ -928,7 +928,7 @@ int uv_read_start(uv_stream_t* stream,
|
|||||||
if (stream->flags & UV_HANDLE_CLOSING)
|
if (stream->flags & UV_HANDLE_CLOSING)
|
||||||
return UV_EINVAL;
|
return UV_EINVAL;
|
||||||
|
|
||||||
if (stream->flags & UV_HANDLE_READING)
|
if (stream->read_cb != NULL)
|
||||||
return UV_EALREADY;
|
return UV_EALREADY;
|
||||||
|
|
||||||
if (!(stream->flags & UV_HANDLE_READABLE))
|
if (!(stream->flags & UV_HANDLE_READABLE))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user