From 2ae032ddc4f5eb6d0e7eaa5400c1ffb80e2c0a8d Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 17 Nov 2016 16:28:33 +0100 Subject: lib: Remove dst_api field from rdrbuff blocks Now that we have an rbuff per flow per AP, there is no more need to keep the dst_api in the rdrbuff. This also simplifies the sanitizer in the irmd. --- src/irmd/main.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'src/irmd/main.c') diff --git a/src/irmd/main.c b/src/irmd/main.c index 055e9d8f..13bfa052 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -55,6 +55,7 @@ #include #define IRMD_CLEANUP_TIMER ((IRMD_FLOW_TIMEOUT / 20) * MILLION) /* ns */ +#define SHM_SAN_HOLDOFF 1000 /* ms */ struct ipcp_entry { struct list_head next; @@ -1612,6 +1613,46 @@ void irmd_sig_handler(int sig, siginfo_t * info, void * c) } } +void * shm_sanitize(void * o) +{ + struct list_head * p = NULL; + struct timespec ts = {SHM_SAN_HOLDOFF / 1000, + (SHM_SAN_HOLDOFF % 1000) * MILLION}; + ssize_t idx; + + (void) o; + + while (true) { + shm_rdrbuff_wait_full(irmd->rdrb); + + pthread_rwlock_rdlock(&irmd->state_lock); + pthread_rwlock_wrlock(&irmd->flows_lock); + + list_for_each(p, &irmd->irm_flows) { + struct irm_flow * f = + list_entry(p, struct irm_flow, next); + if (kill(f->n_api, 0) < 0) { + while ((idx = shm_rbuff_read(f->n_rb)) >= 0) + shm_rdrbuff_remove(irmd->rdrb, idx); + continue; + } + + if (kill(f->n_1_api, 0) < 0) { + while ((idx = shm_rbuff_read(f->n_1_rb)) >= 0) + shm_rdrbuff_remove(irmd->rdrb, idx); + continue; + } + } + + pthread_rwlock_unlock(&irmd->flows_lock); + pthread_rwlock_unlock(&irmd->state_lock); + + nanosleep(&ts, NULL); + } + + return (void *) 0; +} + void * irm_sanitize(void * o) { struct timespec now; @@ -2153,7 +2194,7 @@ int main(int argc, char ** argv) pthread_create(&irmd->irm_sanitize, NULL, irm_sanitize, NULL); pthread_create(&irmd->shm_sanitize, NULL, - shm_rdrbuff_sanitize, irmd->rdrb); + shm_sanitize, irmd->rdrb); /* wait for (all of them) to return */ for (t = 0; t < IRMD_THREADPOOL_SIZE; ++t) -- cgit v1.2.3