From 514791e5c6ded690aaf6dc43709dd02bc6a2ff6a Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 22 Aug 2017 14:58:12 +0200 Subject: lib: Make timerwheel a passive component This turns the timerwheel into a passive component since it is used by application using the library. The user of the timerwheel now has to call timerwheel_move to advance the timerwheel. --- src/lib/dev.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/lib/dev.c') diff --git a/src/lib/dev.c b/src/lib/dev.c index 1018f556..52a56097 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -83,11 +83,7 @@ struct frcti { uint64_t rcv_lwe; uint64_t rcv_rwe; - bool resource_control; - bool reliable; - bool error_check; - bool ordered; - bool partial; + uint8_t conf_flags; }; struct port { @@ -121,7 +117,6 @@ struct { struct shm_flow_set * fqset; struct timerwheel * tw; - int tw_users; struct bmp * fds; struct bmp * fqueues; @@ -317,6 +312,12 @@ static int frcti_write(int fd, frcti = &(ai.frcti[fd]); + pthread_rwlock_unlock(&ai.lock); + + timerwheel_move(ai.tw); + + pthread_rwlock_rdlock(&ai.lock); + /* * Set the DRF in the first packet of a new run of SDUs, * otherwise simply recharge the timer. @@ -337,7 +338,7 @@ static int frcti_write(int fd, pci.seqno = frcti->snd_lwe++; pci.type |= PDU_TYPE_DATA; - if (frct_pci_ser(sdb, &pci, frcti->error_check)) + if (frct_pci_ser(sdb, &pci, frcti->conf_flags & CONF_ERROR_CHECK)) return -1; if (finalize_write(fd, shm_du_buff_get_idx(sdb))) @@ -368,6 +369,8 @@ static ssize_t frcti_read(int fd) struct frct_pci pci; struct shm_du_buff * sdb; + timerwheel_move(ai.tw); + pthread_rwlock_rdlock(&ai.lock); if (ai.flows[fd].oflags & FLOW_O_NONBLOCK) { @@ -399,7 +402,7 @@ static ssize_t frcti_read(int fd) sdb = shm_rdrbuff_get(ai.rdrb, idx); /* SDU may be corrupted. */ - if (frct_pci_des(sdb, &pci, frcti->error_check)) { + if (frct_pci_des(sdb, &pci, frcti->conf_flags & CONF_ERROR_CHECK)) { pthread_rwlock_unlock(&ai.lock); shm_rdrbuff_remove(ai.rdrb, idx); return -1; @@ -460,6 +463,8 @@ static int frcti_event_wait(struct flow_set * set, assert(fq); assert(timeout); + timerwheel_move(ai.tw); + /* * FIXME: Return the fq only if a data SDU * for the application is available. -- cgit v1.2.3