Browse Source

added profile_mem action that dumps memory stats to stdout, enable with LIGHTY_PROFILE_MEM=true env var

personal/stbuehler/wip
Thomas Porzelt 14 years ago
parent
commit
b5f2442d5f
  1. 5
      src/lighttpd.c
  2. 21
      src/plugin_core.c

5
src/lighttpd.c

@ -30,6 +30,11 @@ int main(int argc, char *argv[]) {
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
/* check for environment variable LIGHTY_PROFILE_MEM */
gchar *profile_mem = getenv("LIGHTY_PROFILE_MEM");
if (profile_mem != NULL && g_str_equal(profile_mem, "true")) {
g_mem_set_vtable(glib_mem_profiler_table);
}
/* parse commandline options */
context = g_option_context_new("- fast and lightweight webserver");

21
src/plugin_core.c

@ -283,6 +283,26 @@ static action* core_blank(server *srv, plugin* p, value *val) {
return action_new_function(core_handle_blank, NULL, NULL);
}
static action_result core_handle_profile_mem(connection *con, gpointer param) {
UNUSED(con);
UNUSED(param);
g_mem_profile();
return ACTION_GO_ON;
}
static action* core_profile_mem(server *srv, plugin* p, value *val) {
UNUSED(p);
if (val) {
ERROR(srv, "%s", "'profile_mem' action doesn't have parameters");
return NULL;
}
return action_new_function(core_handle_profile_mem, NULL, NULL);
}
static gboolean core_listen(server *srv, plugin* p, value *val) {
guint32 ipv4;
guint8 ipv6[16];
@ -706,6 +726,7 @@ static const plugin_action actions[] = {
{ "test", core_test },
{ "blank", core_blank },
{ "profile_mem", core_profile_mem },
{ "header_add", core_header_add },
{ "header_append", core_header_append },

Loading…
Cancel
Save