chiark
/
gitweb
/
~mdw
/
tripe
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
62b5e3e
)
server/keyexch.c: Use high-resolution `struct timeval' timers.
author
Mark Wooding
<mdw@distorted.org.uk>
Wed, 1 Feb 2012 21:10:56 +0000
(21:10 +0000)
committer
Mark Wooding
<mdw@distorted.org.uk>
Wed, 21 Mar 2012 16:11:49 +0000
(16:11 +0000)
server/keyexch.c
patch
|
blob
|
blame
|
history
diff --git
a/server/keyexch.c
b/server/keyexch.c
index cd6eae5263677c00aaf0c6ce56d2b55d3fa8df4b..c27d69fd7cff61df15db5c9c9ef7d58afb8551d0 100644
(file)
--- a/
server/keyexch.c
+++ b/
server/keyexch.c
@@
-265,21
+265,17
@@
static void timer(struct timeval *tv, void *v)
/* --- @settimer@ --- *
*
* Arguments: @keyexch *kx@ = pointer to key exchange context
/* --- @settimer@ --- *
*
* Arguments: @keyexch *kx@ = pointer to key exchange context
- * @
time_t t
@ = when to set the timer for
+ * @
struct timeval *tv
@ = when to set the timer for
*
* Returns: ---
*
* Use: Sets the timer for the next key exchange attempt.
*/
*
* Returns: ---
*
* Use: Sets the timer for the next key exchange attempt.
*/
-static void settimer(keyexch *kx,
time_t t
)
+static void settimer(keyexch *kx,
struct timeval *tv
)
{
{
- struct timeval tv;
- if (kx->f & KXF_TIMER)
- sel_rmtimer(&kx->t);
- tv.tv_sec = t;
- tv.tv_usec = 0;
- sel_addtimer(&sel, &kx->t, &tv, timer, kx);
+ if (kx->f & KXF_TIMER) sel_rmtimer(&kx->t);
+ sel_addtimer(&sel, &kx->t, tv, timer, kx);
kx->f |= KXF_TIMER;
}
kx->f |= KXF_TIMER;
}
@@
-728,6
+724,7
@@
static void resend(keyexch *kx)
kxchal *kxc;
buf bb;
stats *st = p_stats(kx->p);
kxchal *kxc;
buf bb;
stats *st = p_stats(kx->p);
+ struct timeval tv;
buf *b;
switch (kx->s) {
buf *b;
switch (kx->s) {
@@
-770,8
+767,11
@@
static void resend(keyexch *kx)
p_txend(kx->p);
}
p_txend(kx->p);
}
- if (kx->s < KXS_SWITCH)
- settimer(kx, time(0) + T_RETRY);
+ if (kx->s < KXS_SWITCH) {
+ gettimeofday(&tv, 0);
+ tv.tv_sec += T_RETRY;
+ settimer(kx, &tv);
+ }
}
/* --- @decryptrest@ --- *
}
/* --- @decryptrest@ --- *
@@
-912,8
+912,12
@@
bad:
static void kxfinish(keyexch *kx)
{
kxchal *kxc = kx->r[0];
static void kxfinish(keyexch *kx)
{
kxchal *kxc = kx->r[0];
+ struct timeval tv;
+
ks_activate(kxc->ks);
ks_activate(kxc->ks);
- settimer(kx, time(0) + T_REGEN);
+ gettimeofday(&tv, 0);
+ tv.tv_sec += T_REGEN;
+ settimer(kx, &tv);
kx->s = KXS_SWITCH;
a_notify("KXDONE", "?PEER", kx->p, A_END);
p_stats(kx->p)->t_kx = time(0);
kx->s = KXS_SWITCH;
a_notify("KXDONE", "?PEER", kx->p, A_END);
p_stats(kx->p)->t_kx = time(0);
@@
-1160,23
+1164,25
@@
void kx_start(keyexch *kx, int forcep)
void kx_message(keyexch *kx, unsigned msg, buf *b)
{
void kx_message(keyexch *kx, unsigned msg, buf *b)
{
-
time_t now = time(0)
;
+
struct timeval now, tv
;
stats *st = p_stats(kx->p);
size_t sz = BSZ(b);
int rc;
stats *st = p_stats(kx->p);
size_t sz = BSZ(b);
int rc;
+ gettimeofday(&now, 0);
if (kx->f & KXF_CORK) {
if (kx->f & KXF_CORK) {
- start(kx, now);
- settimer(kx, now + T_RETRY);
+ start(kx, now.tv_sec);
+ TV_ADDL(&tv, &now, T_RETRY, 0);
+ settimer(kx, &tv);
a_notify("KXSTART", A_END);
}
if (checkpub(kx))
return;
a_notify("KXSTART", A_END);
}
if (checkpub(kx))
return;
- if (!VALIDP(kx, now)) {
+ if (!VALIDP(kx, now
.tv_sec
)) {
stop(kx);
stop(kx);
- start(kx, now);
+ start(kx, now
.tv_sec
);
}
T( trace(T_KEYEXCH, "keyexch: processing %s packet from `%s'",
msg < KX_NMSG ? pkname[msg] : "unknown", p_name(kx->p)); )
}
T( trace(T_KEYEXCH, "keyexch: processing %s packet from `%s'",
msg < KX_NMSG ? pkname[msg] : "unknown", p_name(kx->p)); )