2008-08-05 15:08:32 +00:00
|
|
|
#ifndef _LIGHTTPD_NETWORK_H_
|
|
|
|
#define _LIGHTTPD_NETWORK_H_
|
|
|
|
|
2008-10-28 21:11:50 +00:00
|
|
|
#ifndef _LIGHTTPD_BASE_H_
|
2008-11-16 20:33:53 +00:00
|
|
|
#error Please include <lighttpd/base.h> instead of this file
|
2008-10-28 21:11:50 +00:00
|
|
|
#endif
|
2008-08-05 15:08:32 +00:00
|
|
|
|
2008-11-17 19:54:19 +00:00
|
|
|
#if defined(USE_LINUX_SENDFILE) || defined(USE_FREEBSD_SENDFILE) || defined(USE_SOLARIS_SENDFILEV) || defined(USE_OSX_SENDFILE)
|
2008-11-17 19:23:16 +00:00
|
|
|
# define USE_SENDFILE
|
|
|
|
#endif
|
|
|
|
|
2008-08-09 11:51:06 +00:00
|
|
|
/** repeats write after EINTR */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API ssize_t li_net_write(int fd, void *buf, ssize_t nbyte);
|
2008-08-09 11:51:06 +00:00
|
|
|
|
|
|
|
/** repeats read after EINTR */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API ssize_t li_net_read(int fd, void *buf, ssize_t nbyte);
|
2008-08-09 11:51:06 +00:00
|
|
|
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API liNetworkStatus li_network_write(liVRequest *vr, int fd, liChunkQueue *cq, goffset write_max);
|
|
|
|
LI_API liNetworkStatus li_network_read(liVRequest *vr, int fd, liChunkQueue *cq);
|
2008-08-05 15:08:32 +00:00
|
|
|
|
2008-08-13 19:50:07 +00:00
|
|
|
/* use writev for mem chunks, buffered read/write for files */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API liNetworkStatus li_network_write_writev(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
|
2008-08-13 19:50:07 +00:00
|
|
|
|
2008-11-17 19:23:16 +00:00
|
|
|
#ifdef USE_SENDFILE
|
2008-08-13 19:50:07 +00:00
|
|
|
/* use sendfile for files, writev for mem chunks */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API liNetworkStatus li_network_write_sendfile(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
|
2008-11-17 19:23:16 +00:00
|
|
|
#endif
|
2008-08-13 19:50:07 +00:00
|
|
|
|
2008-08-09 11:51:06 +00:00
|
|
|
/* write backends */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API liNetworkStatus li_network_backend_write(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
|
|
|
|
LI_API liNetworkStatus li_network_backend_writev(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
|
2008-08-09 11:51:06 +00:00
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
#define LI_NETWORK_FALLBACK(f, write_max) do { \
|
|
|
|
liNetworkStatus res; \
|
2008-10-25 12:53:57 +00:00
|
|
|
switch(res = f(vr, fd, cq, write_max)) { \
|
2009-07-08 19:06:07 +00:00
|
|
|
case LI_NETWORK_STATUS_SUCCESS: \
|
2008-08-09 11:51:06 +00:00
|
|
|
break; \
|
|
|
|
default: \
|
|
|
|
return res; \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
2008-08-05 15:08:32 +00:00
|
|
|
#endif
|