[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/stream_sock.c b/src/stream_sock.c
index e420ace..4691a9c 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -165,8 +165,8 @@
*/
if (b->flags & BF_PARTIAL_READ) {
- if (b->rto) {
- tv_ms_add(&b->rex, &now, b->rto);
+ if (tv_isset(&b->rto)) {
+ tv_add(&b->rex, &now, &b->rto);
goto out_wakeup;
}
out_eternity:
@@ -315,8 +315,8 @@
*/
if (b->flags & BF_PARTIAL_WRITE) {
- if (b->wto) {
- tv_ms_add(&b->wex, &now, b->wto);
+ if (tv_isset(&b->wto)) {
+ tv_add(&b->wex, &now, &b->wto);
/* FIXME: to prevent the client from expiring read timeouts during writes,
* we refresh it. A solution would be to merge read+write timeouts into a
* unique one, although that needs some study particularly on full-duplex