Browse Source

server: replace memmove with idx

pull/2596/head
babarosaM33 4 years ago
parent
commit
247d53098c
1 changed files with 5 additions and 5 deletions
  1. 10
      src/server.c

10
src/server.c

@ -502,7 +502,7 @@ connect_to_remote(EV_P_ struct addrinfo *res,
if (fast_open) { if (fast_open) {
#if defined(MSG_FASTOPEN) && !defined(TCP_FASTOPEN_CONNECT) #if defined(MSG_FASTOPEN) && !defined(TCP_FASTOPEN_CONNECT)
int s = -1; 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); MSG_FASTOPEN, res->ai_addr, res->ai_addrlen);
#elif defined(TCP_FASTOPEN_WINSOCK) #elif defined(TCP_FASTOPEN_WINSOCK)
DWORD s = -1; DWORD s = -1;
@ -531,8 +531,8 @@ connect_to_remote(EV_P_ struct addrinfo *res,
memset(&remote->olap, 0, sizeof(remote->olap)); memset(&remote->olap, 0, sizeof(remote->olap));
remote->connect_ex_done = 0; remote->connect_ex_done = 0;
if (ConnectEx(sockfd, res->ai_addr, res->ai_addrlen, 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; remote->connect_ex_done = 1;
break; break;
} }
@ -570,7 +570,7 @@ connect_to_remote(EV_P_ struct addrinfo *res,
FATAL("fast open is not enabled in this build"); FATAL("fast open is not enabled in this build");
#endif #endif
if (s == 0) 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 #endif
if (s == -1) { if (s == -1) {
if (errno == CONNECT_IN_PROGRESS) { if (errno == CONNECT_IN_PROGRESS) {
@ -908,7 +908,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
return; return;
} else { } else {
server->buf->len -= offset; server->buf->len -= offset;
memmove(server->buf->data, server->buf->data + offset, server->buf->len);
server->buf->idx = offset;
} }
if (verbose) { if (verbose) {

Loading…
Cancel
Save