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
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
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 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #include <fm/fmd_snmp.h>
28 28 #include <net-snmp/net-snmp-config.h>
29 29 #include <net-snmp/net-snmp-includes.h>
|
↓ 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
65 68 ": table %s initialization failed: duplicate "
66 69 "registration\n", table->t_name);
67 70 break;
68 71 case MIB_REGISTRATION_FAILED:
69 72 (void) snmp_log(LOG_ERR, MODNAME_STR
70 73 ": table %s initialization failed: agent "
71 74 "registration failure\n", table->t_name);
72 75 break;
|
↓ 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