mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
make sendfile work on freebsd
svn:r1239
This commit is contained in:
parent
a5897917da
commit
5c4c13d8c2
@ -9,6 +9,7 @@ Changes in 2.0.2-alpha:
|
||||
o Try harder to build with certain older c99 compilers.
|
||||
o Make sure that an event_config's flags field is always initialized to 0. [Bug report from Victor Goya]
|
||||
o Avoid data corruption when reading data entirely into the second-to-last chain of an evbuffer. [Bug report from Victor Goya]
|
||||
o Make sendfile work on FreeBSD
|
||||
|
||||
Changes in 2.0.1-alpha:
|
||||
o free minheap on event_base_free(); from Christopher Layne
|
||||
|
15
buffer.c
15
buffer.c
@ -97,9 +97,12 @@
|
||||
#if defined(_EVENT_HAVE_SYS_SENDFILE_H) && defined(_EVENT_HAVE_SENDFILE) && defined(__linux__)
|
||||
#define USE_SENDFILE 1
|
||||
#define SENDFILE_IS_LINUX 1
|
||||
#elif defined(_EVENT_HAVE_SENDFILE) && (defined(__FreeBSD__) || defined(__APPLE__))
|
||||
#elif defined(_EVENT_HAVE_SENDFILE) && defined(__FreeBSD__)
|
||||
#define USE_SENDFILE 1
|
||||
#define SENDFILE_IS_FREEBSD 1
|
||||
#elif defined(_EVENT_HAVE_SENDFILE) && defined(__APPLE__)
|
||||
#define USE_SENDFILE 1
|
||||
#define SENDFILE_IS_MACOSX 1
|
||||
#endif
|
||||
|
||||
#ifdef USE_SENDFILE
|
||||
@ -1682,7 +1685,7 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd,
|
||||
struct evbuffer_chain *chain = buffer->first;
|
||||
struct evbuffer_chain_fd *info =
|
||||
EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_fd, chain);
|
||||
#ifdef SENDFILE_IS_FREEBSD
|
||||
#if defined(SENDFILE_IS_MACOSX) || defined(SENDFILE_IS_FREEBSD)
|
||||
int res;
|
||||
off_t len = chain->off;
|
||||
#elif SENDFILE_IS_LINUX
|
||||
@ -1692,11 +1695,17 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd,
|
||||
|
||||
ASSERT_EVBUFFER_LOCKED(buffer);
|
||||
|
||||
#ifdef SENDFILE_IS_FREEBSD
|
||||
#ifdef SENDFILE_IS_MACOSX
|
||||
res = sendfile(info->fd, fd, chain->misalign, &len, NULL, 0);
|
||||
if (res == -1 && !EVUTIL_ERR_RW_RETRIABLE(errno))
|
||||
return (-1);
|
||||
|
||||
return (len);
|
||||
#elif SENDFILE_IS_FREEBSD
|
||||
res = sendfile(info->fd, fd, chain->misalign, len, NULL, &len, 0);
|
||||
if (res == -1 && !EVUTIL_ERR_RW_RETRIABLE(errno))
|
||||
return (-1);
|
||||
|
||||
return (len);
|
||||
#elif SENDFILE_IS_LINUX
|
||||
/* TODO(niels): implement splice */
|
||||
|
Loading…
x
Reference in New Issue
Block a user