|
|
@ -14,8 +14,14 @@
|
|
|
|
int64 io_sendfile(int64 s,int64 fd,uint64 off,uint64 n) {
|
|
|
|
int64 io_sendfile(int64 s,int64 fd,uint64 off,uint64 n) {
|
|
|
|
off_t sbytes;
|
|
|
|
off_t sbytes;
|
|
|
|
int r=sendfile(fd,s,off,n,0,&sbytes,0);
|
|
|
|
int r=sendfile(fd,s,off,n,0,&sbytes,0);
|
|
|
|
if (r==-1)
|
|
|
|
if (r==-1) {
|
|
|
|
|
|
|
|
io_entry* e=iarray_get(&io_fds,s);
|
|
|
|
|
|
|
|
if (e) {
|
|
|
|
|
|
|
|
e->canwrite=0;
|
|
|
|
|
|
|
|
e->next_write=-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
return (errno==EAGAIN?(sbytes?sbytes:-1):-3);
|
|
|
|
return (errno==EAGAIN?(sbytes?sbytes:-1):-3);
|
|
|
|
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -31,6 +37,13 @@ int64 io_sendfile(int64 s,int64 fd,uint64 off,uint64 n) {
|
|
|
|
int64 io_sendfile(int64 out,int64 in,uint64 off,uint64 bytes) {
|
|
|
|
int64 io_sendfile(int64 out,int64 in,uint64 off,uint64 bytes) {
|
|
|
|
long long r=sendfile64(out,in,off,bytes,0,0);
|
|
|
|
long long r=sendfile64(out,in,off,bytes,0,0);
|
|
|
|
if (r==-1 && errno!=EAGAIN) r=-3;
|
|
|
|
if (r==-1 && errno!=EAGAIN) r=-3;
|
|
|
|
|
|
|
|
if (r!=bytes) {
|
|
|
|
|
|
|
|
io_entry* e=iarray_get(&io_fds,s);
|
|
|
|
|
|
|
|
if (e) {
|
|
|
|
|
|
|
|
e->canwrite=0;
|
|
|
|
|
|
|
|
e->next_write=-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -45,6 +58,13 @@ int64 io_sendfile(int64 out,int64 in,uint64 off,uint64 bytes) {
|
|
|
|
off64_t o=off;
|
|
|
|
off64_t o=off;
|
|
|
|
long long r=sendfile64(out,in,&o,bytes);
|
|
|
|
long long r=sendfile64(out,in,&o,bytes);
|
|
|
|
if (r==-1 && errno!=EAGAIN) r=-3;
|
|
|
|
if (r==-1 && errno!=EAGAIN) r=-3;
|
|
|
|
|
|
|
|
if (r!=bytes) {
|
|
|
|
|
|
|
|
io_entry* e=iarray_get(&io_fds,s);
|
|
|
|
|
|
|
|
if (e) {
|
|
|
|
|
|
|
|
e->canwrite=0;
|
|
|
|
|
|
|
|
e->next_write=-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -65,9 +85,16 @@ int64 io_sendfile(int64 out,int64 in,uint64 off,uint64 bytes) {
|
|
|
|
p.file_bytes=bytes;
|
|
|
|
p.file_bytes=bytes;
|
|
|
|
p.trailer_data=0;
|
|
|
|
p.trailer_data=0;
|
|
|
|
p.trailer_length=0;
|
|
|
|
p.trailer_length=0;
|
|
|
|
if (send_file(&destfd,&p,0)>=0)
|
|
|
|
if (send_file(&destfd,&p,0)>=0) {
|
|
|
|
|
|
|
|
if (p.bytes_sent != bytes) {
|
|
|
|
|
|
|
|
io_entry* e=iarray_get(&io_fds,s);
|
|
|
|
|
|
|
|
if (e) {
|
|
|
|
|
|
|
|
e->canwrite=0;
|
|
|
|
|
|
|
|
e->next_write=-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return p.bytes_sent;
|
|
|
|
return p.bytes_sent;
|
|
|
|
if (errno==EAGAIN)
|
|
|
|
} if (errno==EAGAIN)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return -3;
|
|
|
|
return -3;
|
|
|
@ -99,14 +126,16 @@ int64 io_sendfile(int64 s,int64 fd,uint64 off,uint64 n) {
|
|
|
|
n-=todo;
|
|
|
|
n-=todo;
|
|
|
|
if (n==0) return done;
|
|
|
|
if (n==0) return done;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
} else if (i==-1) {
|
|
|
|
} else {
|
|
|
|
if (e) {
|
|
|
|
if (e) {
|
|
|
|
e->canwrite=0;
|
|
|
|
e->canwrite=0;
|
|
|
|
e->next_write=-1;
|
|
|
|
e->next_write=-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (errno==EAGAIN?-1:-3);
|
|
|
|
if (i==-1)
|
|
|
|
} else
|
|
|
|
return (errno==EAGAIN?-1:-3);
|
|
|
|
return done+i;
|
|
|
|
else
|
|
|
|
|
|
|
|
return done+i;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|