mirror of
https://github.com/tmux/tmux.git
synced 2025-03-04 15:09:54 +00:00
Change session and client activity and creation time members to have more
meaningful names. Also, remove the code to try and update the session activity time for the command client when a command message is received as is pointless because it des not have a session.
This commit is contained in:
parent
c95f1d1ff9
commit
5289da29ba
@ -61,7 +61,7 @@ cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
xsnprintf(tmp, sizeof tmp, " (group %u)", idx);
|
xsnprintf(tmp, sizeof tmp, " (group %u)", idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
t = s->tv.tv_sec;
|
t = s->creation_time.tv_sec;
|
||||||
tim = ctime(&t);
|
tim = ctime(&t);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
t = s->tv.tv_sec;
|
t = s->creation_time.tv_sec;
|
||||||
tim = ctime(&t);
|
tim = ctime(&t);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
|
8
cmd.c
8
cmd.c
@ -362,9 +362,9 @@ cmd_newest_session(struct sessions *ss)
|
|||||||
if ((s = ARRAY_ITEM(ss, i)) == NULL)
|
if ((s = ARRAY_ITEM(ss, i)) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (tv == NULL || timercmp(&s->tv, tv, >)) {
|
if (tv == NULL || timercmp(&s->creation_time, tv, >)) {
|
||||||
snewest = s;
|
snewest = s;
|
||||||
tv = &s->tv;
|
tv = &s->creation_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,9 +386,9 @@ cmd_newest_client(void)
|
|||||||
if (c->session == NULL)
|
if (c->session == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (tv == NULL || timercmp(&c->tv, tv, >)) {
|
if (tv == NULL || timercmp(&c->creation_time, tv, >)) {
|
||||||
cnewest = c;
|
cnewest = c;
|
||||||
tv = &c->tv;
|
tv = &c->creation_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ server_client_create(int fd)
|
|||||||
c->references = 0;
|
c->references = 0;
|
||||||
imsg_init(&c->ibuf, fd);
|
imsg_init(&c->ibuf, fd);
|
||||||
|
|
||||||
if (gettimeofday(&c->tv, NULL) != 0)
|
if (gettimeofday(&c->creation_time, NULL) != 0)
|
||||||
fatal("gettimeofday failed");
|
fatal("gettimeofday failed");
|
||||||
|
|
||||||
ARRAY_INIT(&c->prompt_hdata);
|
ARRAY_INIT(&c->prompt_hdata);
|
||||||
@ -261,18 +261,19 @@ server_client_handle_data(struct client *c)
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct screen *s;
|
struct screen *s;
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
struct timeval tv;
|
struct timeval tv_add, tv_now;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
struct keylist *keylist;
|
struct keylist *keylist;
|
||||||
struct mouse_event mouse;
|
struct mouse_event mouse;
|
||||||
int key, status, xtimeout, mode, isprefix;
|
int key, status, xtimeout, mode, isprefix;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
|
/* Check and update repeat flag. */
|
||||||
|
if (gettimeofday(&tv_now, NULL) != 0)
|
||||||
|
fatal("gettimeofday failed");
|
||||||
xtimeout = options_get_number(&c->session->options, "repeat-time");
|
xtimeout = options_get_number(&c->session->options, "repeat-time");
|
||||||
if (xtimeout != 0 && c->flags & CLIENT_REPEAT) {
|
if (xtimeout != 0 && c->flags & CLIENT_REPEAT) {
|
||||||
if (gettimeofday(&tv, NULL) != 0)
|
if (timercmp(&tv_now, &c->repeat_timer, >))
|
||||||
fatal("gettimeofday failed");
|
|
||||||
if (timercmp(&tv, &c->repeat_timer, >))
|
|
||||||
c->flags &= ~(CLIENT_PREFIX|CLIENT_REPEAT);
|
c->flags &= ~(CLIENT_PREFIX|CLIENT_REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,12 +282,14 @@ server_client_handle_data(struct client *c)
|
|||||||
while (tty_keys_next(&c->tty, &key, &mouse) == 0) {
|
while (tty_keys_next(&c->tty, &key, &mouse) == 0) {
|
||||||
if (c->session == NULL)
|
if (c->session == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
c->session->activity = time(NULL);
|
|
||||||
w = c->session->curw->window;
|
w = c->session->curw->window;
|
||||||
wp = w->active; /* could die */
|
wp = w->active; /* could die */
|
||||||
oo = &c->session->options;
|
oo = &c->session->options;
|
||||||
|
|
||||||
|
/* Update activity timer. */
|
||||||
|
memcpy(&c->session->activity_time,
|
||||||
|
&tv_now, sizeof c->session->activity_time);
|
||||||
|
|
||||||
/* Special case: number keys jump to pane in identify mode. */
|
/* Special case: number keys jump to pane in identify mode. */
|
||||||
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
|
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
|
||||||
wp = window_pane_at_index(w, key - '0');
|
wp = window_pane_at_index(w, key - '0');
|
||||||
@ -364,11 +367,9 @@ server_client_handle_data(struct client *c)
|
|||||||
if (xtimeout != 0 && bd->can_repeat) {
|
if (xtimeout != 0 && bd->can_repeat) {
|
||||||
c->flags |= CLIENT_PREFIX|CLIENT_REPEAT;
|
c->flags |= CLIENT_PREFIX|CLIENT_REPEAT;
|
||||||
|
|
||||||
tv.tv_sec = xtimeout / 1000;
|
tv_add.tv_sec = xtimeout / 1000;
|
||||||
tv.tv_usec = (xtimeout % 1000) * 1000L;
|
tv_add.tv_usec = (xtimeout % 1000) * 1000L;
|
||||||
if (gettimeofday(&c->repeat_timer, NULL) != 0)
|
timeradd(&tv_now, &tv_add, &c->repeat_timer);
|
||||||
fatal("gettimeofday failed");
|
|
||||||
timeradd(&c->repeat_timer, &tv, &c->repeat_timer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dispatch the command. */
|
/* Dispatch the command. */
|
||||||
@ -581,11 +582,14 @@ server_client_msg_dispatch(struct client *c)
|
|||||||
if (!(c->flags & CLIENT_SUSPENDED))
|
if (!(c->flags & CLIENT_SUSPENDED))
|
||||||
break;
|
break;
|
||||||
c->flags &= ~CLIENT_SUSPENDED;
|
c->flags &= ~CLIENT_SUSPENDED;
|
||||||
|
|
||||||
|
if (c->session != NULL &&
|
||||||
|
gettimeofday(&c->session->activity_time, NULL) != 0)
|
||||||
|
fatal("gettimeofday failed");
|
||||||
|
|
||||||
tty_start_tty(&c->tty);
|
tty_start_tty(&c->tty);
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
if (c->session != NULL)
|
|
||||||
c->session->activity = time(NULL);
|
|
||||||
break;
|
break;
|
||||||
case MSG_ENVIRON:
|
case MSG_ENVIRON:
|
||||||
if (datalen != sizeof environdata)
|
if (datalen != sizeof environdata)
|
||||||
@ -665,9 +669,6 @@ server_client_msg_command(struct client *c, struct msg_command_data *data)
|
|||||||
int argc;
|
int argc;
|
||||||
char **argv, *cause;
|
char **argv, *cause;
|
||||||
|
|
||||||
if (c->session != NULL)
|
|
||||||
c->session->activity = time(NULL);
|
|
||||||
|
|
||||||
ctx.error = server_client_msg_error;
|
ctx.error = server_client_msg_error;
|
||||||
ctx.print = server_client_msg_print;
|
ctx.print = server_client_msg_print;
|
||||||
ctx.info = server_client_msg_info;
|
ctx.info = server_client_msg_info;
|
||||||
|
10
server.c
10
server.c
@ -565,12 +565,13 @@ server_lock_server(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (s->flags & SESSION_UNATTACHED) {
|
if (s->flags & SESSION_UNATTACHED) {
|
||||||
s->activity = time(NULL);
|
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 + timeout)
|
if (timeout <= 0 || t <= s->activity_time.tv_sec + timeout)
|
||||||
return; /* not timed out */
|
return; /* not timed out */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,12 +594,13 @@ server_lock_sessions(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (s->flags & SESSION_UNATTACHED) {
|
if (s->flags & SESSION_UNATTACHED) {
|
||||||
s->activity = time(NULL);
|
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 + timeout) {
|
if (timeout > 0 && t > s->activity_time.tv_sec + timeout) {
|
||||||
server_lock_session(s);
|
server_lock_session(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
}
|
}
|
||||||
|
@ -126,10 +126,10 @@ session_create(const char *name, const char *cmd, const char *cwd,
|
|||||||
s = xmalloc(sizeof *s);
|
s = xmalloc(sizeof *s);
|
||||||
s->references = 0;
|
s->references = 0;
|
||||||
s->flags = 0;
|
s->flags = 0;
|
||||||
s->activity = time(NULL);
|
|
||||||
|
|
||||||
if (gettimeofday(&s->tv, 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);
|
||||||
|
|
||||||
s->curw = NULL;
|
s->curw = NULL;
|
||||||
TAILQ_INIT(&s->lastw);
|
TAILQ_INIT(&s->lastw);
|
||||||
|
8
tmux.h
8
tmux.h
@ -922,8 +922,9 @@ TAILQ_HEAD(session_groups, session_group);
|
|||||||
|
|
||||||
struct session {
|
struct session {
|
||||||
char *name;
|
char *name;
|
||||||
struct timeval tv;
|
|
||||||
time_t activity;
|
struct timeval creation_time;
|
||||||
|
struct timeval activity_time;
|
||||||
|
|
||||||
u_int sx;
|
u_int sx;
|
||||||
u_int sy;
|
u_int sy;
|
||||||
@ -1061,7 +1062,8 @@ struct mouse_event {
|
|||||||
/* Client connection. */
|
/* Client connection. */
|
||||||
struct client {
|
struct client {
|
||||||
struct imsgbuf ibuf;
|
struct imsgbuf ibuf;
|
||||||
struct timeval tv;
|
|
||||||
|
struct timeval creation_time;
|
||||||
|
|
||||||
struct environ environ;
|
struct environ environ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user