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/cache.c
          +++ new/usr/src/cmd/nscd/cache.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2012 Milan Jurik. All rights reserved.
  24   24   * Copyright (c) 2016 by Delphix. All rights reserved.
       25 + * Copyright 2018 Joyent, Inc.
  25   26   */
  26   27  
  27   28  /*
  28   29   * Cache routines for nscd
  29   30   */
  30   31  #include <assert.h>
  31   32  #include <errno.h>
  32   33  #include <memory.h>
  33   34  #include <signal.h>
  34   35  #include <stdlib.h>
↓ open down ↓ 1775 lines elided ↑ open up ↑
1810 1811          cache_init_ctx[i](ctx);
1811 1812          cache_ctx_p[i] = ctx;
1812 1813  
1813 1814          return (ctx);
1814 1815  }
1815 1816  
1816 1817  
1817 1818  static void
1818 1819  revalidate(nsc_ctx_t *ctx)
1819 1820  {
     1821 +        (void) thr_setname(thr_self(), "revalidate");
     1822 +
1820 1823          for (;;) {
1821      -                int             i, slp, interval, count;
     1824 +                int i, slp, interval, count;
1822 1825  
1823 1826                  (void) rw_rdlock(&ctx->cfg_rwlp);
1824 1827                  slp = ctx->cfg.pos_ttl;
1825 1828                  count = ctx->cfg.keephot;
1826 1829                  (void) rw_unlock(&ctx->cfg_rwlp);
1827 1830  
1828 1831                  if (slp < 60)
1829 1832                          slp = 60;
1830 1833                  if (count != 0) {
1831 1834                          interval = (slp/2)/count;
↓ open down ↓ 122 lines elided ↑ open up ↑
1954 1957                  return (-1);
1955 1958          }
1956 1959          return (0);
1957 1960  }
1958 1961  
1959 1962  
1960 1963  static void
1961 1964  do_update(nsc_lookup_args_t *in) {
1962 1965          nss_pheader_t   *phdr = (nss_pheader_t *)in->buffer;
1963 1966  
     1967 +        (void) thr_setname(thr_self(), "do_update");
     1968 +
1964 1969          /* update the length of the data buffer */
1965 1970          phdr->data_len = phdr->pbufsiz - phdr->data_off;
1966 1971  
1967 1972          (void) lookup_int(in, UPDATEBIT);
1968 1973          if (in->buffer)
1969 1974                  free(in->buffer);
1970 1975          free(in);
1971 1976  }
1972 1977  
1973 1978  
↓ open down ↓ 36 lines elided ↑ open up ↑
2010 2015          }
2011 2016  }
2012 2017  
2013 2018  
2014 2019  /*
2015 2020   * Invalidate cache by context
2016 2021   */
2017 2022  static void
2018 2023  ctx_invalidate(nsc_ctx_t *ctx)
2019 2024  {
2020      -        int             i;
     2025 +        int             i;
2021 2026          nsc_entry_t     *entry;
2022 2027          char            *me = "ctx_invalidate";
2023 2028  
2024 2029          _NSCD_LOG(NSCD_LOG_CACHE, NSCD_LOG_LEVEL_DEBUG)
2025 2030          (me, "%s: invalidate cache\n", ctx->dbname);
2026 2031  
2027 2032          for (i = 0; i < ctx->db_count; i++) {
2028 2033                  if (ctx->nsc_db[i] == NULL)
2029 2034                          continue;
2030 2035                  (void) mutex_lock(&ctx->nsc_db[i]->db_mutex);
↓ open down ↓ 152 lines elided ↑ open up ↑
2183 2188  }
2184 2189  
2185 2190  static void
2186 2191  reaper(nsc_ctx_t *ctx)
2187 2192  {
2188 2193          uint_t          ttl, extra_sleep, total_sleep, intervals;
2189 2194          uint_t          nodes_per_interval, seconds_per_interval;
2190 2195          ulong_t         nsc_entries;
2191 2196          char            *me = "reaper";
2192 2197  
     2198 +        (void) thr_setname(thr_self(), me);
     2199 +
2193 2200          for (;;) {
2194 2201                  (void) mutex_lock(&ctx->stats_mutex);
2195 2202                  nsc_entries = ctx->stats.entries;
2196 2203                  (void) mutex_unlock(&ctx->stats_mutex);
2197 2204  
2198 2205                  (void) rw_rdlock(&ctx->cfg_rwlp);
2199 2206                  ttl = ctx->cfg.pos_ttl;
2200 2207                  (void) rw_unlock(&ctx->cfg_rwlp);
2201 2208  
2202 2209                  if (nsc_entries == 0) {
↓ open down ↓ 211 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX