Closed kyze8439690 closed 4 years ago
uv_read_start()
never clears UV_HANDLE_READABLE
. Were you thinking of uv__stream_close()
?
uv_read_start()
sets UV_HANDLE_READING
(different flag), to mark that the user wants data.
UV_HANDLE_READABLE
is a note that libuv makes to remember whether the handle was opened in read mode. It never changes during the lifetime of the handle, only when it's closed.
I mean when you get UV_EOF
in uv_read_cb
, which mean this uv_stream becomes unreadable, why not we clear UV_HANDLE_READABLE
flag on this uv_stream?
Here is a similar scene, uv_shutdown
method makes a uv_stream becomes unwritable, and it will clear UV_HANDLE_WRITABLE
flag.
If you think it's a good idea, you're welcome to open a pull request. The thing is, the observable behavior can't change - it's not allowed to break existing programs.
It seems that there is a flag called UV_HANDLE_READ_EOF
which can indicate UV_EOF
, I will try to use this flag instead. Thanks.
UV_HANDLE_READ_EOF
work like a charm! Hope that in the future there will be an uv_is_read_eof()
method for it. Maybe I can open a pull request? :)
Is it a good design to make
handle->flags &= ~UV_HANDLE_READABLE
flag correspond to gettingUV_EOF
inuv_read_start
? It seem thatUV_HANDLE_READABLE
is removed only when closing.