[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] branch master updated: Fixed sending on Lin
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] branch master updated: Fixed sending on Linux responses backed with file which is not supported by sendfile() |
Date: |
Sat, 26 Nov 2016 13:20:23 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
The following commit(s) were added to refs/heads/master by this push:
new b3f1a95 Fixed sending on Linux responses backed with file which is
not supported by sendfile()
b3f1a95 is described below
commit b3f1a958ce613f304234ecb6506976db26c117dc
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Sat Nov 26 15:18:48 2016 +0300
Fixed sending on Linux responses backed with file which is not supported by
sendfile()
---
src/microhttpd/connection.c | 11 +++++++++--
src/microhttpd/daemon.c | 3 ++-
src/microhttpd/internal.h | 8 ++++++++
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 186e9dd..e6a26ef 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -681,8 +681,7 @@ try_ready_normal_body (struct MHD_Connection *connection)
connection->response_write_position) )
return MHD_YES; /* response already ready */
#if LINUX
- if ( (MHD_INVALID_SOCKET != response->fd) &&
- (0 == (connection->daemon->options & MHD_USE_TLS)) )
+ if (MHD_resp_sender_sendfile == connection->resp_sender)
{
/* will use sendfile, no need to bother response crc */
return MHD_YES;
@@ -3488,6 +3487,14 @@ MHD_queue_response (struct MHD_Connection *connection,
MHD_increment_response_rc (response);
connection->response = response;
connection->responseCode = status_code;
+#if LINUX
+ if ( (response->fd == -1) ||
+ (0 != (connection->daemon->options & MHD_USE_TLS)) )
+ connection->resp_sender = MHD_resp_sender_std;
+ else
+ connection->resp_sender = MHD_resp_sender_sendfile;
+#endif /* LINUX */
+
if ( ( (NULL != connection->method) &&
(MHD_str_equal_caseless_ (connection->method,
MHD_HTTP_METHOD_HEAD)) ) ||
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 6e97085..1b0a42b 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1852,7 +1852,7 @@ send_param_adapter (struct MHD_Connection *connection,
if ( (connection->write_buffer_append_offset ==
connection->write_buffer_send_offset) &&
(NULL != connection->response) &&
- (-1 != (fd = connection->response->fd)) )
+ (MHD_resp_sender_sendfile == connection->resp_sender) )
{
/* can use sendfile */
uint64_t left;
@@ -1904,6 +1904,7 @@ send_param_adapter (struct MHD_Connection *connection,
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
*/
+ connection->resp_sender = MHD_resp_sender_std;
}
#endif
ret = MHD_send_ (connection->socket_fd,
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index ae63e79..d92f76a 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -752,6 +752,14 @@ struct MHD_Connection
*/
uint64_t response_write_position;
+#if LINUX
+ enum MHD_resp_sender_
+ {
+ MHD_resp_sender_std = 0,
+ MHD_resp_sender_sendfile
+ } resp_sender;
+#endif /* LINUX */
+
/**
* Position in the 100 CONTINUE message that
* we need to send when receiving http 1.1 requests.
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [libmicrohttpd] branch master updated: Fixed sending on Linux responses backed with file which is not supported by sendfile(),
gnunet <=