changeset 3820:8adf9090a487

6411493 snmpdx dies SIGBUS/SIGSEGV when SNMP GET requests received during sub-agent start-up
author pd155743
date Thu, 15 Mar 2007 06:16:24 -0700
parents 9aa2160bf09e
children 2c5d11a65307
files usr/src/cmd/agents/snmp/snmprelayd/session.c usr/src/cmd/agents/snmp/snmprelayd/session.h usr/src/cmd/agents/snmp/snmprelayd/subtree.c
diffstat 3 files changed, 42 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/agents/snmp/snmprelayd/session.c	Wed Mar 14 13:41:07 2007 -0700
+++ b/usr/src/cmd/agents/snmp/snmprelayd/session.c	Thu Mar 15 06:16:24 2007 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
@@ -73,7 +73,7 @@
 
 /***** LOCAL VARIABLES *****/
 
-static Session *first_session = NULL;
+Session *first_session = NULL;
 
 static u_long session_id = 0;
 
@@ -89,17 +89,17 @@
 static void trace_request(Request *request);
 
 static Session *session_open(Address *address, SNMP_pdu *pdu);
-static void session_close(Session *session);
+void session_close(Session *session);
 
 static int session_build_request_list(Session *session, int index, SNMP_variable *variable, Subtree *subtree);
 static int session_build_local_sysUptime(Session *session, int index, SNMP_variable *variable);
 
 
-static void session_remove_from_list(Session *session);
+void session_remove_from_list(Session *session);
 
-static void session_free(Session *session);
-static void request_list_free(Request *request_list);
-static void request_free(Request *request);
+void session_free(Session *session);
+void request_list_free(Request *request_list);
+void request_free(Request *request);
 
 static void session_respond(Session *session);
 static void session_respond_error(Session *session, int status, int index);
@@ -805,7 +805,7 @@
 
 /************************************************************************/
 
-static void session_close(Session *session)
+void session_close(Session *session)
 {
 	Three_Phase *tp;
 
@@ -848,7 +848,7 @@
 
 /************************************************************************/
 
-static void session_remove_from_list(Session *session)
+void session_remove_from_list(Session *session)
 {
 	Session *sp;
 	Session *osp;
@@ -887,7 +887,7 @@
 
 /************************************************************************/
 
-static void session_free(Session *session)
+void session_free(Session *session)
 {
 	if(session == NULL)
 	{
@@ -907,7 +907,7 @@
 
 /************************************************************************/
 
-static void request_list_free(Request *request_list)
+void request_list_free(Request *request_list)
 {
 	Request *next_request;
 
@@ -1375,7 +1375,7 @@
 
 /************************************************************************/
 
-static void request_free(Request *request)
+void request_free(Request *request)
 {
 	if(request == NULL)
 	{
--- a/usr/src/cmd/agents/snmp/snmprelayd/session.h	Wed Mar 14 13:41:07 2007 -0700
+++ b/usr/src/cmd/agents/snmp/snmprelayd/session.h	Thu Mar 15 06:16:24 2007 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -13,13 +12,16 @@
  *
  * When distributing Covered Code, include this CDDL HEADER in each
  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the 
+ * If applicable, add the following below this CDDL HEADER, with the
  * fields enclosed by brackets "[]" replaced with your own identifying
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  *
- * Copyright 1996 Sun Microsystems, Inc.  All Rights Reserved.
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -136,7 +138,10 @@
 
 extern int any_outstanding_session();
 
-#endif
+extern void session_close(Session *session);
+extern void session_free(Session *session);
+extern void request_list_free(Request *request_list);
+extern void request_free(Request *request);
 
+#endif /* _SESSION_H_ */
 
-
--- a/usr/src/cmd/agents/snmp/snmprelayd/subtree.c	Wed Mar 14 13:41:07 2007 -0700
+++ b/usr/src/cmd/agents/snmp/snmprelayd/subtree.c	Thu Mar 15 06:16:24 2007 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -13,13 +12,16 @@
  *
  * When distributing Covered Code, include this CDDL HEADER in each
  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the 
+ * If applicable, add the following below this CDDL HEADER, with the
  * fields enclosed by brackets "[]" replaced with your own identifying
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
+ */
+
+/*
  *
- * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -49,7 +51,7 @@
 #include "session.h"
 
 
-
+extern Session *first_session;
 Subtree *first_subtree = NULL;
 int sap_reg_tree_index=1;
 
@@ -409,7 +411,8 @@
 {
 	Subtree *sp = first_subtree;
 	Subtree *next, *last=NULL;
-
+	Session *spp;
+	Request *rp;
 
 	while(sp)
 	{
@@ -421,6 +424,14 @@
 			}else{
 			  last->next_subtree = next;
 			}
+
+			for (spp = first_session; spp; spp = spp->next_session) {
+				for (rp = spp->first_request; rp; rp = rp->next_request) {
+					if (rp->subtree->agent == sp->agent)
+						session_close(spp);
+				}
+			}
+
 			subtree_remove_from_agent_list(sp);
 			subtree_free(sp);
 		}else{