Support sendfile on solaris: patch from Caitlin Mercer.
authorNick Mathewson <nickm@torproject.org>
Sun, 16 Aug 2009 16:40:42 +0000 (16:40 +0000)
committerNick Mathewson <nickm@torproject.org>
Sun, 16 Aug 2009 16:40:42 +0000 (16:40 +0000)
svn:r1419

ChangeLog
buffer.c
configure.in

index 694a29784b0a313db9e4ab3774c0a00389a1884f..9238946a3fea2d4d4a092a1bc0e07a1ee48ac4e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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:
index c369f0cac4343449ee83e840212d54d806d3c262..0cd6df50ba534d846975936f53259c7b86c50075 100644 (file)
--- a/buffer.c
+++ b/buffer.c
 #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
index a9b70889d2db8bc0d9ddc32e8399c526eff26a4a..8b7ed00868d44cbe62d27c5b7ca00efd65160d16 100644 (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