gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14459 - in libmicrohttpd: . src/daemon src/include


From: gnunet
Subject: [GNUnet-SVN] r14459 - in libmicrohttpd: . src/daemon src/include
Date: Fri, 18 Feb 2011 11:05:26 +0100

Author: grothoff
Date: 2011-02-18 11:05:26 +0100 (Fri, 18 Feb 2011)
New Revision: 14459

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/daemon/daemon.c
   libmicrohttpd/src/include/microhttpd.h
Log:
try to handle sendfile corner cases better

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2011-02-18 04:56:17 UTC (rev 14458)
+++ libmicrohttpd/ChangeLog     2011-02-18 10:05:26 UTC (rev 14459)
@@ -1,3 +1,8 @@
+Fri Feb 18 11:03:59 CET 2011
+       Handle large (>2 GB) file transfers with sendfile on 32-bit
+       systems better; handle odd sendfile failures by libc/kernel
+       by falling back to standard 'SEND'. -CG
+
 Sun Feb 13 10:52:29 CET 2011
        Handle gnutls receive error(s) for interrupted SSL
        connections better. -MS

Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c   2011-02-18 04:56:17 UTC (rev 14458)
+++ libmicrohttpd/src/daemon/daemon.c   2011-02-18 10:05:26 UTC (rev 14459)
@@ -709,7 +709,8 @@
 #if LINUX
   int fd;
   off_t offset;
-  int ret;
+  off_t left;
+  ssize_t ret;
 #endif
   if (connection->socket_fd == -1)
     return -1;
@@ -723,14 +724,28 @@
     {
       /* can use sendfile */
       offset = (off_t) connection->response_write_position + 
connection->response->fd_off;
+      left = connection->response->total_size - offset;
+      if (left > SSIZE_MAX)
+       left = SSIZE_MAX; /* cap at return value limit */
       ret = sendfile (connection->socket_fd, 
                      fd,
                      &offset,
-                     connection->response->total_size - offset);
-      if ( (ret == -1) &&
-          (errno == EINTR) )
-       return 0;
-      return ret;
+                     left);
+      if (ret != -1)
+       return ret;
+      if (ret == -1) 
+       {
+         if (EINTR == errno) 
+           return 0;
+         if ( (EINVAL == errno) ||
+              (EBADF == errno) ||
+              (EAGAIN == errno) )
+           return -1; 
+         /* None of the 'usual' sendfile errors occurred, so we should try
+            to fall back to 'SEND'; see also this thread for info on
+            odd libc/Linux behavior with sendfile:
+            
http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */
+       }
     }
 #endif
   return SEND (connection->socket_fd, other, i, MSG_NOSIGNAL | MSG_DONTWAIT);

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2011-02-18 04:56:17 UTC (rev 
14458)
+++ libmicrohttpd/src/include/microhttpd.h      2011-02-18 10:05:26 UTC (rev 
14459)
@@ -106,7 +106,7 @@
 /**
  * Current version of the library.
  */
-#define MHD_VERSION 0x00090700
+#define MHD_VERSION 0x00090701
 
 /**
  * MHD-internal return code for "YES".




reply via email to

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