From 04b32fa734d491e7ae9b915dc309858310d96185 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sat, 1 Jan 2011 01:12:09 +0000 Subject: Don't reset the activity timer for unattached sessions every second, this screws up the choice of most-recently-used. Instead, break the time update into a little function and do it when the session is attached. Pointed out by joshe@. --- session.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'session.c') diff --git a/session.c b/session.c index 473f1bc6..fc0d9f07 100644 --- a/session.c +++ b/session.c @@ -97,7 +97,7 @@ session_create(const char *name, const char *cmd, const char *cwd, if (gettimeofday(&s->creation_time, NULL) != 0) fatal("gettimeofday failed"); - memcpy(&s->activity_time, &s->creation_time, sizeof s->activity_time); + session_update_activity(s); s->cwd = xstrdup(cwd); @@ -164,6 +164,14 @@ session_destroy(struct session *s) RB_INSERT(sessions, &dead_sessions, s); } +/* Update session active time. */ +void +session_update_activity(struct session *s) +{ + if (gettimeofday(&s->activity_time, NULL) != 0) + fatal("gettimeofday"); +} + /* Find the next usable session. */ struct session * session_next_session(struct session *s) -- cgit