unix: remove UV_REQ_BUFSML_SIZE
This commit is contained in:
parent
894b0fc0a7
commit
a7f7696a8d
@ -140,8 +140,6 @@ struct uv__io_s {
|
||||
uv_signal_t child_watcher; \
|
||||
UV_LOOP_PRIVATE_PLATFORM_FIELDS
|
||||
|
||||
#define UV_REQ_BUFSML_SIZE (4)
|
||||
|
||||
#define UV_REQ_PRIVATE_FIELDS /* empty */
|
||||
|
||||
#define UV_WRITE_PRIVATE_FIELDS \
|
||||
@ -150,7 +148,7 @@ struct uv__io_s {
|
||||
uv_buf_t* bufs; \
|
||||
int bufcnt; \
|
||||
int error; \
|
||||
uv_buf_t bufsml[UV_REQ_BUFSML_SIZE];
|
||||
uv_buf_t bufsml[4]; \
|
||||
|
||||
#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
|
||||
|
||||
@ -164,7 +162,7 @@ struct uv__io_s {
|
||||
uv_buf_t* bufs; \
|
||||
ssize_t status; \
|
||||
uv_udp_send_cb send_cb; \
|
||||
uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; \
|
||||
uv_buf_t bufsml[4]; \
|
||||
|
||||
#define UV_PRIVATE_REQ_TYPES /* empty */
|
||||
|
||||
|
||||
@ -831,10 +831,16 @@ static void uv__stream_connect(uv_stream_t* stream) {
|
||||
}
|
||||
|
||||
|
||||
int uv_write2(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt,
|
||||
uv_stream_t* send_handle, uv_write_cb cb) {
|
||||
int uv_write2(uv_write_t* req,
|
||||
uv_stream_t* stream,
|
||||
uv_buf_t bufs[],
|
||||
int bufcnt,
|
||||
uv_stream_t* send_handle,
|
||||
uv_write_cb cb) {
|
||||
int empty_queue;
|
||||
|
||||
assert(bufcnt > 0);
|
||||
|
||||
assert((stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
|
||||
stream->type == UV_TTY) &&
|
||||
"uv_write (unix) does not yet support other types of streams");
|
||||
@ -861,7 +867,7 @@ int uv_write2(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt,
|
||||
req->send_handle = send_handle;
|
||||
ngx_queue_init(&req->queue);
|
||||
|
||||
if (bufcnt <= UV_REQ_BUFSML_SIZE)
|
||||
if (bufcnt <= (int) ARRAY_SIZE(req->bufsml))
|
||||
req->bufs = req->bufsml;
|
||||
else
|
||||
req->bufs = malloc(sizeof(uv_buf_t) * bufcnt);
|
||||
|
||||
@ -418,6 +418,8 @@ static int uv__udp_send(uv_udp_send_t* req,
|
||||
struct sockaddr* addr,
|
||||
socklen_t addrlen,
|
||||
uv_udp_send_cb send_cb) {
|
||||
assert(bufcnt > 0);
|
||||
|
||||
if (uv__udp_maybe_deferred_bind(handle, addr->sa_family))
|
||||
return -1;
|
||||
|
||||
@ -429,7 +431,7 @@ static int uv__udp_send(uv_udp_send_t* req,
|
||||
req->handle = handle;
|
||||
req->bufcnt = bufcnt;
|
||||
|
||||
if (bufcnt <= UV_REQ_BUFSML_SIZE) {
|
||||
if (bufcnt <= (int) ARRAY_SIZE(req->bufsml)) {
|
||||
req->bufs = req->bufsml;
|
||||
}
|
||||
else if ((req->bufs = malloc(bufcnt * sizeof(bufs[0]))) == NULL) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user