* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define _GNU_SOURCE
#include "sysdep.h"
#include <ctype.h>
#include <errno.h>
#define SHOW_ME_VAPPEND_PRINTF
#include <stdarg.h>
#ifndef LINUX_SENDFILE
+#include <bits/fcntl.h>
#include <sys/sendfile.h>
#endif
#include "libcitadel.h"
FDB->IOB = IO;
#ifndef LINUX_SENDFILE
FDB->ChunkBuffer = NewStrBuf();
+#else
+ pipe(FDB->SplicePipe);
#endif
FDB->OtherFD = FD;
}
{
#ifdef LINUX_SENDFILE
- ssize_t sent;
- sent = sendfile(FDB->OtherFD, FDB->IOB->fd, &FDB->TotalSentAlready, FDB->ChunkSendRemain);
+ ssize_t sent, pipesize;
+ long foo = 0;
+
+ pipesize = splice(FDB->IOB->fd, NULL,
+ FDB->SplicePipe[1], NULL,
+ FDB->ChunkSendRemain,
+ SPLICE_F_MORE | SPLICE_F_MOVE|SPLICE_F_NONBLOCK);
+ if (pipesize == -1)
+ {
+ *Err = strerror(errno);
+ return pipesize;
+ }
+
+ sent = splice(FDB->SplicePipe[0], NULL,
+ FDB->OtherFD, &FDB->TotalSentAlready,
+ pipesize, SPLICE_F_MORE | SPLICE_F_MOVE);
if (sent == -1)
{
*Err = strerror(errno);
return sent;
}
FDB->ChunkSendRemain -= sent;
- return FDB->ChunkSendRemain;
+ return sent;
#else
#endif
return 0;