Skip to content

Commit

Permalink
Polish timeout handling
Browse files Browse the repository at this point in the history
The abs() function may not be needed, and the !reverse condition is
really hard to follow. Bonus point, the way the if statement is broken
doesn't comply with our code style (it came from stud).

Refs #297
Refs #298
dridi committed Feb 19, 2019
1 parent 033d229 commit a63a6a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hitch.c
Original file line number Diff line number Diff line change
@@ -461,8 +461,9 @@ handle_shcupd(struct ev_loop *loop, ev_io *w, int revents)
/* drop too unsync updates */
r -= sizeof(uint32_t);
encdate = *((uint32_t *)&msg[r]);
if (!(abs((int)(int32_t)now - ntohl(encdate))
< SSL_CTX_get_timeout(default_ctx->ctx)))
assert(now >= ntohl(encdate));
if ((now - ntohl(encdate)) >=
SSL_CTX_get_timeout(default_ctx->ctx))
continue;

shctx_sess_add(msg, r, now);

0 comments on commit a63a6a4

Please sign in to comment.