unix: replace some asserts with returning errors
This commit is contained in:
parent
b53aeb491a
commit
875814adc5
@ -60,6 +60,7 @@ int uv_fs_poll_start(uv_fs_poll_t* handle,
|
||||
struct poll_ctx* ctx;
|
||||
uv_loop_t* loop;
|
||||
size_t len;
|
||||
int err;
|
||||
|
||||
if (uv__is_active(handle))
|
||||
return 0;
|
||||
@ -78,19 +79,25 @@ int uv_fs_poll_start(uv_fs_poll_t* handle,
|
||||
ctx->parent_handle = handle;
|
||||
memcpy(ctx->path, path, len + 1);
|
||||
|
||||
if (uv_timer_init(loop, &ctx->timer_handle))
|
||||
abort();
|
||||
err = uv_timer_init(loop, &ctx->timer_handle);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
|
||||
ctx->timer_handle.flags |= UV__HANDLE_INTERNAL;
|
||||
uv__handle_unref(&ctx->timer_handle);
|
||||
|
||||
if (uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb))
|
||||
abort();
|
||||
err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
|
||||
handle->poll_ctx = ctx;
|
||||
uv__handle_start(handle);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
free(ctx);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -537,7 +537,7 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
done:
|
||||
@ -573,7 +573,6 @@ done:
|
||||
int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) {
|
||||
int err;
|
||||
|
||||
err = -EINVAL;
|
||||
switch (stream->type) {
|
||||
case UV_TCP:
|
||||
err = uv_tcp_listen((uv_tcp_t*)stream, backlog, cb);
|
||||
@ -584,7 +583,7 @@ int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
err = -EINVAL;
|
||||
}
|
||||
|
||||
if (err == 0)
|
||||
|
||||
@ -340,8 +340,6 @@ static int uv__udp_maybe_deferred_bind(uv_udp_t* handle,
|
||||
unsigned char taddr[sizeof(struct sockaddr_in6)];
|
||||
socklen_t addrlen;
|
||||
|
||||
assert(domain == AF_INET || domain == AF_INET6);
|
||||
|
||||
if (handle->io_watcher.fd != -1)
|
||||
return 0;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user