summaryrefslogtreecommitdiff
path: root/apps/Gateway/Gateway/gatewayd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/Gateway/Gateway/gatewayd.cpp')
-rw-r--r--apps/Gateway/Gateway/gatewayd.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/apps/Gateway/Gateway/gatewayd.cpp b/apps/Gateway/Gateway/gatewayd.cpp
index b0af5f7cace..babb6c80350 100644
--- a/apps/Gateway/Gateway/gatewayd.cpp
+++ b/apps/Gateway/Gateway/gatewayd.cpp
@@ -1,11 +1,28 @@
-// Main driver program for the Gateway. This file is completely
// $Id$
+// Main driver program for the Gateway. This file is completely
// generic code due to the ACE Service Configurator framework!
#include "ace/Service_Config.h"
#include "Gateway.h"
+class Service_Ptr
+ // = TITLE
+ // Holds the <ACE_Service_Object> * until we're done.
+{
+public:
+ Service_Ptr (ACE_Service_Object *so)
+ : service_object_ (so) {}
+
+ ~Service_Ptr (void) { this->service_object_->fini (); }
+
+ ACE_Service_Object *operator-> () { return this->service_object_; }
+
+private:
+ ACE_Service_Object *service_object_;
+ // Holds the service object until we're done.
+};
+
int
main (int argc, char *argv[])
{
@@ -15,19 +32,27 @@ main (int argc, char *argv[])
{
if (errno != ENOENT)
ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1));
- else // Use static binding.
+ else // Use static linking.
{
- ACE_Service_Object *so = ACE_SVC_INVOKE (Gateway);
+ Service_Ptr sp = ACE_SVC_INVOKE (Gateway);
- if (so->init (argc - 1, argv + 1) == -1)
+ if (sp->init (argc - 1, argv + 1) == -1)
ACE_ERROR ((LM_ERROR, "%p\n%a", "init", 1));
+
+ // Run forever, performing the configured services until we are
+ // shut down by a SIGINT/SIGQUIT signal.
+
+ daemon.run_reactor_event_loop ();
+
+ // Destructors of Service_Ptr's automagically call fini().
}
}
+ else // Use dynamic linking.
- // Run forever, performing the configured services until we are shut
- // down by a SIGINT/SIGQUIT signal.
+ // Run forever, performing the configured services until we are
+ // shut down by a SIGINT/SIGQUIT signal.
- daemon.run_reactor_event_loop ();
+ daemon.run_reactor_event_loop ();
return 0;
}