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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/strsubr.c
          +++ new/usr/src/uts/common/os/strsubr.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  22   22  /*        All Rights Reserved   */
  23   23  
  24      -
  25   24  /*
  26   25   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  27   26   * Use is subject to license terms.
  28   27   * Copyright (c) 2016 by Delphix. All rights reserved.
       28 + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  29   29   */
       30 +/*
       31 + * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       32 + */
  30   33  
  31   34  #include <sys/types.h>
  32   35  #include <sys/sysmacros.h>
  33   36  #include <sys/param.h>
  34   37  #include <sys/errno.h>
  35   38  #include <sys/signal.h>
  36   39  #include <sys/proc.h>
  37   40  #include <sys/conf.h>
  38   41  #include <sys/cred.h>
  39   42  #include <sys/user.h>
↓ open down ↓ 173 lines elided ↑ open up ↑
 213  216  int run_queues = 0;
 214  217  
 215  218  /*
 216  219   * sq_max_size is the depth of the syncq (in number of messages) before
 217  220   * qfill_syncq() starts QFULL'ing destination queues. As its primary
 218  221   * consumer - IP is no longer D_MTPERMOD, but there may be other
 219  222   * modules/drivers depend on this syncq flow control, we prefer to
 220  223   * choose a large number as the default value. For potential
 221  224   * performance gain, this value is tunable in /etc/system.
 222  225   */
 223      -int sq_max_size = 10000;
      226 +volatile int sq_max_size = 10000;
 224  227  
 225  228  /*
 226  229   * The number of ciputctrl structures per syncq and stream we create when
 227  230   * needed.
 228  231   */
 229  232  int n_ciputctrl;
 230  233  int max_n_ciputctrl = 16;
 231  234  /*
 232  235   * If n_ciputctrl is < min_n_ciputctrl don't even create ciputctrl_cache.
 233  236   */
↓ open down ↓ 709 lines elided ↑ open up ↑
 943  946  }
 944  947  
 945  948  /*
 946  949   * Send the "sevent" set of signals to a process.
 947  950   * This might send more than one signal if the process is registered
 948  951   * for multiple events. The caller should pass in an sevent that only
 949  952   * includes the events for which the process has registered.
 950  953   */
 951  954  static void
 952  955  dosendsig(proc_t *proc, int events, int sevent, k_siginfo_t *info,
 953      -        uchar_t band, int error)
      956 +    uchar_t band, int error)
 954  957  {
 955  958          ASSERT(MUTEX_HELD(&proc->p_lock));
 956  959  
 957  960          info->si_band = 0;
 958  961          info->si_errno = 0;
 959  962  
 960  963          if (sevent & S_ERROR) {
 961  964                  sevent &= ~S_ERROR;
 962  965                  info->si_code = POLL_ERR;
 963  966                  info->si_errno = error;
↓ open down ↓ 1379 lines elided ↑ open up ↑
2343 2346          }
2344 2347          ASSERT(0);      /* should not reach here */
2345 2348  }
2346 2349  
2347 2350  /*
2348 2351   * Translate the device flags (from conf.h) to the corresponding
2349 2352   * qflag and sq_flag (type) values.
2350 2353   */
2351 2354  int
2352 2355  devflg_to_qflag(struct streamtab *stp, uint32_t devflag, uint32_t *qflagp,
2353      -        uint32_t *sqtypep)
     2356 +    uint32_t *sqtypep)
2354 2357  {
2355 2358          uint32_t qflag = 0;
2356 2359          uint32_t sqtype = 0;
2357 2360  
2358 2361          if (devflag & _D_OLD)
2359 2362                  goto bad;
2360 2363  
2361 2364          /* Inner perimeter presence and scope */
2362 2365          switch (devflag & D_MTINNER_MASK) {
2363 2366          case D_MP:
↓ open down ↓ 93 lines elided ↑ open up ↑
2457 2460           * to sockfs that it supports direct-access mode without
2458 2461           * having to go through STREAMS.
2459 2462           */
2460 2463          if (devflag & _D_DIRECT) {
2461 2464                  /* Reject unless the module is fully-MT (no perimeter) */
2462 2465                  if ((qflag & QMT_TYPEMASK) != QMTSAFE)
2463 2466                          goto bad;
2464 2467                  qflag |= _QDIRECT;
2465 2468          }
2466 2469  
     2470 +        /*
     2471 +         * Private flag used to indicate that a streams module should only
     2472 +         * be pushed once. The TTY streams modules have this flag since if
     2473 +         * libc believes itself to be an xpg4 process then it will
     2474 +         * automatically and unconditionally push them when a PTS device is
     2475 +         * opened. If an application is not aware of this then without this
     2476 +         * flag we would end up with duplicate modules.
     2477 +         */
     2478 +        if (devflag & _D_SINGLE_INSTANCE)
     2479 +                qflag |= _QSINGLE_INSTANCE;
     2480 +
2467 2481          *qflagp = qflag;
2468 2482          *sqtypep = sqtype;
2469 2483          return (0);
2470 2484  
2471 2485  bad:
2472 2486          cmn_err(CE_WARN,
2473 2487              "stropen: bad MT flags (0x%x) in driver '%s'",
2474 2488              (int)(qflag & D_MTSAFETY_MASK),
2475 2489              stp->st_rdinit->qi_minfo->mi_idname);
2476 2490  
↓ open down ↓ 5603 lines elided ↑ open up ↑
8080 8094  {
8081 8095          struct stdata *stp = vp->v_stream;
8082 8096  
8083 8097          mutex_enter(&stp->sd_lock);
8084 8098          flushq(_RD(stp->sd_wrq), flag);
8085 8099          mutex_exit(&stp->sd_lock);
8086 8100  }
8087 8101  
8088 8102  void
8089 8103  strsetrputhooks(vnode_t *vp, uint_t flags,
8090      -                msgfunc_t protofunc, msgfunc_t miscfunc)
     8104 +    msgfunc_t protofunc, msgfunc_t miscfunc)
8091 8105  {
8092 8106          struct stdata *stp = vp->v_stream;
8093 8107  
8094 8108          mutex_enter(&stp->sd_lock);
8095 8109  
8096 8110          if (protofunc == NULL)
8097 8111                  stp->sd_rprotofunc = strrput_proto;
8098 8112          else
8099 8113                  stp->sd_rprotofunc = protofunc;
8100 8114  
↓ open down ↓ 697 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX