!11 add: user defined interface(uv_poll_init_with_block_socket)

Merge pull request !11 from 熊磊/libuv1224
This commit is contained in:
openharmony_ci 2021-12-27 02:51:04 +00:00 committed by Gitee
commit 66ab796626
2 changed files with 19 additions and 0 deletions

View File

@ -789,6 +789,8 @@ enum uv_poll_event {
UV_PRIORITIZED = 8
};
// User defined interface, to poll a block socket
UV_EXTERN int uv_poll_init_with_block_socket(uv_loop_t* loop, uv_poll_t* handle, int fd);
UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd);
UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop,
uv_poll_t* handle,

View File

@ -65,6 +65,23 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
}
int uv_poll_init_with_block_socket(uv_loop_t* loop, uv_poll_t* handle, int fd) {
int err;
if (uv__fd_exists(loop, fd))
return UV_EEXIST;
err = uv__io_check_fd(loop, fd);
if (err)
return err;
uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL);
uv__io_init(&handle->io_watcher, uv__poll_io, fd);
handle->poll_cb = NULL;
return 0;
}
int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) {
int err;