summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-08-22 14:58:12 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-22 15:00:56 +0200
commit514791e5c6ded690aaf6dc43709dd02bc6a2ff6a (patch)
treeb751a94678188772c5772261549fe772a7872427 /src/lib/dev.c
parent911a0ba062f7fd9debfebd330e94ff7de6ac1101 (diff)
downloadouroboros-514791e5c6ded690aaf6dc43709dd02bc6a2ff6a.tar.gz
ouroboros-514791e5c6ded690aaf6dc43709dd02bc6a2ff6a.zip
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.
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c21
1 files changed, 13 insertions, 8 deletions
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.