]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- better module memory lookup, fix of unbound-control shm names for
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 May 2017 14:16:59 +0000 (14:16 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 May 2017 14:16:59 +0000 (14:16 +0000)
  module memory printout of statistics.

git-svn-id: file:///svn/unbound/trunk@4161 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/remote.c
doc/Changelog
libunbound/unbound.h
services/modstack.c
services/modstack.h
smallapp/unbound-control.c
util/shm_side/shm_main.c

index ac5ffbc86346051bf49bdd75724dd6dbbc15e984..01663fad608a23cc8c9d90c3a4f023dff97a2a7d 100644 (file)
@@ -866,7 +866,6 @@ print_longnum(SSL* ssl, const char* desc, size_t x)
 static int
 print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon)
 {
-       int m;
        size_t msg, rrset, val, iter, respip;
 #ifdef CLIENT_SUBNET
        size_t subnet = 0;
@@ -876,47 +875,14 @@ print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon)
 #endif /* USE_IPSECMOD */
        msg = slabhash_get_mem(daemon->env->msg_cache);
        rrset = slabhash_get_mem(&daemon->env->rrset_cache->table);
-       val=0;
-       iter=0;
-       respip=0;
-       m = modstack_find(&worker->env.mesh->mods, "validator");
-       if(m != -1) {
-               fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->
-                       mods.mod[m]->get_mem));
-               val = (*worker->env.mesh->mods.mod[m]->get_mem)
-                       (&worker->env, m);
-       }
-       m = modstack_find(&worker->env.mesh->mods, "iterator");
-       if(m != -1) {
-               fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->
-                       mods.mod[m]->get_mem));
-               iter = (*worker->env.mesh->mods.mod[m]->get_mem)
-                       (&worker->env, m);
-       }
-       m = modstack_find(&worker->env.mesh->mods, "respip");
-       if(m != -1) {
-               fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->
-                       mods.mod[m]->get_mem));
-               respip = (*worker->env.mesh->mods.mod[m]->get_mem)
-                       (&worker->env, m);
-       }
+       val = mod_get_mem(&worker->env, "validator");
+       iter = mod_get_mem(&worker->env, "iterator");
+       respip = mod_get_mem(&worker->env, "respip");
 #ifdef CLIENT_SUBNET
-       m = modstack_find(&worker->env.mesh->mods, "subnet");
-       if(m != -1) {
-               fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->
-                       mods.mod[m]->get_mem));
-               subnet = (*worker->env.mesh->mods.mod[m]->get_mem)
-                       (&worker->env, m);
-       }
+       subnet = mod_get_mem(&worker->env, "subnet");
 #endif /* CLIENT_SUBNET */
 #ifdef USE_IPSECMOD
-       m = modstack_find(&worker->env.mesh->mods, "ipsecmod");
-       if(m != -1) {
-               fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->
-                       mods.mod[m]->get_mem));
-               ipsecmod = (*worker->env.mesh->mods.mod[m]->get_mem)
-                       (&worker->env, m);
-       }
+       ipsecmod = mod_get_mem(&worker->env, "ipsecmod");
 #endif /* USE_IPSECMOD */
 
        if(!print_longnum(ssl, "mem.cache.rrset"SQ, rrset))
index 10d52f559e01ac9a7a8b72a94e7b4d99f68d08af..ceac7885d1face53577f25a2e8f515ab91c83f8e 100644 (file)
@@ -6,6 +6,8 @@
        - updated dependencies in the makefile.
        - document trust-anchor-signaling in example config file.
        - updated configure, dependencies and flex output.
+       - better module memory lookup, fix of unbound-control shm names for
+         module memory printout of statistics.
 
 12 May 2017: Wouter
        - Adjust servfail by iterator to not store in cache when serve-expired
index bc47b5e464de039b81937d03a81502ce9bdd7a17..d7667d104a0e2c8960598c7375eaf6a4231e6415 100644 (file)
@@ -621,6 +621,7 @@ struct ub_shm_stat_info {
                long long iter;
                long long subnet;
                long long ipsecmod;
+               long long respip;
        } mem;
 };
 
index 8a8aa4e8f97cb137747de7d38b32b612c9bcd876..136245a96838610dce9537ec2c5064b590ee1161 100644 (file)
@@ -243,3 +243,15 @@ modstack_find(struct module_stack* stack, const char* name)
        }
        return -1;
 }
+
+size_t
+mod_get_mem(struct module_env* env, const char* name)
+{
+       int m = modstack_find(&env->mesh->mods, name);
+       if(m != -1) {
+               fptr_ok(fptr_whitelist_mod_get_mem(env->mesh->
+                       mods.mod[m]->get_mem));
+               return (*env->mesh->mods.mod[m]->get_mem)(env, m);
+       }
+       return 0;
+}
index cb8613299abb45f869b264f3cd5a5f4fb4d594b3..3ff01b54d938d192a98ade210a7416542eaeb2cc 100644 (file)
@@ -110,4 +110,7 @@ void modstack_desetup(struct module_stack* stack, struct module_env* env);
  */
 int modstack_find(struct module_stack* stack, const char* name);
 
