From da038e6c8f2f2db10c610337d6aa9a7e8622f3b4 Mon Sep 17 00:00:00 2001
From: brad kittenbrink <brad@lindenlab.com>
Date: Fri, 10 Jul 2009 18:29:10 -0700
Subject: First draft of cleaning up eventhost module on viewer shutdown. 
 Still need to make the whole system more generalized and data driven.

---
 indra/newview/llappviewer.cpp | 25 +++++++++++++++++++------
 indra/newview/llappviewer.h   |  5 ++++-
 2 files changed, 23 insertions(+), 7 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 947f5bdb20..8492644b2d 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1154,7 +1154,17 @@ bool LLAppViewer::mainLoop()
 
 bool LLAppViewer::cleanup()
 {
-    // *TODO - unload event host module here -brad
+	// *TODO - generalize this and move DSO wrangling to a helper class -brad
+	std::set<struct apr_dso_handle_t *>::const_iterator i;
+	for(i = mPlugins.begin(); i != mPlugins.end(); ++i)
+	{
+		int (*ll_plugin_stop_func)(void) = NULL;
+		apr_status_t rv = apr_dso_sym((apr_dso_handle_sym_t*)&ll_plugin_stop_func, *i, "ll_plugin_stop");
+		ll_plugin_stop_func();
+
+		rv = apr_dso_unload(*i);
+	}
+	mPlugins.clear();
 
 	//----------------------------------------------
 	//this test code will be removed after the test
@@ -4098,7 +4108,7 @@ void LLAppViewer::handleLoginComplete()
 }
 
 // *TODO - generalize this and move DSO wrangling to a helper class -brad
-void LLAppViewer::loadEventHostModule(S32 listen_port) const
+void LLAppViewer::loadEventHostModule(S32 listen_port)
 {
 	std::string dso_name =
 #if LL_WINDOWS
@@ -4133,9 +4143,12 @@ void LLAppViewer::loadEventHostModule(S32 listen_port) const
 	LLSD args;
 	args["listen_port"] = listen_port;
 
-	ll_plugin_start_func(args);
+	int status = ll_plugin_start_func(args);
+
+	if(status != 0)
+	{
+		llwarns << "problem loading eventhost plugin, status: " << status << llendl;
+	}
 
-    args = LLSD();
-    args["MESSAGE"] = "EventHost module loaded successfully";
-    LLNotifications::instance().add("SystemMessageTip", args);
+	mPlugins.insert(eventhost_dso_handle);
 }
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 1227ab470f..69f2a074aa 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -47,6 +47,7 @@ class LLVFS;
 class LLWatchdogTimeout;
 class LLWorkerThread;
 
+struct apr_dso_handle_t;
 
 
 class LLAppViewer : public LLApp
@@ -204,7 +205,7 @@ private:
     void sendLogoutRequest();
     void disconnectViewer();
 
-	void loadEventHostModule(S32 listen_port) const;
+	void loadEventHostModule(S32 listen_port);
 	
 	// *FIX: the app viewer class should be some sort of singleton, no?
 	// Perhaps its child class is the singleton and this should be an abstract base.
@@ -251,6 +252,8 @@ private:
 
     LLAllocator mAlloc;
 
+	std::set<struct apr_dso_handle_t*> mPlugins;
+
 public:
 	//some information for updater
 	typedef struct
-- 
cgit v1.2.3