From d0cd1b427b843e23e73bcdb4b5d69c6b7b24ee62 Mon Sep 17 00:00:00 2001 From: crvv Date: Mon, 7 Dec 2015 18:02:40 +0800 Subject: [PATCH] Also refine TCP fastopen --- src/local.c | 11 ++++------- src/server.c | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/local.c b/src/local.c index f256154b..e39116bc 100644 --- a/src/local.c +++ b/src/local.c @@ -301,14 +301,11 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) endpoints.sae_dstaddr = (struct sockaddr*)&(remote->addr); endpoints.sae_dstaddrlen = remote->addr_len; - struct iovec iov; - iov.iov_base = remote->buf->array; - iov.iov_len = remote->buf->len; - size_t len; - int s = connectx(remote->fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_DATA_IDEMPOTENT, - &iov, 1, &len, NULL); + int s = connectx(remote->fd, &endpoints, SAE_ASSOCID_ANY, + CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, + NULL, 0, NULL, NULL); if (s == 0) { - s = len; + s = send(remote->fd, remote->buf->array, remote->buf->len, 0); } #else int s = sendto(remote->fd, remote->buf->array, remote->buf->len, MSG_FASTOPEN, diff --git a/src/server.c b/src/server.c index f7d2a7e5..fe66fc05 100644 --- a/src/server.c +++ b/src/server.c @@ -446,7 +446,7 @@ static remote_t *connect_to_remote(struct addrinfo *res, } else { ERROR("sendto"); } - } else if (s < server->buf->len) { + } else if (s <= server->buf->len) { server->buf->idx += s; server->buf->len -= s; } else {