make sure we use fd_off in linux sendfile properly

This commit is contained in:
Joris Vink 2018-06-29 03:10:28 +00:00
parent 3e5939a8e3
commit cca269ff5d
1 changed files with 2 additions and 3 deletions

View File

@ -283,7 +283,8 @@ kore_platform_sendfile(struct connection *c, struct netbuf *nb)
smin = nb->fd_len - nb->fd_off;
len = MIN(SENDFILE_PAYLOAD_MAX, smin);
if ((sent = sendfile(c->fd, nb->file_ref->fd, NULL, len)) == -1) {
sent = sendfile(c->fd, nb->file_ref->fd, &nb->fd_off, len);
if (sent == -1) {
if (errno == EAGAIN) {
c->flags &= ~CONN_WRITE_POSSIBLE;
return (KORE_RESULT_OK);
@ -295,8 +296,6 @@ kore_platform_sendfile(struct connection *c, struct netbuf *nb)
return (KORE_RESULT_ERROR);
}
nb->fd_off += (size_t)sent;
if (sent == 0 || nb->fd_off == nb->fd_len) {
net_remove_netbuf(&(c->send_queue), nb);
c->snb = NULL;