Print this page
NEX-18699 libfmd_snmp needs to prevent double loading
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Cynthia Eastham <cynthia.eastham@nexenta.com>
NEX-17796 libfmd_snmp performance is awful
Reviewed by: Cynthia Eastham <cynthia.eastham@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/fm/libfmd_snmp/common/init.c
          +++ new/usr/src/lib/fm/libfmd_snmp/common/init.c
↓ open down ↓ 29 lines elided ↑ open up ↑
  30   30  #include <net-snmp/agent/net-snmp-agent-includes.h>
  31   31  #include "sunFM_impl.h"
  32   32  #include "module.h"
  33   33  #include "resource.h"
  34   34  #include "problem.h"
  35   35  
  36   36  static const sunFm_table_t sun_fm_tables[] = {
  37   37          TABLE_REG(sunFmModuleTable),
  38   38          TABLE_REG(sunFmResourceTable),
  39   39          TABLE_REG(sunFmProblemTable),
  40      -        TABLE_REG(sunFmFaultEventTable),
  41   40          TABLE_NULL
  42   41  };
  43   42  
  44   43  /*
  45   44   * This is our entry point for initialization by the agent, which
  46   45   * (for reasons unknown) ignores the return value.  The name is fixed
  47   46   * by the agent API.
  48   47   */
  49   48  int
  50   49  init_sunFM(void)
  51   50  {
       51 +        static int              once = 0;
  52   52          int                     max_err = MIB_REGISTERED_OK;
  53   53          const sunFm_table_t     *table;
  54   54  
       55 +        if (once != 0)
       56 +                return (MIB_DUPLICATE_REGISTRATION);
       57 +
  55   58          for (table = sun_fm_tables; table->t_name != NULL; table++) {
  56   59                  int err = table->t_init();
  57   60  
  58   61                  switch (err) {
  59   62                  case MIB_REGISTERED_OK:
  60   63                          DEBUGMSGTL((MODNAME_STR, "registered table %s\n",
  61   64                              table->t_name));
  62   65                          break;
  63   66                  case MIB_DUPLICATE_REGISTRATION:
  64   67                          (void) snmp_log(LOG_ERR, MODNAME_STR
↓ open down ↓ 8 lines elided ↑ open up ↑
  73   76                  default:
  74   77                          (void) snmp_log(LOG_ERR, MODNAME_STR
  75   78                              ": table %s initialization failed: "
  76   79                              "unknown reason\n", table->t_name);
  77   80                  }
  78   81  
  79   82                  if (err > max_err)
  80   83                          max_err = err;
  81   84          }
  82   85  
       86 +        once = 1;
  83   87          return (max_err);
  84   88  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX