Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/nscd/nscd_getentctx.c
          +++ new/usr/src/cmd/nscd/nscd_getentctx.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  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + *
       25 + * Copyright 2018 Joyent, Inc.
  24   26   */
  25   27  
  26   28  #include <sys/ccompile.h>
  27   29  
  28   30  #include <stdlib.h>
  29   31  #include <assert.h>
  30   32  #include <string.h>
  31   33  #include <errno.h>
  32   34  #include <fcntl.h>
  33   35  
↓ open down ↓ 617 lines elided ↑ open up ↑
 651  653  reclaim_getent_ctx(void *arg)
 652  654  {
 653  655          void                    *cookie = NULL;
 654  656          nscd_db_entry_t         *ep;
 655  657          nscd_getent_ctx_t       *ctx;
 656  658          nscd_getent_context_t   *gctx, *c;
 657  659          nscd_getent_context_t   *first = NULL, *last = NULL;
 658  660          nss_getent_t            nssctx = { 0 };
 659  661          char                    *me = "reclaim_getent_ctx";
 660  662  
      663 +        (void) thr_setname(thr_self(), me);
      664 +
 661  665          /*CONSTCOND*/
 662  666          while (1) {
 663  667  
 664  668                  (void) sleep(60);
 665  669  
 666  670                  (void) rw_rdlock(&getent_ctxDB_rwlock);
 667  671  
 668  672                  for (ep = _nscd_walk_db(getent_ctxDB, &cookie); ep != NULL;
 669  673                      ep = _nscd_walk_db(getent_ctxDB, &cookie)) {
 670  674  
↓ open down ↓ 66 lines elided ↑ open up ↑
 737  741                          }
 738  742                          gctx = c;
 739  743                  }
 740  744                  first = last = NULL;
 741  745          }
 742  746          /*NOTREACHED*/
 743  747          /*LINTED E_FUNC_HAS_NO_RETURN_STMT*/
 744  748  }
 745  749  
 746  750  static nscd_rc_t
 747      -_nscd_init_getent_ctx_monitor() {
      751 +_nscd_init_getent_ctx_monitor()
      752 +{
 748  753  
 749  754          int     errnum;
 750  755          char    *me = "_nscd_init_getent_ctx_monitor";
 751  756  
 752  757          _NSCD_LOG(NSCD_LOG_GETENT_CTX, NSCD_LOG_LEVEL_DEBUG)
 753  758          (me, "initializing the getent context monitor\n");
 754  759  
 755  760          /*
 756  761           * the forker nscd does not process getent requests
 757  762           * so no need to monitor orphan getent contexts
 758  763           */
 759  764          if (_whoami == NSCD_FORKER)
 760  765                  return (NSCD_SUCCESS);
 761  766  
 762  767          /*
 763  768           * start a thread to reclaim unused getent contexts
 764  769           */
 765  770          if (thr_create(NULL, NULL, reclaim_getent_ctx,
 766      -                NULL, THR_DETACHED, NULL) != 0) {
      771 +            NULL, THR_DETACHED, NULL) != 0) {
 767  772                  errnum = errno;
 768  773                  _NSCD_LOG(NSCD_LOG_GETENT_CTX, NSCD_LOG_LEVEL_ERROR)
 769  774                  (me, "thr_create: %s\n", strerror(errnum));
 770  775                  return (NSCD_THREAD_CREATE_ERROR);
 771  776          }
 772  777  
 773  778          return (NSCD_SUCCESS);
 774  779  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX