commit b220303691d627ca3cfe0d949c6aa2257b722c60
parent 53674dcdfba0ade96b50672a709edae1eae0323a
Author: silvioprog <silvioprog@gmail.com>
Date: Thu, 6 Dec 2018 12:54:00 -0300
Optimized the function MHD_create_response_from_callback() for Windows by increasing its internal buffer size and allowed to customize it via macro MHD_FD_BLOCK_SIZE.
Diffstat:
5 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,4 +1,9 @@
-Thu Dec 6 02:11:15 -03 2018
+Thu Dec 6 12:50:11 BRT 2018
+ Optimized the function MHD_create_response_from_callback() for
+ Windows by increasing its internal buffer size and allowed to customize
+ it via macro MHD_FD_BLOCK_SIZE. -SC
+
+Thu Dec 6 02:11:15 BRT 2018
Referenced the gnutls_load_file() function in the HTTPs examples. -SC
Wed Dec 5 18:08:59 CET 2018
diff --git a/src/lib/mhd_limits.h b/src/lib/mhd_limits.h
@@ -143,4 +143,12 @@
#endif /* _WIN32 */
#endif /* !TIMEVAL_TV_SEC_MAX */
+#ifndef MHD_FD_BLOCK_SIZE
+#ifdef _WIN32
+#define MHD_FD_BLOCK_SIZE 16384 /* 16k */
+#else /* _WIN32 */
+#define MHD_FD_BLOCK_SIZE 4096 /* 4k */
+#endif /* _WIN32 */
+#endif /* !MHD_FD_BLOCK_SIZE */
+
#endif /* MHD_LIMITS_H */
diff --git a/src/lib/response_from_fd.c b/src/lib/response_from_fd.c
@@ -182,7 +182,7 @@ MHD_response_from_fd (enum MHD_HTTP_StatusCode sc,
response = MHD_response_from_callback (sc,
size,
- 4 * 1024,
+ MHD_FD_BLOCK_SIZE,
&file_reader,
NULL,
&free_callback);
diff --git a/src/microhttpd/mhd_limits.h b/src/microhttpd/mhd_limits.h
@@ -143,4 +143,12 @@
#endif /* _WIN32 */
#endif /* !TIMEVAL_TV_SEC_MAX */
+#ifndef MHD_FD_BLOCK_SIZE
+#ifdef _WIN32
+#define MHD_FD_BLOCK_SIZE 16384 /* 16k */
+#else /* _WIN32 */
+#define MHD_FD_BLOCK_SIZE 4096 /* 4k */
+#endif /* _WIN32 */
+#endif /* !MHD_FD_BLOCK_SIZE */
+
#endif /* MHD_LIMITS_H */
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
@@ -566,7 +566,7 @@ MHD_create_response_from_fd_at_offset64 (uint64_t size,
return NULL;
response = MHD_create_response_from_callback (size,
- 4 * 1024,
+ MHD_FD_BLOCK_SIZE,
&file_reader,
NULL,
&free_callback);