On Mon, Aug 04, 2014 at 01:59:26PM -0400, Nathaniel W Filardo wrote:
> Greetings list,
> 
> The attached patch adds options to new-window, new-session, and split-window
> (commands which create panes) to signal a wait_channel when that pane is
> destroyed, for example after the contained process exits.  Towards this end,
> it changes the life-cycle management code in cmd-wait-for.c to allow
> external holds on a wait_channel structure; these are only taken, at the
> moment, by the aforementioned commands.
> 
> It's something of an afternoon hack-job, so it might not be ideal.
> Comments and criticisms welcome; rotten tomatoes possibly understood but
> less welcome. ;)
> 
> Cheers!
> --nwf;

> diff --git a/cmd-new-session.c b/cmd-new-session.c
> index b36de70..4cf72fc 100644
> --- a/cmd-new-session.c
> +++ b/cmd-new-session.c
> @@ -38,7 +38,7 @@ const struct cmd_entry cmd_new_session_entry = {
>       "Ac:dDF:n:Ps:t:x:y:", 0, -1,

No "W" needed here?  This seems wrong.

>       "[-AdDP] [-c start-directory] [-F format] [-n window-name] "
>       "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
> -     "[-y height] [command]",
> +     "[-y height] [-W channel] [command]",
>       CMD_STARTSERVER|CMD_CANTNEST,
>       NULL,
>       cmd_new_session_exec
> @@ -61,6 +61,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
>       u_int                    sx, sy;
>       struct format_tree      *ft;
>       struct environ_entry    *envent;
> +     struct wait_channel *wc = NULL;

Missing tab character between type and variable.

[...]

> +static struct wait_channel *
> +wait_channel_find_by_name(const char *name) {
> +     struct wait_channel     wc0;
> +
> +     wc0.name = name;
> +     return RB_FIND(wait_channels, &wait_channels, &wc0);

You need to cast name here to (char *), as RB_FIND doesn't accept const
char * pointers.

> +}
> +
> +static struct wait_channel *
> +wait_channel_alloc(const char *name) {
> +     struct wait_channel *wc = xmalloc(sizeof *wc);
> +     wc->name = xstrdup(name);
> +     wc->locked = 0;
> +     TAILQ_INIT(&wc->waiters);
> +     TAILQ_INIT(&wc->lockers);
> +     RB_INSERT(wait_channels, &wait_channels, wc);
> +
> +     return wc;

return (wc);

> +
> +static void
> +wait_channel_try_free(struct wait_channel *wc) {
> +     if (wc->holds > 0)
> +             return;
> +
> +     if (!TAILQ_EMPTY(&wc->waiters))
> +             return;
> +
> +     if (!TAILQ_EMPTY(&wc->lockers)) {
> +             /* Should we assert that wc->locked == 1 ? */

Why?

> +             return;
> +     }
> +
> +     /* All references to this wait_channel are gone */
> +     RB_REMOVE(wait_channels, &wait_channels, wc);
> +     free((void*) wc->name);

No need to cast this.

> +     free(wc);
> +}
> +
> +static void
> +wait_channel_hold(struct wait_channel *wc) {
> +     wc->holds++;
> +}
> +
> +struct wait_channel *
> +wait_channel_hold_by_name(const char *name) {
> +     struct wait_channel *wc = wait_channel_find_by_name(name);
> +
> +     if(!wc)

if (wc != NULL)

> +             wc = wait_channel_alloc(name);

Suggest you call this wait_channel_new();

> +
> +     wait_channel_hold(wc);
> +
> +     return wc;

return (wc);

> +.Fl W
> +option specifies a channel name which will be signaled when the created pane
> +is destroyed.  Clients may use the

New sentences begin on a new line, please.

-- 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.)

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to