[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 01/02: mhd_send: fixed broken sendfile() on FreeBSD, v0
From: |
gnunet |
Subject: |
[libmicrohttpd] 01/02: mhd_send: fixed broken sendfile() on FreeBSD, v0.9.67 regression |
Date: |
Thu, 15 Oct 2020 16:11:52 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 16d9f9e426a8ea1f5c05a21554824b7981c0df3b
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Oct 15 12:55:24 2020 +0300
mhd_send: fixed broken sendfile() on FreeBSD, v0.9.67 regression
---
src/microhttpd/connection.c | 41 --------------------
src/microhttpd/connection.h | 10 -----
src/microhttpd/daemon.c | 3 +-
src/microhttpd/mhd_send.c | 91 ++++++++++++++++++++++++++++++++-------------
src/microhttpd/mhd_send.h | 21 ++++-------
5 files changed, 76 insertions(+), 90 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 5d7f52fb..98e58123 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -125,47 +125,6 @@
*/
#define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000)
-#ifdef HAVE_FREEBSD_SENDFILE
-#ifdef SF_FLAGS
-/**
- * FreeBSD sendfile() flags
- */
-static int freebsd_sendfile_flags_;
-
-/**
- * FreeBSD sendfile() flags for thread-per-connection
- */
-static int freebsd_sendfile_flags_thd_p_c_;
-#endif /* SF_FLAGS */
-/**
- * Initialises static variables
- */
-void
-MHD_conn_init_static_ (void)
-{
-/* FreeBSD 11 and later allow to specify read-ahead size
- * and handles SF_NODISKIO differently.
- * SF_FLAGS defined only on FreeBSD 11 and later. */
-#ifdef SF_FLAGS
- long sys_page_size = sysconf (_SC_PAGESIZE);
- if (0 > sys_page_size)
- { /* Failed to get page size. */
- freebsd_sendfile_flags_ = SF_NODISKIO;
- freebsd_sendfile_flags_thd_p_c_ = SF_NODISKIO;
- }
- else
- {
- freebsd_sendfile_flags_ =
- SF_FLAGS ((uint16_t) (MHD_SENFILE_CHUNK_ / sys_page_size), SF_NODISKIO);
- freebsd_sendfile_flags_thd_p_c_ =
- SF_FLAGS ((uint16_t) (MHD_SENFILE_CHUNK_THR_P_C_ / sys_page_size),
- SF_NODISKIO);
- }
-#endif /* SF_FLAGS */
-}
-
-
-#endif /* HAVE_FREEBSD_SENDFILE */
/**
* Callback for receiving data from the socket.
*
diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h
index 29724a24..8b1a0946 100644
--- a/src/microhttpd/connection.h
+++ b/src/microhttpd/connection.h
@@ -62,16 +62,6 @@
#define MHD_ERR_INVAL_ (-3078)
-#ifdef HAVE_FREEBSD_SENDFILE
-/**
- * Initialises static variables
- */
-void
-MHD_conn_init_static_ (void);
-
-#endif /* HAVE_FREEBSD_SENDFILE */
-
-
/**
* Set callbacks for this connection to those for HTTP.
*
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 6888db28..2eefdef5 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -42,6 +42,7 @@
#include "mhd_sockets.h"
#include "mhd_itc.h"
#include "mhd_compat.h"
+#include "mhd_send.h"
#if HAVE_SEARCH_H
#include <search.h>
@@ -7496,7 +7497,7 @@ MHD_init (void)
#endif /* HTTPS_SUPPORT */
MHD_monotonic_sec_counter_init ();
#ifdef HAVE_FREEBSD_SENDFILE
- MHD_conn_init_static_ ();
+ MHD_send_init_static_vars_ ();
#endif /* HAVE_FREEBSD_SENDFILE */
MHD_init_mem_pools_ ();
}
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 335aa13a..987a694b 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -36,8 +36,74 @@
* and every place where sendfile(), sendfile64(), setsockopt()
* are used. */
+#ifdef MHD_LINUX_SOLARIS_SENDFILE
+#include <sys/sendfile.h>
+#endif /* MHD_LINUX_SOLARIS_SENDFILE */
+#if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE)
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#endif /* HAVE_FREEBSD_SENDFILE || HAVE_DARWIN_SENDFILE */
+#ifdef HAVE_SYS_PARAM_H
+/* For FreeBSD version identification */
+#include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
#include "mhd_send.h"
+
+/**
+ * sendfile() chuck size
+ */
+#define MHD_SENFILE_CHUNK_ (0x20000)
+
+/**
+ * sendfile() chuck size for thread-per-connection
+ */
+#define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000)
+
+#ifdef HAVE_FREEBSD_SENDFILE
+#ifdef SF_FLAGS
+/**
+ * FreeBSD sendfile() flags
+ */
+static int freebsd_sendfile_flags_;
+
+/**
+ * FreeBSD sendfile() flags for thread-per-connection
+ */
+static int freebsd_sendfile_flags_thd_p_c_;
+#endif /* SF_FLAGS */
+/**
+ * Initialises static variables
+ */
+void
+MHD_send_init_static_vars_ (void)
+{
+/* FreeBSD 11 and later allow to specify read-ahead size
+ * and handles SF_NODISKIO differently.
+ * SF_FLAGS defined only on FreeBSD 11 and later. */
+#ifdef SF_FLAGS
+ long sys_page_size = sysconf (_SC_PAGESIZE);
+ if (0 > sys_page_size)
+ { /* Failed to get page size. */
+ freebsd_sendfile_flags_ = SF_NODISKIO;
+ freebsd_sendfile_flags_thd_p_c_ = SF_NODISKIO;
+ }
+ else
+ {
+ freebsd_sendfile_flags_ =
+ SF_FLAGS ((uint16_t) (MHD_SENFILE_CHUNK_ / sys_page_size), SF_NODISKIO);
+ freebsd_sendfile_flags_thd_p_c_ =
+ SF_FLAGS ((uint16_t) (MHD_SENFILE_CHUNK_THR_P_C_ / sys_page_size),
+ SF_NODISKIO);
+ }
+#endif /* SF_FLAGS */
+}
+
+
+#endif /* HAVE_FREEBSD_SENDFILE */
+
+
/**
* Handle setsockopt calls.
*
@@ -471,31 +537,6 @@ MHD_send_on_connection2_ (struct MHD_Connection
*connection,
}
-/**
- * sendfile() chuck size
- */
-#define MHD_SENFILE_CHUNK_ (0x20000)
-
-/**
- * sendfile() chuck size for thread-per-connection
- */
-#define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000)
-
-#ifdef HAVE_FREEBSD_SENDFILE
-#ifdef SF_FLAGS
-/**
- * FreeBSD sendfile() flags
- */
-static int freebsd_sendfile_flags_;
-
-/**
- * FreeBSD sendfile() flags for thread-per-connection
- */
-static int freebsd_sendfile_flags_thd_p_c_;
-#endif /* SF_FLAGS */
-
-#endif /* HAVE_FREEBSD_SENDFILE */
-
#if defined(_MHD_HAVE_SENDFILE)
/**
* Function for sending responses backed by file FD.
diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h
index 22d934b3..12ac1ac6 100644
--- a/src/microhttpd/mhd_send.h
+++ b/src/microhttpd/mhd_send.h
@@ -39,19 +39,14 @@
#include "connection_https.h"
#endif
-#ifdef MHD_LINUX_SOLARIS_SENDFILE
-#include <sys/sendfile.h>
-#endif /* MHD_LINUX_SOLARIS_SENDFILE */
-#if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE)
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#endif /* HAVE_FREEBSD_SENDFILE || HAVE_DARWIN_SENDFILE */
-
-#ifdef HAVE_SYS_PARAM_H
-/* For FreeBSD version identification */
-#include <sys/param.h>
-#endif /* HAVE_SYS_PARAM_H */
+#ifdef HAVE_FREEBSD_SENDFILE
+/**
+ * Initialises static variables
+ */
+void
+MHD_send_init_static_vars_ (void);
+
+#endif /* HAVE_FREEBSD_SENDFILE */
/**
* The enumeration of send socket options.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.