unix,win: handle nbufs=0 in uv_udp_try_send (#4641)
This commit is contained in:
parent
467859c2ba
commit
2494c088f0
@ -793,7 +793,8 @@ int uv__udp_try_send(uv_udp_t* handle,
|
|||||||
struct msghdr h;
|
struct msghdr h;
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
|
|
||||||
assert(nbufs > 0);
|
if (nbufs < 1)
|
||||||
|
return UV_EINVAL;
|
||||||
|
|
||||||
/* already sending a message */
|
/* already sending a message */
|
||||||
if (handle->send_queue_count != 0)
|
if (handle->send_queue_count != 0)
|
||||||
|
|||||||
@ -1101,7 +1101,8 @@ int uv__udp_try_send(uv_udp_t* handle,
|
|||||||
struct sockaddr_storage converted;
|
struct sockaddr_storage converted;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
assert(nbufs > 0);
|
if (nbufs < 1)
|
||||||
|
return UV_EINVAL;
|
||||||
|
|
||||||
if (addr != NULL) {
|
if (addr != NULL) {
|
||||||
err = uv__convert_to_localhost_if_unspecified(addr, &converted);
|
err = uv__convert_to_localhost_if_unspecified(addr, &converted);
|
||||||
|
|||||||
@ -101,6 +101,10 @@ TEST_IMPL(udp_try_send) {
|
|||||||
ASSERT_OK(r);
|
ASSERT_OK(r);
|
||||||
|
|
||||||
buf = uv_buf_init(buffer, sizeof(buffer));
|
buf = uv_buf_init(buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
r = uv_udp_try_send(&client, &buf, 0, (const struct sockaddr*) &addr);
|
||||||
|
ASSERT_EQ(r, UV_EINVAL);
|
||||||
|
|
||||||
r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &addr);
|
r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &addr);
|
||||||
ASSERT_EQ(r, UV_EMSGSIZE);
|
ASSERT_EQ(r, UV_EMSGSIZE);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user