diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-11-03 22:40:40 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-11-03 22:40:40 +0000 |
commit | 0785f2872f0f41f15c1c67bb1f6bfb4e1baba180 (patch) | |
tree | e70da6caef1a14e083cc99e414fb25754bb46978 /server-client.c | |
parent | 5761ab6b555db9ec16e79722897c09685a03f9d5 (diff) | |
download | rtmux-0785f2872f0f41f15c1c67bb1f6bfb4e1baba180.tar.gz rtmux-0785f2872f0f41f15c1c67bb1f6bfb4e1baba180.tar.bz2 rtmux-0785f2872f0f41f15c1c67bb1f6bfb4e1baba180.zip |
Add an activity time for clients, like for sessions, and change session and
client lookup to pick the most recently used rather than the most recently
created - this is much more useful when used interactively and (because the
activity time is set at creation) should have no effect on source-file.
Based on a problem reported by Jan Johansson.
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/server-client.c b/server-client.c index a337c6b2..3ff16e25 100644 --- a/server-client.c +++ b/server-client.c @@ -63,6 +63,7 @@ server_client_create(int fd) if (gettimeofday(&c->creation_time, NULL) != 0) fatal("gettimeofday failed"); + memcpy(&c->activity_time, &c->creation_time, sizeof c->activity_time); ARRAY_INIT(&c->prompt_hdata); @@ -287,6 +288,7 @@ server_client_handle_data(struct client *c) oo = &c->session->options; /* Update activity timer. */ + memcpy(&c->activity_time, &tv_now, sizeof c->activity_time); memcpy(&c->session->activity_time, &tv_now, sizeof c->session->activity_time); @@ -583,9 +585,13 @@ server_client_msg_dispatch(struct client *c) break; c->flags &= ~CLIENT_SUSPENDED; - if (c->session != NULL && - gettimeofday(&c->session->activity_time, NULL) != 0) - fatal("gettimeofday failed"); + if (gettimeofday(&c->activity_time, NULL) != 0) + fatal("gettimeofday"); + if (c->session != NULL) { + memcpy(&c->session->activity_time, + &c->activity_time, + sizeof c->session->activity_time); + } tty_start_tty(&c->tty); server_redraw_client(c); |