[MAJOR] replaced all timeouts with struct timeval
The timeout functions were difficult to manipulate because they were
rounding results to the millisecond. Thus, it was difficult to compare
and to check what expired and what did not. Also, the comparison
functions were heavy with multiplies and divides by 1000. Now, all
timeouts are stored in timevals, reducing the number of operations
for updates and leading to cleaner and more efficient code.
diff --git a/src/appsession.c b/src/appsession.c
index d11fb19..0307ff7 100644
--- a/src/appsession.c
+++ b/src/appsession.c
@@ -125,7 +125,7 @@
return 0;
}
-int appsession_refresh(struct task *t)
+void appsession_refresh(struct task *t, struct timeval *next)
{
struct proxy *p = proxy;
CHTbl *htbl;
@@ -143,7 +143,7 @@
for (element = list_head(&htbl->table[i]);
element != NULL; element = list_next(element)) {
asession = (appsess *)list_data(element);
- if (tv_ms_le2(&asession->expire, &now)) {
+ if (__tv_isle(&asession->expire, &now)) {
if ((global.mode & MODE_DEBUG) &&
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))) {
int len;
@@ -165,7 +165,7 @@
}
else
element = last;
- }/* end if (tv_ms_le2(&asession->expire, &now)) */
+ }/* end if (__tv_isle(&asession->expire, &now)) */
else
last = element;
}/* end for (element = list_head(&htbl->table[i]); element != NULL; element = list_next(element)) */
@@ -174,7 +174,7 @@
p = p->next;
}
tv_ms_add(&t->expire, &now, TBLCHKINT); /* check expiration every 5 seconds */
- return TBLCHKINT;
+ *next = t->expire;
} /* end appsession_refresh */
int match_str(const void *key1, const void *key2)