Print this page
OS-11 rcapd behaves poorly when under extreme load

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/rcap/common/utils.c
          +++ new/usr/src/cmd/rcap/common/utils.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  /*
  23   23   * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  24   25   */
  25   26  
  26   27  #include <sys/param.h>
  27   28  #include <libintl.h>
  28   29  #include <stdarg.h>
  29   30  #include <stdio.h>
  30   31  #include <stdlib.h>
  31   32  #include <strings.h>
  32   33  #include <syslog.h>
  33   34  #include <unistd.h>
↓ open down ↓ 215 lines elided ↑ open up ↑
 249  250          char *q;
 250  251  
 251  252          errno = 0;
 252  253          i = (int)strtol(p, &q, 10);
 253  254          if (errno != 0 || q == p || i < 0 || *q != '\0') {
 254  255                  warn(gettext("illegal argument -- %s\n"), p);
 255  256                  return (-1);
 256  257          } else {
 257  258                  return (i);
 258  259          }
 259      -}
 260      -
 261      -/*
 262      - * get_running_zones() calls zone_list(2) to find out how many zones are
 263      - * running.  It then calls zone_list(2) again to fetch the list of running
 264      - * zones (stored in *zents).
 265      - */
 266      -int
 267      -get_running_zones(uint_t *nzents, zone_entry_t **zents)
 268      -{
 269      -        zoneid_t *zids;
 270      -        uint_t nzents_saved;
 271      -        int i;
 272      -        zone_entry_t *zentp;
 273      -        zone_state_t zstate;
 274      -
 275      -        *zents = NULL;
 276      -        if (zone_list(NULL, nzents) != 0) {
 277      -                warn(gettext("could not get zoneid list\n"));
 278      -                return (E_ERROR);
 279      -        }
 280      -
 281      -again:
 282      -        if (*nzents == 0)
 283      -                return (E_SUCCESS);
 284      -
 285      -        if ((zids = (zoneid_t *)calloc(*nzents, sizeof (zoneid_t))) == NULL) {
 286      -                warn(gettext("out of memory: zones will not be capped\n"));
 287      -                return (E_ERROR);
 288      -        }
 289      -
 290      -        nzents_saved = *nzents;
 291      -
 292      -        if (zone_list(zids, nzents) != 0) {
 293      -                warn(gettext("could not get zone list\n"));
 294      -                free(zids);
 295      -                return (E_ERROR);
 296      -        }
 297      -        if (*nzents != nzents_saved) {
 298      -                /* list changed, try again */
 299      -                free(zids);
 300      -                goto again;
 301      -        }
 302      -
 303      -        *zents = calloc(*nzents, sizeof (zone_entry_t));
 304      -        if (*zents == NULL) {
 305      -                warn(gettext("out of memory: zones will not be capped\n"));
 306      -                free(zids);
 307      -                return (E_ERROR);
 308      -        }
 309      -
 310      -        zentp = *zents;
 311      -        for (i = 0; i < *nzents; i++) {
 312      -                char name[ZONENAME_MAX];
 313      -
 314      -                if (getzonenamebyid(zids[i], name, sizeof (name)) < 0) {
 315      -                        warn(gettext("could not get name for "
 316      -                            "zoneid %d\n"), zids[i]);
 317      -                        continue;
 318      -                }
 319      -
 320      -                (void) strlcpy(zentp->zname, name, sizeof (zentp->zname));
 321      -                zentp->zid = zids[i];
 322      -                if (zone_get_state(name, &zstate) != Z_OK ||
 323      -                    zstate != ZONE_STATE_RUNNING)
 324      -                        continue;
 325      -
 326      -
 327      -                zentp++;
 328      -        }
 329      -        *nzents = zentp - *zents;
 330      -
 331      -        free(zids);
 332      -        return (E_SUCCESS);
 333  260  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX