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 {