From 7c845fb25f13a03a5264ea28e0a642fc7dbf7c98 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 10 Jun 2019 18:37:17 -0400 Subject: [PATCH] win: remove some unused code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code was missed in the cleanup done in #971, or just otherwise is not used on libuv master. PR-URL: https://github.com/libuv/libuv/pull/2327 Reviewed-By: Ben Noordhuis Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: Colin Ihrig --- include/uv/win.h | 8 +++----- src/uv-common.h | 2 +- src/win/tcp.c | 34 ++-------------------------------- src/win/udp.c | 27 +++++---------------------- test/test-ping-pong.c | 4 ---- 5 files changed, 11 insertions(+), 64 deletions(-) diff --git a/include/uv/win.h b/include/uv/win.h index 21ce7290..238daaae 100644 --- a/include/uv/win.h +++ b/include/uv/win.h @@ -303,7 +303,8 @@ typedef struct { LPFN_ACCEPTEX func_acceptex; #define uv_tcp_connection_fields \ - uv_buf_t read_buffer; \ + uv_tcp_accept_t* dummy1; /* Mirror of union field, keep as NULL */ \ + unsigned int dummy2; /* Mirror of union field, keep as 0 */ \ LPFN_CONNECTEX func_connectex; #define UV_TCP_PRIVATE_FIELDS \ @@ -319,7 +320,6 @@ typedef struct { unsigned int reqs_pending; \ int activecnt; \ uv_req_t recv_req; \ - uv_buf_t recv_buffer; \ struct sockaddr_storage recv_from; \ int recv_from_len; \ uv_udp_recv_cb recv_cb; \ @@ -334,11 +334,9 @@ typedef struct { #define uv_pipe_connection_fields \ uv_timer_t* eof_timer; \ - uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ DWORD ipc_remote_pid; \ - union { \ + struct { \ uint32_t payload_remaining; \ - uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ } ipc_data_frame; \ void* ipc_xfer_queue[2]; \ int ipc_xfer_queue_length; \ diff --git a/src/uv-common.h b/src/uv-common.h index bddd99b3..8343567f 100644 --- a/src/uv-common.h +++ b/src/uv-common.h @@ -76,7 +76,7 @@ enum { UV_HANDLE_WRITABLE = 0x00008000, UV_HANDLE_READ_PENDING = 0x00010000, UV_HANDLE_SYNC_BYPASS_IOCP = 0x00020000, - UV_HANDLE_ZERO_READ = 0x00040000, + /*UV_HANDLE_FLAG_UNUSED = 0x00040000,*/ UV_HANDLE_EMULATE_IOCP = 0x00080000, UV_HANDLE_BLOCKING_WRITES = 0x00100000, UV_HANDLE_CANCELLATION_PENDING = 0x00200000, diff --git a/src/win/tcp.c b/src/win/tcp.c index a1389324..cfe2e753 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -472,7 +472,6 @@ static void uv_tcp_queue_read(uv_loop_t* loop, uv_tcp_t* handle) { req = &handle->read_req; memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - handle->flags |= UV_HANDLE_ZERO_READ; buf.base = ""; buf.len = 0; @@ -900,12 +899,10 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, if (!REQ_SUCCESS(req)) { /* An error occurred doing the read. */ - if ((handle->flags & UV_HANDLE_READING) || - !(handle->flags & UV_HANDLE_ZERO_READ)) { + if ((handle->flags & UV_HANDLE_READING) != 0) { handle->flags &= ~UV_HANDLE_READING; DECREASE_ACTIVE_COUNT(loop, handle); - buf = (handle->flags & UV_HANDLE_ZERO_READ) ? - uv_buf_init(NULL, 0) : handle->tcp.conn.read_buffer; + buf = uv_buf_init(NULL, 0); err = GET_REQ_SOCK_ERROR(req); @@ -920,32 +917,6 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, &buf); } } else { - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - /* The read was done with a non-zero buffer length. */ - if (req->u.io.overlapped.InternalHigh > 0) { - /* Successful read */ - handle->read_cb((uv_stream_t*)handle, - req->u.io.overlapped.InternalHigh, - &handle->tcp.conn.read_buffer); - /* Read again only if bytes == buf.len */ - if (req->u.io.overlapped.InternalHigh < handle->tcp.conn.read_buffer.len) { - goto done; - } - } else { - /* Connection closed */ - if (handle->flags & UV_HANDLE_READING) { - handle->flags &= ~UV_HANDLE_READING; - DECREASE_ACTIVE_COUNT(loop, handle); - } - handle->flags &= ~UV_HANDLE_READABLE; - - buf.base = 0; - buf.len = 0; - handle->read_cb((uv_stream_t*)handle, UV_EOF, &handle->tcp.conn.read_buffer); - goto done; - } - } - /* Do nonblocking reads until the buffer is empty */ count = 32; while ((handle->flags & UV_HANDLE_READING) && (count-- > 0)) { @@ -1004,7 +975,6 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, } } -done: /* Post another read if still reading and not closing. */ if ((handle->flags & UV_HANDLE_READING) && !(handle->flags & UV_HANDLE_READ_PENDING)) { diff --git a/src/win/udp.c b/src/win/udp.c index f772b367..5d8527dd 100644 --- a/src/win/udp.c +++ b/src/win/udp.c @@ -34,8 +34,6 @@ */ const unsigned int uv_active_udp_streams_threshold = 0; -/* A zero-size buffer for use by uv_udp_read */ -static char uv_zero_[] = ""; int uv_udp_getpeername(const uv_udp_t* handle, struct sockaddr* name, int* namelen) { @@ -283,7 +281,6 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { req = &handle->recv_req; memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); - handle->flags |= UV_HANDLE_ZERO_READ; buf.base = ""; buf.len = 0; flags = MSG_PEEK; @@ -408,7 +405,6 @@ static int uv__send(uv_udp_send_t* req, void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, uv_req_t* req) { uv_buf_t buf; - int partial; assert(handle->type == UV_UDP); @@ -420,35 +416,22 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, /* Not a real error, it just indicates that the received packet was * bigger than the receive buffer. */ } else if (err == WSAECONNRESET || err == WSAENETRESET) { - /* A previous sendto operation failed; ignore this error. If zero-reading - * we need to call WSARecv/WSARecvFrom _without_ the. MSG_PEEK flag to - * clear out the error queue. For nonzero reads, immediately queue a new - * receive. */ - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - goto done; - } + /* A previous sendto operation failed; ignore this error. + * We need to call WSARecv/WSARecvFrom _without_ the MSG_PEEK flag to + * clear out the error queue. */ } else { /* A real error occurred. Report the error to the user only if we're * currently reading. */ if (handle->flags & UV_HANDLE_READING) { uv_udp_recv_stop(handle); - buf = (handle->flags & UV_HANDLE_ZERO_READ) ? - uv_buf_init(NULL, 0) : handle->recv_buffer; + buf = uv_buf_init(NULL, 0); handle->recv_cb(handle, uv_translate_sys_error(err), &buf, NULL, 0); } goto done; } } - if (!(handle->flags & UV_HANDLE_ZERO_READ)) { - /* Successful read */ - partial = !REQ_SUCCESS(req); - handle->recv_cb(handle, - req->u.io.overlapped.InternalHigh, - &handle->recv_buffer, - (const struct sockaddr*) &handle->recv_from, - partial ? UV_UDP_PARTIAL : 0); - } else if (handle->flags & UV_HANDLE_READING) { + if (handle->flags & UV_HANDLE_READING) { DWORD bytes, err, flags; struct sockaddr_storage from; int from_len; diff --git a/test/test-ping-pong.c b/test/test-ping-pong.c index c86a3f4a..67a4e5b9 100644 --- a/test/test-ping-pong.c +++ b/test/test-ping-pong.c @@ -33,9 +33,6 @@ static int completed_pingers = 0; #define NUM_PINGS 1000 #endif -/* 64 bytes is enough for a pinger */ -#define BUFSIZE 10240 - static char PING[] = "PING\n"; static int pinger_on_connect_count; @@ -49,7 +46,6 @@ typedef struct { uv_pipe_t pipe; } stream; uv_connect_t connect_req; - char read_buffer[BUFSIZE]; } pinger_t;