mirror of https://git.kore.io/kore.git
deal with sendfile() in newer linux kernels.
This commit is contained in:
parent
570f9ac986
commit
ac6fcf8981
12
src/linux.c
12
src/linux.c
|
@ -276,13 +276,15 @@ kore_platform_proctitle(char *title)
|
|||
int
|
||||
kore_platform_sendfile(struct connection *c, struct netbuf *nb)
|
||||
{
|
||||
size_t len;
|
||||
ssize_t sent;
|
||||
off_t smin;
|
||||
ssize_t sent;
|
||||
size_t len, prevoff;
|
||||
|
||||
prevoff = nb->fd_off;
|
||||
smin = nb->fd_len - nb->fd_off;
|
||||
len = MIN(SENDFILE_PAYLOAD_MAX, smin);
|
||||
|
||||
resend:
|
||||
sent = sendfile(c->fd, nb->file_ref->fd, &nb->fd_off, len);
|
||||
if (sent == -1) {
|
||||
if (errno == EAGAIN) {
|
||||
|
@ -290,12 +292,12 @@ kore_platform_sendfile(struct connection *c, struct netbuf *nb)
|
|||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
if (errno == EINTR)
|
||||
return (KORE_RESULT_OK);
|
||||
|
||||
return (KORE_RESULT_ERROR);
|
||||
}
|
||||
|
||||
if (nb->fd_off - prevoff != (size_t)len)
|
||||
goto resend;
|
||||
|
||||
if (sent == 0 || nb->fd_off == nb->fd_len) {
|
||||
net_remove_netbuf(&(c->send_queue), nb);
|
||||
c->snb = NULL;
|
||||
|
|
Loading…
Reference in New Issue