=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.215 retrieving revision 1.216 diff -c -r1.215 -r1.216 *** src/usr.bin/tmux/server-client.c 2017/03/09 22:00:46 1.215 --- src/usr.bin/tmux/server-client.c 2017/04/05 10:49:46 1.216 *************** *** 1,4 **** ! /* $OpenBSD: server-client.c,v 1.215 2017/03/09 22:00:46 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server-client.c,v 1.216 2017/04/05 10:49:46 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 99,113 **** struct environ_entry *envent; struct window_pane *wp; - if (c->tty.path == NULL) - return (0); - envent = environ_find(c->environ, "TMUX"); if (envent == NULL || *envent->value == '\0') return (0); RB_FOREACH(wp, window_pane_tree, &all_window_panes) { ! if (strcmp(wp->tty, c->tty.path) == 0) return (1); } return (0); --- 99,110 ---- struct environ_entry *envent; struct window_pane *wp; envent = environ_find(c->environ, "TMUX"); if (envent == NULL || *envent->value == '\0') return (0); RB_FOREACH(wp, window_pane_tree, &all_window_panes) { ! if (strcmp(wp->tty, c->ttyname) == 0) return (1); } return (0); *************** *** 322,329 **** if (!TAILQ_EMPTY(&c->queue)) fatalx("queue not empty"); ! if (c->references == 0) free(c); } /* Detach a client. */ --- 319,328 ---- if (!TAILQ_EMPTY(&c->queue)) fatalx("queue not empty"); ! if (c->references == 0) { ! free((void *)c->name); free(c); + } } /* Detach a client. */ *************** *** 1470,1475 **** --- 1469,1475 ---- const char *data, *home; size_t datalen; int flags; + char *name; if (c->flags & CLIENT_IDENTIFIED) fatalx("out-of-order identify message"); *************** *** 1535,1540 **** --- 1535,1547 ---- return; c->flags |= CLIENT_IDENTIFIED; + if (*c->ttyname != '\0') + name = xstrdup(c->ttyname); + else + xasprintf(&name, "client-%ld", (long)c->pid); + c->name = name; + log_debug("client %p name is %s", c, c->name); + if (c->flags & CLIENT_CONTROL) { c->stdin_callback = control_callback; *************** *** 1685,1691 **** xvasprintf(&s, fmt, ap); va_end(ap); ! log_debug("%s: message %s", c->tty.path, s); msg = xcalloc(1, sizeof *msg); msg->msg_time = time(NULL); --- 1692,1698 ---- xvasprintf(&s, fmt, ap); va_end(ap); ! log_debug("message %s (client %p)", s, c); msg = xcalloc(1, sizeof *msg); msg->msg_time = time(NULL);