diff options
author | Federico Ceratto <federico.ceratto@gmail.com> | 2018-03-27 21:28:27 +0000 |
---|---|---|
committer | Federico Ceratto <federico.ceratto@gmail.com> | 2018-03-27 21:28:27 +0000 |
commit | eb7cc2640201f168bbd9a05799fd2dbe823bb57c (patch) | |
tree | 1f88da02b7ee3c16ced7b5f7dc4aadb190766e7c /src/adaptive_resortable_list.c | |
parent | Release v. 1.9.0+dfsg-1 to Unstable (diff) | |
parent | New upstream version 1.10.0+dfsg (diff) | |
download | netdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.tar.xz netdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.zip |
Update upstream source from tag 'upstream/1.10.0+dfsg'
Update to upstream version '1.10.0+dfsg'
with Debian dir fa5485f3d9aea3038a19eff06ba33374ac5c5d7c
Diffstat (limited to 'src/adaptive_resortable_list.c')
-rw-r--r-- | src/adaptive_resortable_list.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/adaptive_resortable_list.c b/src/adaptive_resortable_list.c index add1d8c96..c564efff3 100644 --- a/src/adaptive_resortable_list.c +++ b/src/adaptive_resortable_list.c @@ -96,9 +96,14 @@ void arl_begin(ARL_BASE *base) { } #endif - if(unlikely(base->added || base->iteration % base->rechecks) == 1) { + if(unlikely(base->iteration > 0 && (base->added || (base->iteration % base->rechecks) == 0))) { + int wanted_equals_expected = ((base->iteration % base->rechecks) == 0); + + // fprintf(stderr, "\n\narl_begin() rechecking, added %zu, iteration %zu, rechecks %zu, wanted_equals_expected %d\n\n\n", base->added, base->iteration, base->rechecks, wanted_equals_expected); + base->added = 0; - base->wanted = 0; + base->wanted = (wanted_equals_expected)?base->expected:0; + ARL_ENTRY *e = base->head; while(e) { if(e->flags & ARL_ENTRY_FLAG_FOUND) { @@ -107,7 +112,7 @@ void arl_begin(ARL_BASE *base) { e->flags &= ~ARL_ENTRY_FLAG_FOUND; // count it in wanted - if(e->flags & ARL_ENTRY_FLAG_EXPECTED) + if(!wanted_equals_expected && e->flags & ARL_ENTRY_FLAG_EXPECTED) base->wanted++; } @@ -155,10 +160,11 @@ void arl_begin(ARL_BASE *base) { // register an expected keyword to the ARL // together with its destination ( i.e. the output of the processor() ) -ARL_ENTRY *arl_expect(ARL_BASE *base, const char *keyword, void *dst) { +ARL_ENTRY *arl_expect_custom(ARL_BASE *base, const char *keyword, void (*processor)(const char *name, uint32_t hash, const char *value, void *dst), void *dst) { ARL_ENTRY *e = callocz(1, sizeof(ARL_ENTRY)); e->name = strdupz(keyword); e->hash = simple_hash(e->name); + e->processor = (processor)?processor:base->processor; e->dst = dst; e->flags = ARL_ENTRY_FLAG_EXPECTED; e->prev = NULL; @@ -198,7 +204,7 @@ int arl_find_or_create_and_relink(ARL_BASE *base, const char *s, const char *val // run the processor for it if(unlikely(e->dst)) { - base->processor(e->name, hash, value, e->dst); + e->processor(e->name, hash, value, e->dst); base->found++; } @@ -254,8 +260,10 @@ int arl_find_or_create_and_relink(ARL_BASE *base, const char *s, const char *val if(unlikely(!base->next_keyword)) base->next_keyword = base->head; - if(unlikely(base->found == base->wanted)) + if(unlikely(base->found == base->wanted)) { + // fprintf(stderr, "FOUND ALL WANTED 1: found = %zu, wanted = %zu, expected %zu\n", base->found, base->wanted, base->expected); return 1; + } return 0; } |