Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11287

Modified Files:
        cmd-attach-session.c cmd-new-session.c cmd-switch-client.c 
        server-client.c server-fn.c server.c session.c tmux.h 
Log Message:
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 jo...@.


Index: server-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-client.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- server-client.c     30 Dec 2010 22:27:38 -0000      1.49
+++ server-client.c     3 Jan 2011 23:27:54 -0000       1.50
@@ -760,11 +760,8 @@
 
                        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);
-                       }
+                       if (c->session != NULL)
+                               session_update_activity(c->session);
 
                        tty_start_tty(&c->tty);
                        server_redraw_client(c);

Index: cmd-attach-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-attach-session.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- cmd-attach-session.c        22 Dec 2010 15:36:44 -0000      1.37
+++ cmd-attach-session.c        3 Jan 2011 23:27:54 -0000       1.38
@@ -74,6 +74,7 @@
                }
 
                ctx->curclient->session = s;
+               session_update_activity(s);
                server_redraw_client(ctx->curclient);
        } else {
                if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
@@ -96,6 +97,7 @@
                        server_write_session(s, MSG_DETACH, NULL, 0);
 
                ctx->cmdclient->session = s;
+               session_update_activity(s);
                server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
 
                update = options_get_string(&s->options, "update-environment");

Index: cmd-new-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-new-session.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- cmd-new-session.c   22 Dec 2010 15:31:00 -0000      1.80
+++ cmd-new-session.c   3 Jan 2011 23:27:54 -0000       1.81
@@ -284,12 +284,14 @@
                        if (old_s != NULL)
                                ctx->cmdclient->last_session = old_s;
                        ctx->cmdclient->session = s;
+                       session_update_activity(s);
                        server_redraw_client(ctx->cmdclient);
                } else {
                        old_s = ctx->curclient->session;
                        if (old_s != NULL)
                                ctx->curclient->last_session = old_s;
                        ctx->curclient->session = s;
+                       session_update_activity(s);
                        server_redraw_client(ctx->curclient);
                }
        }

Index: server-fn.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-fn.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- server-fn.c 25 Dec 2010 23:44:37 -0000      1.117
+++ server-fn.c 3 Jan 2011 23:27:54 -0000       1.118
@@ -396,6 +396,7 @@
                } else {
                        c->last_session = NULL;
                        c->session = s_new;
+                       session_update_activity(s_new);
                        server_redraw_client(c);
                }
        }

Index: cmd-switch-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-switch-client.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmd-switch-client.c 22 Dec 2010 15:31:00 -0000      1.23
+++ cmd-switch-client.c 3 Jan 2011 23:27:54 -0000       1.24
@@ -173,6 +173,7 @@
        if (c->session != NULL)
                c->last_session = c->session;
        c->session = s;
+       session_update_activity(s);
 
        recalculate_sizes();
        server_check_unattached();

Index: server.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server.c,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -d -r1.250 -r1.251
--- server.c    30 Dec 2010 22:39:49 -0000      1.250
+++ server.c    3 Jan 2011 23:27:54 -0000       1.251
@@ -495,12 +495,8 @@
 
        t = time(NULL);
        RB_FOREACH(s, sessions, &sessions) {
-               if (s->flags & SESSION_UNATTACHED) {
-                       if (gettimeofday(&s->activity_time, NULL) != 0)
-                               fatal("gettimeofday failed");
+               if (s->flags & SESSION_UNATTACHED)
                        continue;
-               }
-
                timeout = options_get_number(&s->options, "lock-after-time");
                if (timeout <= 0 || t <= s->activity_time.tv_sec + timeout)
                        return; /* not timed out */
@@ -520,12 +516,8 @@
 
        t = time(NULL);
        RB_FOREACH(s, sessions, &sessions) {
-               if (s->flags & SESSION_UNATTACHED) {
-                       if (gettimeofday(&s->activity_time, NULL) != 0)
-                               fatal("gettimeofday failed");
+               if (s->flags & SESSION_UNATTACHED)
                        continue;
-               }
-
                timeout = options_get_number(&s->options, "lock-after-time");
                if (timeout > 0 && t > s->activity_time.tv_sec + timeout) {
                        server_lock_session(s);

Index: session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/session.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- session.c   30 Dec 2010 22:39:49 -0000      1.84
+++ session.c   3 Jan 2011 23:27:54 -0000       1.85
@@ -96,7 +96,7 @@
 
        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);
 
@@ -163,6 +163,14 @@
        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)

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.596
retrieving revision 1.597
diff -u -d -r1.596 -r1.597
--- tmux.h      31 Dec 2010 22:12:33 -0000      1.596
+++ tmux.h      3 Jan 2011 23:27:54 -0000       1.597
@@ -1974,6 +1974,7 @@
                     struct environ *, struct termios *, int, u_int, u_int,
                     char **);
 void            session_destroy(struct session *);
+void            session_update_activity(struct session *);
 struct session *session_next_session(struct session *);
 struct session *session_previous_session(struct session *);
 struct winlink *session_new(struct session *,


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to