[PATCH 0/2] winlink alert improvements
Hi, I've had these two patches kicking around for a while, so I've cleaned them up and shoved them here for review. [1/2]: Simplify server_window_check_bell() This patch simplifies the code for window bell checks. Previously, the case statement which differentiated the different bell types did the same thing, the only difference being the status message, if visual-bell was set. This patch combines the two. [2/2]: Clear WINLINK_ALERTFLAGS across all sessions It seems that in January 2012, a patch was applied to tmux to address handling of alerts in the current window to only show when the session was detached (OpenBSD patchset 1003). However, from what I can tell, this is broken, not least of which it breaks linked windows across sessions, where previously an alert in a linked window caused that alert to propagate to _all_ sessions to which it is linked. With OpenBSD patchet 1003 however, windows linked across sessions are cleared in all but the originating window. So this patch effectively does a few things: 1. Restores the functionality of alerting all instances of windows linked to across multiple sessions. 2. Keeps the original intention of showing alerts on the current window if that session is unattached. That is: tmux lsw -t some_unattached_session_id -F \ '#{window_name}|#{window_flags}' will show the current window as having an alert of some kind. 3. Introduces winlink_clear_flags() which is called from a few places when selecting windows to clear all flags across winlinks. Any questions, please ask. -- Thomas Adam Thomas Adam (2): Simplify server_window_check_bell() Clear WINLINK_ALERTFLAGS across all sessions trunk/server-window.c | 55 ++--- trunk/session.c |8 +++ trunk/tmux.h |2 ++ trunk/window.c| 31 4 files changed, 53 insertions(+), 43 deletions(-) -- 1.7.10 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
[PATCH 1/2] Simplify server_window_check_bell()
Rather than duplicating the same logic between monitoring bells in all or the current window, instead centralise the logic of looping over all windows, and for the purposes of rendering visual-* alerts, only check the bell type at that point, and print the appropriate message. --- trunk/server-window.c | 50 ++--- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/trunk/server-window.c b/trunk/server-window.c index 69e4c6c..2fc0e21 100644 --- a/trunk/server-window.c +++ b/trunk/server-window.c @@ -76,46 +76,24 @@ server_window_check_bell(struct session *s, struct winlink *wl) return (0); if (s-curw != wl || s-flags SESSION_UNATTACHED) wl-flags |= WINLINK_BELL; + if (s-flags SESSION_UNATTACHED) + return (1); + visual = options_get_number(s-options, visual-bell); action = options_get_number(s-options, bell-action); - switch (action) { - case BELL_ANY: - if (s-flags SESSION_UNATTACHED) - break; - visual = options_get_number(s-options, visual-bell); - for (i = 0; i ARRAY_LENGTH(clients); i++) { - c = ARRAY_ITEM(clients, i); - if (c == NULL || c-session != s) - continue; - if (!visual) { - tty_bell(c-tty); - continue; - } - if (c-session-curw-window == w) { - status_message_set(c, Bell in current window); - continue; - } - status_message_set(c, Bell in window %u, - winlink_find_by_window(s-windows, w)-idx); + for (i = 0; i ARRAY_LENGTH(clients); i++) { + c = ARRAY_ITEM(clients, i); + if (c == NULL || c-session != s) + continue; + if (!visual) { + tty_bell(c-tty); + continue; } - break; - case BELL_CURRENT: - if (s-flags SESSION_UNATTACHED) - break; - visual = options_get_number(s-options, visual-bell); - for (i = 0; i ARRAY_LENGTH(clients); i++) { - c = ARRAY_ITEM(clients, i); - if (c == NULL || c-session != s) - continue; - if (c-session-curw-window != w) - continue; - if (!visual) { - tty_bell(c-tty); - continue; - } + if (c-session-curw-window == w) status_message_set(c, Bell in current window); - } - break; + else if (action == BELL_ANY) + status_message_set(c, Bell in window %u, + winlink_find_by_window(s-windows, w)-idx); } return (1); -- 1.7.10 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
[PATCH v2 2/2] Clear WINLINK_ALERTFLAGS across all sessions
When a winlink is linked in to multiple sessions, make the alert appear across all sessions where that winlink is linked to, and on clearing it, ensure *all* instances of that alert are cleared. --- V2: Clear more window-flags than just WINDOW_BELL. trunk/server-window.c | 11 --- trunk/session.c |8 trunk/tmux.h |2 ++ trunk/window.c| 31 +++ 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/trunk/server-window.c b/trunk/server-window.c index 2fc0e21..b87a4e5 100644 --- a/trunk/server-window.c +++ b/trunk/server-window.c @@ -56,9 +56,6 @@ server_window_loop(void) server_status_session(s); TAILQ_FOREACH(wp, w-panes, entry) server_window_check_content(s, wl, wp); - - if (!(s-flags SESSION_UNATTACHED)) - w-flags = ~(WINDOW_BELL|WINDOW_ACTIVITY); } } } @@ -78,6 +75,8 @@ server_window_check_bell(struct session *s, struct winlink *wl) wl-flags |= WINLINK_BELL; if (s-flags SESSION_UNATTACHED) return (1); + if (s-curw-window == wl-window) + w-flags = ~WINDOW_BELL; visual = options_get_number(s-options, visual-bell); action = options_get_number(s-options, bell-action); @@ -107,6 +106,9 @@ server_window_check_activity(struct session *s, struct winlink *wl) struct window *w = wl-window; u_inti; + if (s-curw-window == wl-window) + w-flags = ~WINDOW_ACTIVITY; + if (!(w-flags WINDOW_ACTIVITY) || wl-flags WINLINK_ACTIVITY) return (0); if (s-curw == wl !(s-flags SESSION_UNATTACHED)) @@ -195,6 +197,9 @@ server_window_check_content( char*found, *ptr; /* Activity flag must be set for new content. */ + if (s-curw-window == w) + w-flags = ~WINDOW_ACTIVITY; + if (!(w-flags WINDOW_ACTIVITY) || wl-flags WINLINK_CONTENT) return (0); if (s-curw == wl !(s-flags SESSION_UNATTACHED)) diff --git a/trunk/session.c b/trunk/session.c index 0d3b8dd..13be0c7 100644 --- a/trunk/session.c +++ b/trunk/session.c @@ -352,7 +352,7 @@ session_next(struct session *s, int alert) winlink_stack_remove(s-lastw, wl); winlink_stack_push(s-lastw, s-curw); s-curw = wl; - wl-flags = ~WINLINK_ALERTFLAGS; + winlink_clear_flags(wl); return (0); } @@ -389,7 +389,7 @@ session_previous(struct session *s, int alert) winlink_stack_remove(s-lastw, wl); winlink_stack_push(s-lastw, s-curw); s-curw = wl; - wl-flags = ~WINLINK_ALERTFLAGS; + winlink_clear_flags(wl); return (0); } @@ -407,7 +407,7 @@ session_select(struct session *s, int idx) winlink_stack_remove(s-lastw, wl); winlink_stack_push(s-lastw, s-curw); s-curw = wl; - wl-flags = ~WINLINK_ALERTFLAGS; + winlink_clear_flags(wl); return (0); } @@ -426,7 +426,7 @@ session_last(struct session *s) winlink_stack_remove(s-lastw, wl); winlink_stack_push(s-lastw, s-curw); s-curw = wl; - wl-flags = ~WINLINK_ALERTFLAGS; + winlink_clear_flags(wl); return (0); } diff --git a/trunk/tmux.h b/trunk/tmux.h index d0dc122..455affb 100644 --- a/trunk/tmux.h +++ b/trunk/tmux.h @@ -2054,6 +2054,8 @@ struct window_pane *window_pane_find_down(struct window_pane *); struct window_pane *window_pane_find_left(struct window_pane *); struct window_pane *window_pane_find_right(struct window_pane *); voidwindow_set_name(struct window *, const char *); +voidwinlink_clear_flags(struct winlink *); + /* layout.c */ u_int layout_count_cells(struct layout_cell *); diff --git a/trunk/window.c b/trunk/window.c index 8eb11f2..c1ba0aa 100644 --- a/trunk/window.c +++ b/trunk/window.c @@ -1174,3 +1174,34 @@ window_pane_find_right(struct window_pane *wp) } return (NULL); } + +/* Clear alert flags for a winlink */ +void +winlink_clear_flags(struct winlink *wl) +{ + struct winlink *wm; + struct session *s; + struct window *w; + u_inti; + + for (i = 0; i ARRAY_LENGTH(windows); i++) + { + if ((w = ARRAY_ITEM(windows, i)) == NULL) + continue; + + RB_FOREACH(s, sessions, sessions) + { + if ((wm = session_has(s, w)) == NULL) + continue; + + if (wm-flags WINLINK_ALERTFLAGS + wm-window == wl-window) + { + wm-flags = ~WINLINK_ALERTFLAGS; + w-flags = ~(WINDOW_BELL|WINDOW_ACTIVITY); + +
tmux segfaults after suspension to ram
Hi, in many occasions, after resuming from suspension to ram, the tmux server suddenly segfaults for me. The segfault happens quite randomly, but a way to reproduce it is the following: 1) I start tmux; 2) I launch mutt with the following key binding defined in my tmux.conf: bind p neww -k -t:6 'mutt' 3) I suspend my laptop to ram; 4) I relaunch mutt with that same keybinding. I am pretty convinced that it happened to me also in other scenarios after suspension but where mutt is not involved, but I am not able to reproduce these other scenarios. This happens to me both in 1.6 release and with latest git (I am on archlinux). It happened to me in 1.5 too, but not with 1.4. In the system logs I find this: tmux[3138]: segfault at 8 ip 004168de sp 7fffe2179ed0 error 4 in tmux[40+6d000] I have run tmux -vvv for the above steps and the resulting tmux-server-x.log is here: http://ix.io/2A5 Thanks in advance for your help Giorgio Lando -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
Re: tmux segfaults after suspension to ram
On Sun, Jun 17, 2012, at 08:46 PM, Giorgio Lando wrote: 1) I start tmux; 2) I launch mutt with the following key binding defined in my tmux.conf: bind p neww -k -t:6 'mutt' 3) I suspend my laptop to ram; 4) I relaunch mutt with that same keybinding. Sorry to correct myself so soon, but it seems that suspension is irrelevant here. In order to get the segfault, it is enough to launch mutt two times with that binding with the -k option, but only if the window with mutt is selected (if I switch to another window and press the keys mutt is destroyed and relaunched fine). But it happens e.g. also with htop: I launch it with neww, then I select that window, I relaunch it with neww -k over itself and tmux segfaults. Perhaps I shouldn't destroy (with -k) a selcted window? This was useful to me when mutt stalled, in order to relaunch it... But perhaps tmux should give an error instead of segfaulting? Best Giorgio -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
Re: tmux segfaults after suspension to ram
Hi, On 17 June 2012 22:50, Giorgio Lando la...@imap.cc wrote: On Sun, Jun 17, 2012, at 08:46 PM, Giorgio Lando wrote: 1) I start tmux; 2) I launch mutt with the following key binding defined in my tmux.conf: bind p neww -k -t:6 'mutt' 3) I suspend my laptop to ram; 4) I relaunch mutt with that same keybinding. I can't reproduce this, but if you're using the SVN version that compiles with -g in CFLAGS, and a backtrace from gdb from a corefile would be really useful. Can you do that? Thanks, -- Thomas Adam -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
Re: tmux segfaults after suspension to ram
On Sun, Jun 17, 2012 at 10:53:54PM +0100, Thomas Adam wrote: Hi, On 17 June 2012 22:50, Giorgio Lando la...@imap.cc wrote: On Sun, Jun 17, 2012, at 08:46 PM, Giorgio Lando wrote: 1) I start tmux; 2) I launch mutt with the following key binding defined in my tmux.conf: bind p neww -k -t:6 'mutt' 3) I suspend my laptop to ram; 4) I relaunch mutt with that same keybinding. I can't reproduce this, but if you're using the SVN version that compiles with -g in CFLAGS, and a backtrace from gdb from a corefile would be really useful. OK, I had to do a few things differently to you. Does the following help? diff --git a/trunk/cmd.c b/trunk/cmd.c index 7aefeff..09b4922 100644 --- a/trunk/cmd.c +++ b/trunk/cmd.c @@ -1303,7 +1303,7 @@ cmd_get_default_path(struct cmd_ctx *ctx, const char *cwd) /* Empty or relative path. */ if (ctx-cmdclient != NULL ctx-cmdclient-cwd != NULL) root = ctx-cmdclient-cwd; - else if (ctx-curclient != NULL) + else if (ctx-curclient != NULL s-curw != NULL) root = osdep_get_cwd(s-curw-window-active-pid); else return (s-cwd); -- Thomas Adam -- Deep in my heart I wish I was wrong. But deep in my heart I know I am not. -- Morrissey (Girl Least Likely To -- off of Viva Hate.) -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
Re: tmux segfaults after suspension to ram
On Sun, Jun 17, 2012, at 11:00 PM, Thomas Adam wrote: OK, I had to do a few things differently to you. Does the following help? diff --git a/trunk/cmd.c b/trunk/cmd.c index 7aefeff..09b4922 100644 --- a/trunk/cmd.c +++ b/trunk/cmd.c @@ -1303,7 +1303,7 @@ cmd_get_default_path(struct cmd_ctx *ctx, const char *cwd) /* Empty or relative path. */ if (ctx-cmdclient != NULL ctx-cmdclient-cwd != NULL) root = ctx-cmdclient-cwd; - else if (ctx-curclient != NULL) + else if (ctx-curclient != NULL s-curw != NULL) root = osdep_get_cwd(s-curw-window-active-pid); else return (s-cwd); Yes, this helps! I have applied the patch against the current version (I am using a git repo synchronized with the svn one), tried to reproduce the segfault several times but it seems to be fixed. Thanks a lot. I guess you do not need the backtrace anymore (if you need it nonetheless let me know) Giorgio -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users