freebsd-nq/sys
Marcel Moolenaar 15773775f7 Properly drain the TTY when both revoke(2) and close(2) end up closing
the TTY. In such a case, ttydev_close() is called multiple times and
each time, t_revokecnt is incremented and cv_broadcast() is called for
both the t_outwait and t_inwait condition variables.
Let's say revoke(2) comes in first and gets to call tty_drain() from
ttydev_leave(). Let's say that the revoke comes from init(8) as the
result of running "shutdown -r now". Since shutdown prints various
messages to the console before announing that the machine will reboot
immediately, let's also say that the output queue is not empty and
that tty_drain() has something to do. Let's assume this all happens
on a 9600 baud serial console, so it takes a time to drain.
The shutdown command will exit(2) and as such will end up closing
stdout. Let's say this close will come in second, bump t_revokecnt
and call tty_wakeup(). This has tty_wait() return prematurely and
the next thing that will happen is that the thread doing revoke(2)
will flush the TTY. Since the drain wasn't complete, the flush will
effectively drop whatever is left in t_outq.

This change takes into account that tty_drain() will return ERESTART
due to the fact that t_revokecnt was bumped and in that case simply
call tty_drain() again. The thread in question is already performing
the close so it can safely finish draining the TTY before destroying
the TTY structure.

Now all messages from shutdown will be printed on the serial console.

Obtained from:	Juniper Networks, Inc.
2013-12-16 00:50:14 +00:00
..
amd64 Fix typo when initializing the vlapic version register ('<<' instead of '<'). 2013-12-11 06:28:44 +00:00
arm After r256961 ofw_iicbuc.c will be built for any kernel which includes 2013-12-12 18:29:36 +00:00
boot Add an FDT DTS and MDROOT kernel configuration for BERI on NetFPGA. 2013-12-12 18:08:31 +00:00
bsm Change the cap_rights_t type from uint64_t to a structure that we can extend 2013-09-05 00:09:56 +00:00
cam Widen lun_id_t to 64 bits. This is a follow-on to r257345 to let the kernel 2013-12-14 22:07:40 +00:00
cddl sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c 2013-12-12 00:27:22 +00:00
compat Migrate the sendfile_sync structure into a public(ish) API in preparation 2013-12-01 03:53:21 +00:00
conf Revert r259045. 2013-12-15 18:13:42 +00:00
contrib Remove 'inline' from ar9300_init_pll(), it's too big to inline. 2013-11-08 16:28:00 +00:00
crypto fix broken style(9) in r258399 2013-11-23 00:28:18 +00:00
ddb
dev split netmap code according to functions: 2013-12-15 08:37:24 +00:00
fs Fix long known bug with handling device aliases residing not in devfs root. 2013-12-12 11:05:48 +00:00
gdb
geom Clear some more places with potentially sensitive data. 2013-12-15 22:52:18 +00:00
gnu/fs/reiserfs
i386 Move constants for indices in the local APIC's local vector table from 2013-12-09 21:08:52 +00:00
ia64 Allow pmap_remove_pages() to be called for physical maps not 2013-12-12 03:04:00 +00:00
isa
kern Properly drain the TTY when both revoke(2) and close(2) end up closing 2013-12-16 00:50:14 +00:00
kgssapi
libkern Fix typo 2013-11-29 20:14:26 +00:00
mips Add an FDT DTS and MDROOT kernel configuration for BERI on NetFPGA. 2013-12-12 18:08:31 +00:00
modules split netmap code according to functions: 2013-12-15 08:37:24 +00:00
net split netmap code according to functions: 2013-12-15 08:37:24 +00:00
net80211 Make sure any waiters on the scan results get notified if the scan task 2013-11-29 22:24:57 +00:00
netatalk The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare 2013-10-26 17:58:36 +00:00
netgraph Eliminate duplicated & dead code. 2013-11-08 22:40:33 +00:00
netinet In a situation where: 2013-12-02 03:11:25 +00:00
netinet6 - For kernel compiled only with KDTRACE_HOOKS and not any lock debugging 2013-11-25 07:38:45 +00:00
netipsec Initialize prot variable. 2013-11-11 13:19:55 +00:00
netipx The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare 2013-10-26 17:58:36 +00:00
netnatm Provide includes that are needed in these files, and before were read 2013-10-26 18:18:50 +00:00
netpfil Simplify O_NAT opcode handling. 2013-11-28 15:28:51 +00:00
netsmb Catch up with sb_timeo type change in r255138. This fixes 2013-11-08 08:44:09 +00:00
nfs The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare 2013-10-26 17:58:36 +00:00
nfsclient For software builds, the NFS client does many small 2013-12-07 23:05:59 +00:00
nfsserver The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare 2013-10-26 17:58:36 +00:00
nlm Intermittent crashes in the NLM (rpc.lockd) code during system 2013-09-06 23:14:31 +00:00
ofed Defer start/stop port to workqueues. 2013-12-15 07:07:13 +00:00
opencrypto Fix build with 'crypto' and 'zfs' in the same kernel. This was the path 2013-12-08 21:59:46 +00:00
pc98 Fix a typo. 2013-12-05 21:58:02 +00:00
pci Add preliminary support for RTL8168EP. 2013-10-29 05:37:05 +00:00
powerpc Save r3 before using it for the trap check, else we end up saving the new r3, 2013-12-15 18:07:25 +00:00
rpc Replace Sun Industry Standards Source License for Sun RPC code with a 2013-11-25 19:08:38 +00:00
security There is no sysctl with the MIB { CTL_KERN, KERN_MAXID }. 2013-12-05 21:55:10 +00:00
sparc64 Restore a vital comment nuked in r259016. 2013-12-08 15:25:19 +00:00
sys Increment __FreeBSD_version for the behavior change of gss_pseudo_random 2013-12-15 18:26:31 +00:00
teken Merge VT(9) project (a.k.a. newcons). 2013-12-05 22:38:53 +00:00
tools dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE 2013-11-26 08:46:27 +00:00
ufs We needlessly panic when trying to flush MKDIR_PARENT dependencies. 2013-12-01 07:34:21 +00:00
vm Eliminate a redundant parameter to vm_radix_replace(). 2013-12-08 20:07:02 +00:00
x86 Use fixed-width types for all fields in MP Table structures and pack 2013-12-11 21:19:04 +00:00
xdr
xen Remove redundant redeclaration of gdtset in sys/xen/xen-os.h, to silence 2013-10-18 17:06:13 +00:00
Makefile