From 247d53098cb90600b4aa04d8e733a92d183ccca7 Mon Sep 17 00:00:00 2001 From: babarosaM33 Date: Sun, 19 Jan 2020 09:41:17 +0800 Subject: [PATCH] server: replace memmove with idx --- src/server.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server.c b/src/server.c index 62237194..29fb7ae2 100644 --- a/src/server.c +++ b/src/server.c @@ -502,7 +502,7 @@ connect_to_remote(EV_P_ struct addrinfo *res, if (fast_open) { #if defined(MSG_FASTOPEN) && !defined(TCP_FASTOPEN_CONNECT) int s = -1; - s = sendto(sockfd, server->buf->data, server->buf->len, + s = sendto(sockfd, server->buf->data + server->buf->idx, server->buf->len, MSG_FASTOPEN, res->ai_addr, res->ai_addrlen); #elif defined(TCP_FASTOPEN_WINSOCK) DWORD s = -1; @@ -531,8 +531,8 @@ connect_to_remote(EV_P_ struct addrinfo *res, memset(&remote->olap, 0, sizeof(remote->olap)); remote->connect_ex_done = 0; if (ConnectEx(sockfd, res->ai_addr, res->ai_addrlen, - server->buf->data, server->buf->len, - &s, &remote->olap)) { + server->buf->data + server->buf->idx, + server->buf->len, &s, &remote->olap)) { remote->connect_ex_done = 1; break; } @@ -570,7 +570,7 @@ connect_to_remote(EV_P_ struct addrinfo *res, FATAL("fast open is not enabled in this build"); #endif if (s == 0) - s = send(sockfd, server->buf->data, server->buf->len, 0); + s = send(sockfd, server->buf->data + server->buf->idx, server->buf->len, 0); #endif if (s == -1) { if (errno == CONNECT_IN_PROGRESS) { @@ -908,7 +908,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) return; } else { server->buf->len -= offset; - memmove(server->buf->data, server->buf->data + offset, server->buf->len); + server->buf->idx = offset; } if (verbose) {