aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-20 02:02:09 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-20 02:02:09 +0200
commit98e95de90e79c581d2296084ea23919ed616ad29 (patch)
treee4ddc10944ebf4121d4e8159c1e837f4ee23ba94
parent383f6af344b07a4bc8f510310aaed5eb54f61033 (diff)
downloadxK-98e95de90e79c581d2296084ea23919ed616ad29.tar.gz
xK-98e95de90e79c581d2296084ea23919ed616ad29.tar.xz
xK-98e95de90e79c581d2296084ea23919ed616ad29.zip
degesch: add a hidden LOMEM compile option
-rw-r--r--degesch.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/degesch.c b/degesch.c
index 6d120c2..d96567f 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1904,6 +1904,8 @@ struct plugin
struct plugin_vtable
{
+ /// Collect garbage
+ void (*gc) (struct plugin *self);
/// Unregister and free the plugin including all relevant resources
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
SSL_CTX_set_options (ssl_ctx, 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;
if (!transport_tls_init_ca (s, ssl_ctx, &error))
@@ -8438,6 +8443,13 @@ struct lua_plugin
};
static void
+lua_plugin_gc (struct plugin *self_)
+{
+ struct lua_plugin *self = (struct lua_plugin *) self_;
+ lua_gc (self->L, LUA_GCCOLLECT);
+}
+
+static void
lua_plugin_free (struct plugin *self_)
{
struct lua_plugin *self = (struct lua_plugin *) self_;
@@ -8446,6 +8458,7 @@ lua_plugin_free (struct plugin *self_)
struct plugin_vtable lua_plugin_vtable =
{
+ .gc = lua_plugin_gc,
.free = lua_plugin_free,
};
@@ -13821,7 +13834,14 @@ on_flush_timer (struct app_context *ctx)
"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);
}