Print this page
9042 multiples of tty streams modules cause weirdness
Reviewed by: Randy Fishel <randyf@sibernet.com>
Reviewed by: Carlos Neira <cneirabustos@gmail.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
re #13613 rb4516 Tunables needs volatile keyword
        
@@ -19,16 +19,19 @@
  * CDDL HEADER END
  */
 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
 /*        All Rights Reserved   */
 
-
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  * Copyright (c) 2016 by Delphix. All rights reserved.
+ * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  */
+/*
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+ */
 
 #include <sys/types.h>
 #include <sys/sysmacros.h>
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -218,11 +221,11 @@
  * consumer - IP is no longer D_MTPERMOD, but there may be other
  * modules/drivers depend on this syncq flow control, we prefer to
  * choose a large number as the default value. For potential
  * performance gain, this value is tunable in /etc/system.
  */
-int sq_max_size = 10000;
+volatile int sq_max_size = 10000;
 
 /*
  * The number of ciputctrl structures per syncq and stream we create when
  * needed.
  */
@@ -2462,10 +2465,21 @@
                 if ((qflag & QMT_TYPEMASK) != QMTSAFE)
                         goto bad;
                 qflag |= _QDIRECT;
         }
 
+        /*
+         * Private flag used to indicate that a streams module should only
+         * be pushed once. The TTY streams modules have this flag since if
+         * libc believes itself to be an xpg4 process then it will
+         * automatically and unconditionally push them when a PTS device is
+         * opened. If an application is not aware of this then without this
+         * flag we would end up with duplicate modules.
+         */
+        if (devflag & _D_SINGLE_INSTANCE)
+                qflag |= _QSINGLE_INSTANCE;
+
         *qflagp = qflag;
         *sqtypep = sqtype;
         return (0);
 
 bad: