Skip to content
Snippets Groups Projects
Commit 5557d09e authored by deuce's avatar deuce
Browse files

sendfilesocket() now uses sendfile() on FreeBSD for zero-copy sends.

parent 6b38defa
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,26 @@
int sendfilesocket(int sock, int file, long *offset, long count)
{
/* sendfile() on Linux may or may not work with non-blocking sockets ToDo */
#if defined(__FreeBSD__)
off_t total=0;
off_t wr=0;
int i;
long len;
len=filelength(file);
if(count<1 || count>len) {
count=len;
count-=offset==NULL?0:*offset;
}
while((i=sendfile(file,sock,(offset==NULL?0:*offset)+total,count-total,NULL,&wr,0))==-1 && errno==EAGAIN) {
total+=wr;
SLEEP(1);
}
if(i==0)
return((int)count);
return(i);
#else
char* buf;
long len;
int rd;
......@@ -97,6 +117,7 @@ int sendfilesocket(int sock, int file, long *offset, long count)
return(wr);
return(total);
#endif
}
int recvfilesocket(int sock, int file, long *offset, long count)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment