mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 00:23:08 +01:00
Sync OpenBSD patchset 819:
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@.
This commit is contained in:
parent
09ef2c9f40
commit
d3c04b74ec
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-attach-session.c,v 1.37 2010-12-22 15:36:44 tcunha Exp $ */
|
/* $Id: cmd-attach-session.c,v 1.38 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -74,6 +74,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->curclient->session = s;
|
ctx->curclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
server_redraw_client(ctx->curclient);
|
server_redraw_client(ctx->curclient);
|
||||||
} else {
|
} else {
|
||||||
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
|
||||||
@ -96,6 +97,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_write_session(s, MSG_DETACH, NULL, 0);
|
server_write_session(s, MSG_DETACH, NULL, 0);
|
||||||
|
|
||||||
ctx->cmdclient->session = s;
|
ctx->cmdclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
||||||
|
|
||||||
update = options_get_string(&s->options, "update-environment");
|
update = options_get_string(&s->options, "update-environment");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-new-session.c,v 1.80 2010-12-22 15:31:00 tcunha Exp $ */
|
/* $Id: cmd-new-session.c,v 1.81 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -284,12 +284,14 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (old_s != NULL)
|
if (old_s != NULL)
|
||||||
ctx->cmdclient->last_session = old_s;
|
ctx->cmdclient->last_session = old_s;
|
||||||
ctx->cmdclient->session = s;
|
ctx->cmdclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
server_redraw_client(ctx->cmdclient);
|
server_redraw_client(ctx->cmdclient);
|
||||||
} else {
|
} else {
|
||||||
old_s = ctx->curclient->session;
|
old_s = ctx->curclient->session;
|
||||||
if (old_s != NULL)
|
if (old_s != NULL)
|
||||||
ctx->curclient->last_session = old_s;
|
ctx->curclient->last_session = old_s;
|
||||||
ctx->curclient->session = s;
|
ctx->curclient->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
server_redraw_client(ctx->curclient);
|
server_redraw_client(ctx->curclient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-switch-client.c,v 1.23 2010-12-22 15:31:00 tcunha Exp $ */
|
/* $Id: cmd-switch-client.c,v 1.24 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -173,6 +173,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (c->session != NULL)
|
if (c->session != NULL)
|
||||||
c->last_session = c->session;
|
c->last_session = c->session;
|
||||||
c->session = s;
|
c->session = s;
|
||||||
|
session_update_activity(s);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_check_unattached();
|
server_check_unattached();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-client.c,v 1.49 2010-12-30 22:27:38 tcunha Exp $ */
|
/* $Id: server-client.c,v 1.50 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -760,11 +760,8 @@ server_client_msg_dispatch(struct client *c)
|
|||||||
|
|
||||||
if (gettimeofday(&c->activity_time, NULL) != 0)
|
if (gettimeofday(&c->activity_time, NULL) != 0)
|
||||||
fatal("gettimeofday");
|
fatal("gettimeofday");
|
||||||
if (c->session != NULL) {
|
if (c->session != NULL)
|
||||||
memcpy(&c->session->activity_time,
|
session_update_activity(c->session);
|
||||||
&c->activity_time,
|
|
||||||
sizeof c->session->activity_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
tty_start_tty(&c->tty);
|
tty_start_tty(&c->tty);
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-fn.c,v 1.117 2010-12-25 23:44:37 tcunha Exp $ */
|
/* $Id: server-fn.c,v 1.118 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -396,6 +396,7 @@ server_destroy_session(struct session *s)
|
|||||||
} else {
|
} else {
|
||||||
c->last_session = NULL;
|
c->last_session = NULL;
|
||||||
c->session = s_new;
|
c->session = s_new;
|
||||||
|
session_update_activity(s_new);
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
server.c
14
server.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server.c,v 1.250 2010-12-30 22:39:49 tcunha Exp $ */
|
/* $Id: server.c,v 1.251 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -495,12 +495,8 @@ server_lock_server(void)
|
|||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
if (s->flags & SESSION_UNATTACHED) {
|
if (s->flags & SESSION_UNATTACHED)
|
||||||
if (gettimeofday(&s->activity_time, NULL) != 0)
|
|
||||||
fatal("gettimeofday failed");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
timeout = options_get_number(&s->options, "lock-after-time");
|
timeout = options_get_number(&s->options, "lock-after-time");
|
||||||
if (timeout <= 0 || t <= s->activity_time.tv_sec + timeout)
|
if (timeout <= 0 || t <= s->activity_time.tv_sec + timeout)
|
||||||
return; /* not timed out */
|
return; /* not timed out */
|
||||||
@ -520,12 +516,8 @@ server_lock_sessions(void)
|
|||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
RB_FOREACH(s, sessions, &sessions) {
|
RB_FOREACH(s, sessions, &sessions) {
|
||||||
if (s->flags & SESSION_UNATTACHED) {
|
if (s->flags & SESSION_UNATTACHED)
|
||||||
if (gettimeofday(&s->activity_time, NULL) != 0)
|
|
||||||
fatal("gettimeofday failed");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
timeout = options_get_number(&s->options, "lock-after-time");
|
timeout = options_get_number(&s->options, "lock-after-time");
|
||||||
if (timeout > 0 && t > s->activity_time.tv_sec + timeout) {
|
if (timeout > 0 && t > s->activity_time.tv_sec + timeout) {
|
||||||
server_lock_session(s);
|
server_lock_session(s);
|
||||||
|
12
session.c
12
session.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: session.c,v 1.84 2010-12-30 22:39:49 tcunha Exp $ */
|
/* $Id: session.c,v 1.85 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -96,7 +96,7 @@ session_create(const char *name, const char *cmd, const char *cwd,
|
|||||||
|
|
||||||
if (gettimeofday(&s->creation_time, NULL) != 0)
|
if (gettimeofday(&s->creation_time, NULL) != 0)
|
||||||
fatal("gettimeofday failed");
|
fatal("gettimeofday failed");
|
||||||
memcpy(&s->activity_time, &s->creation_time, sizeof s->activity_time);
|
session_update_activity(s);
|
||||||
|
|
||||||
s->cwd = xstrdup(cwd);
|
s->cwd = xstrdup(cwd);
|
||||||
|
|
||||||
@ -163,6 +163,14 @@ session_destroy(struct session *s)
|
|||||||
RB_INSERT(sessions, &dead_sessions, 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. */
|
/* Find the next usable session. */
|
||||||
struct session *
|
struct session *
|
||||||
session_next_session(struct session *s)
|
session_next_session(struct session *s)
|
||||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.596 2010-12-31 22:12:33 nicm Exp $ */
|
/* $Id: tmux.h,v 1.597 2011-01-03 23:27:54 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1974,6 +1974,7 @@ struct session *session_create(const char *, const char *, const char *,
|
|||||||
struct environ *, struct termios *, int, u_int, u_int,
|
struct environ *, struct termios *, int, u_int, u_int,
|
||||||
char **);
|
char **);
|
||||||
void session_destroy(struct session *);
|
void session_destroy(struct session *);
|
||||||
|
void session_update_activity(struct session *);
|
||||||
struct session *session_next_session(struct session *);
|
struct session *session_next_session(struct session *);
|
||||||
struct session *session_previous_session(struct session *);
|
struct session *session_previous_session(struct session *);
|
||||||
struct winlink *session_new(struct session *,
|
struct winlink *session_new(struct session *,
|
||||||
|
Loading…
Reference in New Issue
Block a user