+/** fetch memory for a module by name, returns 0 if module not there */
+size_t mod_get_mem(struct module_env* env, const char* name);
+
 #endif /* SERVICES_MODSTACK_H */
index 3e4f5dce2d8791faeddff69068cd6552f580b5cb..aa2db4a61dfbc767294a9ded6bc524001a5f8198 100644 (file)
@@ -242,10 +242,14 @@ static void print_mem(struct ub_shm_stat_info* shm_stat)
 {
        PR_LL("mem.cache.rrset", shm_stat->mem.rrset);
        PR_LL("mem.cache.message", shm_stat->mem.msg);
-       PR_LL("mem.cache.iterator", shm_stat->mem.iter);
-       PR_LL("mem.cache.validator", shm_stat->mem.val);
+       PR_LL("mem.mod.iterator", shm_stat->mem.iter);
+       PR_LL("mem.mod.validator", shm_stat->mem.val);
+       PR_LL("mem.mod.respip", shm_stat->mem.respip);
 #ifdef CLIENT_SUBNET
-       PR_LL("mem.cache.subnet", shm_stat->mem.subnet);
+       PR_LL("mem.mod.subnet", shm_stat->mem.subnet);
+#endif
+#ifdef USE_IPSECMOD
+       PR_LL("mem.mod.ipsecmod", shm_stat->mem.ipsecmod);
 #endif
 }
 
index 55b96e5c0a7e336a94e195e6befbf55550b4ae6b..bba2a8396333a118a3a7f7f487da8bdbb4558ccd 100644 (file)
@@ -221,7 +221,6 @@ void shm_main_run(struct worker *worker)
        struct ub_shm_stat_info *shm_stat;
        struct ub_stats_info *stat_total;
        struct ub_stats_info *stat_info;
-       int modstack;
        int offset;
 
        verbose(VERB_DETAIL, "SHM run - worker [%d] - daemon [%p] - timenow(%u) - timeboot(%u)",
@@ -250,40 +249,28 @@ void shm_main_run(struct worker *worker)
 
                shm_stat->mem.msg = (long long)slabhash_get_mem(worker->env.msg_cache);
                shm_stat->mem.rrset = (long long)slabhash_get_mem(&worker->env.rrset_cache->table);
-               shm_stat->mem.val = 0;
-               shm_stat->mem.iter = 0;
-
-               modstack = modstack_find(&worker->env.mesh->mods, "validator");
-               if(modstack != -1) {
-                       fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->mods.mod[modstack]->get_mem));
-                       shm_stat->mem.val = (long long)(*worker->env.mesh->mods.mod[modstack]->get_mem)(&worker->env, modstack);
-               }
-               modstack = modstack_find(&worker->env.mesh->mods, "iterator");
-               if(modstack != -1) {
-                       fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->mods.mod[modstack]->get_mem));
-                       shm_stat->mem.iter = (long long)(*worker->env.mesh->mods.mod[modstack]->get_mem)(&worker->env, modstack);
-               }
+               shm_stat->mem.val = (long long)mod_get_mem(&worker->env,
+                       "validator");
+               shm_stat->mem.iter = (long long)mod_get_mem(&worker->env,
+                       "iterator");
+               shm_stat->mem.respip = (long long)mod_get_mem(&worker->env,
+                       "respip");
+
                /* subnet mem value is available in shm, also when not enabled,
                 * to make the struct easier to memmap by other applications,
                 * independent of the configuration of unbound */
                shm_stat->mem.subnet = 0;
 #ifdef CLIENT_SUBNET
-               modstack = modstack_find(&worker->env.mesh->mods, "subnet");
-               if(modstack != -1) {
-                       fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->mods.mod[modstack]->get_mem));
-                       shm_stat->mem.subnet = (long long)(*worker->env.mesh->mods.mod[modstack]->get_mem)(&worker->env, modstack);
-               }
+               shm_stat->mem.subnet = (long long)mod_get_mem(&worker->env,
+                       "subnet");
 #endif
                /* ipsecmod mem value is available in shm, also when not enabled,
                 * to make the struct easier to memmap by other applications,
                 * independent of the configuration of unbound */
                shm_stat->mem.ipsecmod = 0;
 #ifdef USE_IPSECMOD
-               modstack = modstack_find(&worker->env.mesh->mods, "ipsecmod");
-               if(modstack != -1) {
-                       fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh->mods.mod[modstack]->get_mem));
-                       shm_stat->mem.ipsecmod = (*worker->env.mesh->mods.mod[modstack]->get_mem)(&worker->env, modstack);
-               }
+               shm_stat->mem.ipsecmod = (long long)mod_get_mem(&worker->env,
+                       "ipsecmod");
 #endif
        }