gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35903 - in libmicrohttpd: . src/include src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r35903 - in libmicrohttpd: . src/include src/microhttpd
Date: Tue, 9 Jun 2015 21:34:45 +0200

Author: Karlson2k
Date: 2015-06-09 21:34:45 +0200 (Tue, 09 Jun 2015)
New Revision: 35903

Modified:
   libmicrohttpd/configure.ac
   libmicrohttpd/src/include/platform.h
   libmicrohttpd/src/microhttpd/daemon.c
Log:
send_param_adapter(): support hosts with sendfile64(), but with 32-bit off_t 
(i.e. Android)

Modified: libmicrohttpd/configure.ac
===================================================================
--- libmicrohttpd/configure.ac  2015-06-09 19:34:36 UTC (rev 35902)
+++ libmicrohttpd/configure.ac  2015-06-09 19:34:45 UTC (rev 35903)
@@ -608,7 +608,7 @@
 # large file support (> 4 GB)
 AC_SYS_LARGEFILE
 AC_FUNC_FSEEKO
-AC_CHECK_FUNCS([_lseeki64 lseek64])
+AC_CHECK_FUNCS([_lseeki64 lseek64 sendfile64])
 
 # optional: have error messages ?
 AC_MSG_CHECKING(whether to generate error messages)

Modified: libmicrohttpd/src/include/platform.h
===================================================================
--- libmicrohttpd/src/include/platform.h        2015-06-09 19:34:36 UTC (rev 
35902)
+++ libmicrohttpd/src/include/platform.h        2015-06-09 19:34:45 UTC (rev 
35903)
@@ -78,6 +78,10 @@
 #endif /* !WIN32_LEAN_AND_MEAN */
 #endif // _WIN32
 
+#if LINUX+0 && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && ! 
defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -202,4 +206,12 @@
 #define IPPROTO_IPV6 IPPROTO_IPV6
 #endif
 
+#ifndef OFF_T_MAX
+#define OFF_T_MAX ((off_t) ~(((uint64_t) 1) << (8 * sizeof(off_t) - 1)))
 #endif
+
+#if defined(_LARGEFILE64_SOURCE) && !defined(OFF64_T_MAX)
+#define OFF64_T_MAX ((off64_t) ~(((uint64_t) 1) << (8 * sizeof(off64_t) - 1)))
+#endif
+
+#endif

Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c       2015-06-09 19:34:36 UTC (rev 
35902)
+++ libmicrohttpd/src/microhttpd/daemon.c       2015-06-09 19:34:45 UTC (rev 
35903)
@@ -117,7 +117,11 @@
 #define EPOLL_CLOEXEC 0
 #endif
 
+#ifndef INT32_MAX
+#define INT32_MAX ((int32_t)0x7FFFFFFF)
+#endif /* !INT32_MAX */
 
+
 /**
  * Default implementation of the panic function,
  * prints an error message and aborts.
@@ -1078,8 +1082,6 @@
   const size_t requested_size = i;
 #if LINUX
   MHD_socket fd;
-  off_t offset;
-  off_t left;
 #endif
 
   if ( (MHD_INVALID_SOCKET == connection->socket_fd) ||
@@ -1105,14 +1107,27 @@
        (-1 != (fd = connection->response->fd)) )
     {
       /* can use sendfile */
-      offset = (off_t) connection->response_write_position + 
connection->response->fd_off;
+      uint64_t left;
+#ifndef HAVE_SENDFILE64
+      uint64_t offsetu64;
+      off_t offset;
+#else  /* HAVE_SENDFILE64 */
+      uint64_t offsetu64;
+      off64_t offset;
+#endif /* HAVE_SENDFILE64 */
+      offsetu64 = connection->response_write_position + 
connection->response->fd_off;
       left = connection->response->total_size - 
connection->response_write_position;
       if (i > left)
         i = left;
-      if (0 < (ret = sendfile (connection->socket_fd,
-                                fd,
-                                &offset,
-                                i)))
+#ifndef HAVE_SENDFILE64
+      offset = (off_t) offsetu64;
+      if ( (offsetu64 <= (uint64_t)OFF_T_MAX) &&
+           0 < (ret = sendfile (connection->socket_fd, fd, &offset, i)))
+#else  /* HAVE_SENDFILE64 */
+      offset = (off64_t) offsetu64;
+      if ( (offsetu64 <= (uint64_t)OFF64_T_MAX) &&
+          0 < (ret = sendfile64 (connection->socket_fd, fd, &offset, i)))
+#endif /* HAVE_SENDFILE64 */
        {
 #if EPOLL_SUPPORT
           if (requested_size > (size_t) ret)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]