[TLS] release openssl buffers as used (fixes #1265, fixes #1283, #881)

use SSL_MODE_RELEASE_BUFFERS (OpenSSL >= 1.0.0) to free buffers
as they are used, to potentially reduce memory footprint of
idle SSL connections

x-ref:
  "memory usage when ssl.engine used and large data uploaded through CGI"
  https://redmine.lighttpd.net/issues/881
  "SSL + file upload = lots of memory"
  https://redmine.lighttpd.net/issues/1265
  "Memory usage increases when proxy+ssl+large file"
  https://redmine.lighttpd.net/issues/1283
personal/stbuehler/mod-csrf-old
Glenn Strauss 7 years ago
parent 53f550b290
commit 5ab7944d34

@ -714,6 +714,9 @@ int network_init(server *srv) {
specific_config *s = srv->config_storage[i];
#ifndef SSL_OP_NO_COMPRESSION
# define SSL_OP_NO_COMPRESSION 0
#endif
#ifndef SSL_MODE_RELEASE_BUFFERS /* OpenSSL >= 1.0.0 */
#define SSL_MODE_RELEASE_BUFFERS 0
#endif
long ssloptions =
SSL_OP_ALL | SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION | SSL_OP_NO_COMPRESSION;
@ -937,7 +940,10 @@ int network_init(server *srv) {
return -1;
}
SSL_CTX_set_default_read_ahead(s->ssl_ctx, 1);
SSL_CTX_set_mode(s->ssl_ctx, SSL_CTX_get_mode(s->ssl_ctx) | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
SSL_CTX_set_mode(s->ssl_ctx, SSL_CTX_get_mode(s->ssl_ctx)
| SSL_MODE_ENABLE_PARTIAL_WRITE
| SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
| SSL_MODE_RELEASE_BUFFERS);
# ifndef OPENSSL_NO_TLSEXT
if (!SSL_CTX_set_tlsext_servername_callback(s->ssl_ctx, network_ssl_servername_callback) ||

Loading…
Cancel
Save