make BSD sendfile optional (NetBSD doesn't have it)
This commit is contained in:
parent
9541a22879
commit
0c64df2331
@ -1,7 +1,8 @@
|
|||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
#include "io_internal.h"
|
#include "io_internal.h"
|
||||||
|
#include "havebsdsf.h"
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
#if defined(HAVE_BSDSENDFILE)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
|
||||||
#define BSD_SENDFILE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
@ -13,6 +9,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "iob_internal.h"
|
#include "iob_internal.h"
|
||||||
|
#include "havebsdsf.h"
|
||||||
|
|
||||||
int64 iob_send(int64 s,io_batch* b) {
|
int64 iob_send(int64 s,io_batch* b) {
|
||||||
iob_entry* e,* last;
|
iob_entry* e,* last;
|
||||||
@ -20,7 +17,7 @@ int64 iob_send(int64 s,io_batch* b) {
|
|||||||
int64 total,sent;
|
int64 total,sent;
|
||||||
long i;
|
long i;
|
||||||
long headers;
|
long headers;
|
||||||
#ifdef BSD_SENDFILE
|
#ifdef HAVEBSDSENDFILE
|
||||||
long trailers;
|
long trailers;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -31,7 +28,7 @@ int64 iob_send(int64 s,io_batch* b) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
if (!(e=array_get(&b->b,sizeof(iob_entry),b->next)))
|
if (!(e=array_get(&b->b,sizeof(iob_entry),b->next)))
|
||||||
return -3; /* can't happen error */
|
return -3; /* can't happen error */
|
||||||
#ifdef BSD_SENDFILE
|
#ifdef HAVEBSDSENDFILE
|
||||||
/* BSD sendfile can send headers and trailers. If we run on BSD, we
|
/* BSD sendfile can send headers and trailers. If we run on BSD, we
|
||||||
* should try to exploit this. */
|
* should try to exploit this. */
|
||||||
headers=trailers=0;
|
headers=trailers=0;
|
||||||
@ -42,7 +39,7 @@ int64 iob_send(int64 s,io_batch* b) {
|
|||||||
v[i].iov_len=e[i].n-e[i].offset;
|
v[i].iov_len=e[i].n-e[i].offset;
|
||||||
}
|
}
|
||||||
headers=i;
|
headers=i;
|
||||||
#ifdef BSD_SENDFILE
|
#ifdef HAVEBSDSENDFILE
|
||||||
if (e[i].type==FROMFILE) {
|
if (e[i].type==FROMFILE) {
|
||||||
off_t sbytes;
|
off_t sbytes;
|
||||||
struct sf_hdtr hdr;
|
struct sf_hdtr hdr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user