Date: Fri, 20 Dec 2013 19:45:51 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259663 - head/sys/kern Message-ID: <201312201945.rBKJjpuj009106@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Fri Dec 20 19:45:51 2013 New Revision: 259663 URL: http://svnweb.freebsd.org/changeset/base/259663 Log: Move list of ttys handling from the allocating procedures, to the device creation stage. A device creation can fail, and in that case an entry already on the list will be freed. Sponsored by: Nginx, Inc. Modified: head/sys/kern/tty.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Fri Dec 20 19:44:29 2013 (r259662) +++ head/sys/kern/tty.c Fri Dec 20 19:45:51 2013 (r259663) @@ -1007,11 +1007,6 @@ tty_alloc_mutex(struct ttydevsw *tsw, vo knlist_init_mtx(&tp->t_inpoll.si_note, tp->t_mtx); knlist_init_mtx(&tp->t_outpoll.si_note, tp->t_mtx); - sx_xlock(&tty_list_sx); - TAILQ_INSERT_TAIL(&tty_list, tp, t_list); - tty_list_count++; - sx_xunlock(&tty_list_sx); - return (tp); } @@ -1020,11 +1015,6 @@ tty_dealloc(void *arg) { struct tty *tp = arg; - sx_xlock(&tty_list_sx); - TAILQ_REMOVE(&tty_list, tp, t_list); - tty_list_count--; - sx_xunlock(&tty_list_sx); - /* Make sure we haven't leaked buffers. */ MPASS(ttyinq_getsize(&tp->t_inq) == 0); MPASS(ttyoutq_getsize(&tp->t_outq) == 0); @@ -1065,6 +1055,11 @@ tty_rel_free(struct tty *tp) tp->t_dev = NULL; tty_unlock(tp); + sx_xlock(&tty_list_sx); + TAILQ_REMOVE(&tty_list, tp, t_list); + tty_list_count--; + sx_xunlock(&tty_list_sx); + if (dev != NULL) destroy_dev_sched_cb(dev, tty_dealloc, tp); } @@ -1279,6 +1274,11 @@ tty_makedevf(struct tty *tp, struct ucre } } + sx_xlock(&tty_list_sx); + TAILQ_INSERT_TAIL(&tty_list, tp, t_list); + tty_list_count++; + sx_xunlock(&tty_list_sx); + return (0); fail:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312201945.rBKJjpuj009106>