diff options
| author | Jesper Jensen <jesper@slashwin.dk> | 2021-10-05 22:48:37 +0200 |
|---|---|---|
| committer | Jesper Jensen <jesper@slashwin.dk> | 2021-10-05 22:48:37 +0200 |
| commit | 6e6829ad209550fbac0e363f9421c1fba78915b5 (patch) | |
| tree | a769fdc053e5cd8dabbebe9048725bdc9b6500cc /src/routing.c | |
| parent | e3eb0d2eda0bb8c4decf9bc56b025157e70387c2 (diff) | |
Add getclient timeout
Diffstat (limited to 'src/routing.c')
| -rw-r--r-- | src/routing.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/routing.c b/src/routing.c index 1448f55..d77f87c 100644 --- a/src/routing.c +++ b/src/routing.c @@ -213,6 +213,9 @@ void routing_oldest(struct entry** dest) { if(!entry->set) continue; + if(entry->expire == 0) + continue; + if(*dest == NULL) { *dest = entry; continue; @@ -223,3 +226,25 @@ void routing_oldest(struct entry** dest) { } } } + +void routing_status(int* filled, int* size, double* load_factor, size_t load_factor_len) { + *size = ROUTINGSIZE; + + *filled = 0; + for(size_t i = 0; i < ROUTINGSIZE; i++) { + if(table[i].set) + (*filled)++; + } + + int per_bucket = ROUTINGSIZE / load_factor_len; + int overflow = ROUTINGSIZE % load_factor_len; + struct entry* table_cursor = table; + for(int i = 0; i < load_factor_len; i++) { + int is_overflow = i < overflow; + for(int j = 0; j < per_bucket + is_overflow; j++) { + load_factor[i] += table_cursor->set; + table_cursor++; + } + load_factor[i] /= per_bucket + is_overflow; + } +} |
