|
@@ -1308,9 +1308,11 @@ enum {
|
|
SSL_CIPHER_LIST,
|
|
SSL_CIPHER_LIST,
|
|
SSL_PROTOCOL_VERSION,
|
|
SSL_PROTOCOL_VERSION,
|
|
SSL_SHORT_TRUST,
|
|
SSL_SHORT_TRUST,
|
|
|
|
+
|
|
#if defined(USE_WEBSOCKET)
|
|
#if defined(USE_WEBSOCKET)
|
|
WEBSOCKET_TIMEOUT,
|
|
WEBSOCKET_TIMEOUT,
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
DECODE_URL,
|
|
DECODE_URL,
|
|
|
|
|
|
#if defined(USE_LUA)
|
|
#if defined(USE_LUA)
|
|
@@ -1328,6 +1330,7 @@ enum {
|
|
#if defined(USE_LUA) && defined(USE_WEBSOCKET)
|
|
#if defined(USE_LUA) && defined(USE_WEBSOCKET)
|
|
LUA_WEBSOCKET_EXTENSIONS,
|
|
LUA_WEBSOCKET_EXTENSIONS,
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
ACCESS_CONTROL_ALLOW_ORIGIN,
|
|
ACCESS_CONTROL_ALLOW_ORIGIN,
|
|
ERROR_PAGES,
|
|
ERROR_PAGES,
|
|
CONFIG_TCP_NODELAY, /* Prepended CONFIG_ to avoid conflict with the
|
|
CONFIG_TCP_NODELAY, /* Prepended CONFIG_ to avoid conflict with the
|
|
@@ -1335,6 +1338,9 @@ enum {
|
|
#if !defined(NO_CACHING)
|
|
#if !defined(NO_CACHING)
|
|
STATIC_FILE_MAX_AGE,
|
|
STATIC_FILE_MAX_AGE,
|
|
#endif
|
|
#endif
|
|
|
|
+#if defined(__linux__)
|
|
|
|
+ ALLOW_SENDFILE_CALL,
|
|
|
|
+#endif
|
|
|
|
|
|
NUM_OPTIONS
|
|
NUM_OPTIONS
|
|
};
|
|
};
|
|
@@ -1409,6 +1415,9 @@ static struct mg_option config_options[] = {
|
|
#if !defined(NO_CACHING)
|
|
#if !defined(NO_CACHING)
|
|
{"static_file_max_age", CONFIG_TYPE_NUMBER, "3600"},
|
|
{"static_file_max_age", CONFIG_TYPE_NUMBER, "3600"},
|
|
#endif
|
|
#endif
|
|
|
|
+#if defined(__linux__)
|
|
|
|
+ {"allow_sendfile_call", CONFIG_TYPE_BOOLEAN, "yes"},
|
|
|
|
+#endif
|
|
|
|
|
|
{NULL, CONFIG_TYPE_UNKNOWN, NULL}};
|
|
{NULL, CONFIG_TYPE_UNKNOWN, NULL}};
|
|
|
|
|
|
@@ -6754,7 +6763,9 @@ send_file_data(struct mg_connection *conn,
|
|
/* file stored on disk */
|
|
/* file stored on disk */
|
|
#if defined(__linux__)
|
|
#if defined(__linux__)
|
|
/* sendfile is only available for Linux */
|
|
/* sendfile is only available for Linux */
|
|
- if (conn->throttle == 0 && conn->ssl == 0) {
|
|
|
|
|
|
+ if ((conn->ssl == 0) && (conn->throttle == 0)
|
|
|
|
+ && (!mg_strcasecmp(conn->ctx->config[ALLOW_SENDFILE_CALL],
|
|
|
|
+ "yes"))) {
|
|
off_t sf_offs = (off_t)offset;
|
|
off_t sf_offs = (off_t)offset;
|
|
ssize_t sf_sent;
|
|
ssize_t sf_sent;
|
|
int sf_file = fileno(filep->fp);
|
|
int sf_file = fileno(filep->fp);
|