degesch: add a hidden LOMEM compile option

This commit is contained in:
Přemysl Eric Janouch 2020-10-20 02:02:09 +02:00
parent 383f6af344
commit 98e95de90e
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 21 additions and 1 deletions

View File

@ -1904,6 +1904,8 @@ struct plugin
struct plugin_vtable struct plugin_vtable
{ {
/// Collect garbage
void (*gc) (struct plugin *self);
/// Unregister and free the plugin including all relevant resources /// Unregister and free the plugin including all relevant resources
void (*free) (struct plugin *self); void (*free) (struct plugin *self);
}; };
@ -5382,6 +5384,9 @@ transport_tls_init_ctx (struct server *s, SSL_CTX *ssl_ctx, struct error **e)
#ifdef SSL_OP_NO_COMPRESSION #ifdef SSL_OP_NO_COMPRESSION
SSL_CTX_set_options (ssl_ctx, SSL_OP_NO_COMPRESSION); SSL_CTX_set_options (ssl_ctx, SSL_OP_NO_COMPRESSION);
#endif // SSL_OP_NO_COMPRESSION #endif // SSL_OP_NO_COMPRESSION
#ifdef LOMEM
SSL_CTX_set_mode (ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
#endif // LOMEM
struct error *error = NULL; struct error *error = NULL;
if (!transport_tls_init_ca (s, ssl_ctx, &error)) if (!transport_tls_init_ca (s, ssl_ctx, &error))
@ -8437,6 +8442,13 @@ struct lua_plugin
struct lua_schema_item *schemas; ///< Registered schema items struct lua_schema_item *schemas; ///< Registered schema items
}; };
static void
lua_plugin_gc (struct plugin *self_)
{
struct lua_plugin *self = (struct lua_plugin *) self_;
lua_gc (self->L, LUA_GCCOLLECT);
}
static void static void
lua_plugin_free (struct plugin *self_) lua_plugin_free (struct plugin *self_)
{ {
@ -8446,6 +8458,7 @@ lua_plugin_free (struct plugin *self_)
struct plugin_vtable lua_plugin_vtable = struct plugin_vtable lua_plugin_vtable =
{ {
.gc = lua_plugin_gc,
.free = lua_plugin_free, .free = lua_plugin_free,
}; };
@ -13821,7 +13834,14 @@ on_flush_timer (struct app_context *ctx)
"Log write failure detected for #s", buffer->name); "Log write failure detected for #s", buffer->name);
} }
// TODO: maybe also garbage collect all plugins? #ifdef LOMEM
// Lua should normally be reasonable and collect garbage when needed,
// though we can try to push it. This is a reasonable place.
LIST_FOR_EACH (struct plugin, iter, ctx->plugins)
if (iter->vtable->gc)
iter->vtable->gc (iter);
#endif // LOMEM
rearm_flush_timer (ctx); rearm_flush_timer (ctx);
} }