Support sendfile on solaris: patch from Caitlin Mercer.

svn:r1419
This commit is contained in:
Nick Mathewson 2009-08-16 16:40:42 +00:00
parent f22823982f
commit 22bd5b4287
3 changed files with 13 additions and 1 deletions

View File

@ -14,6 +14,7 @@ Changes in 2.0.3-alpha:
o Add an evbuffer_search_range() function to search a bounded range of a buffer.
o Fix a rare crash bug in evdns.
o Have bufferevent_socket_connect() with no arguments put a bufferevent into connecting mode.
o Support sendfile on Solaris: patch from Caitlin Mercer.
Changes in 2.0.2-alpha:

View File

@ -104,6 +104,9 @@
#elif defined(_EVENT_HAVE_SENDFILE) && defined(__APPLE__)
#define USE_SENDFILE 1
#define SENDFILE_IS_MACOSX 1
#elif defined(_EVENT_HAVE_SENDFILE) && defined(__sun__) && defined(__svr4__)
#define USE_SENDFILE 1
#define SENDFILE_IS_SOLARIS 1
#endif
#ifdef USE_SENDFILE
@ -1785,7 +1788,7 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd,
#if defined(SENDFILE_IS_MACOSX) || defined(SENDFILE_IS_FREEBSD)
int res;
off_t len = chain->off;
#elif SENDFILE_IS_LINUX
#elif defined(SENDFILE_IS_LINUX) || defined(SENDFILE_IS_SOLARIS)
ev_ssize_t res;
off_t offset = chain->misalign;
#endif
@ -1812,6 +1815,13 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t fd,
return (0);
}
return (res);
#elif defined(SENDFILE_IS_SOLARIS)
res = sendfile(fd, info->fd, &offset, chain->off);
if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) {
/* if this is EAGAIN or EINTR return 0; otherwise, -1 */
return (0);
}
return (res);
#endif
}
#endif

View File

@ -53,6 +53,7 @@ AC_SEARCH_LIBS([inet_ntoa], [nsl])
AC_SEARCH_LIBS([socket], [socket])
AC_SEARCH_LIBS([inet_aton], [resolv])
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([sendfile], [sendfile])
dnl Determine if we have zlib for regression tests
dnl Don't put this one in LIBS