[svn] commit: r416 - in /branches/parkinglot/src/bin/parkinglot: ccsession.cc ccsession.h main.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Dec 30 09:45:43 UTC 2009


Author: jelte
Date: Wed Dec 30 09:45:42 2009
New Revision: 416

Log:
catch session error and exit (fix for trac ticket 11)

Modified:
    branches/parkinglot/src/bin/parkinglot/ccsession.cc
    branches/parkinglot/src/bin/parkinglot/ccsession.h
    branches/parkinglot/src/bin/parkinglot/main.cc

Modified: branches/parkinglot/src/bin/parkinglot/ccsession.cc
==============================================================================
--- branches/parkinglot/src/bin/parkinglot/ccsession.cc (original)
+++ branches/parkinglot/src/bin/parkinglot/ccsession.cc Wed Dec 30 09:45:42 2009
@@ -75,7 +75,7 @@
                                std::string spec_file_name,
                                isc::data::ElementPtr(*config_handler)(isc::data::ElementPtr new_config),
                                isc::data::ElementPtr(*command_handler)(isc::data::ElementPtr command)
-                              ) :
+                              ) throw (isc::cc::SessionError):
     module_name_(module_name),
     session_(isc::cc::Session())
 {

Modified: branches/parkinglot/src/bin/parkinglot/ccsession.h
==============================================================================
--- branches/parkinglot/src/bin/parkinglot/ccsession.h (original)
+++ branches/parkinglot/src/bin/parkinglot/ccsession.h Wed Dec 30 09:45:42 2009
@@ -36,7 +36,7 @@
     CommandSession(std::string module_name, std::string spec_file_name,
                    isc::data::ElementPtr(*config_handler)(isc::data::ElementPtr new_config) = NULL,
                    isc::data::ElementPtr(*command_handler)(isc::data::ElementPtr command) = NULL
-                  );
+                  ) throw (isc::cc::SessionError);
     int getSocket();
 
     /**

Modified: branches/parkinglot/src/bin/parkinglot/main.cc
==============================================================================
--- branches/parkinglot/src/bin/parkinglot/main.cc (original)
+++ branches/parkinglot/src/bin/parkinglot/main.cc Wed Dec 30 09:45:42 2009
@@ -133,35 +133,40 @@
     //plot = ParkingLot(port);
 
     // initialize command channel
-    CommandSession cs = CommandSession(PROGRAM, SPECFILE, my_config_handler, my_command_handler);
+    try {
+        CommandSession cs = CommandSession(PROGRAM, SPECFILE, my_config_handler, my_command_handler);
     
-    // main server loop
-    fd_set fds;
-    int ps = plot.getSocket();
-    int ss = cs.getSocket();
-    int nfds = max(ps, ss) + 1;
-    int counter = 0;
-
-    cout << "Server started." << endl;
-    while (true) {
-        FD_ZERO(&fds);
-        FD_SET(ps, &fds);
-        FD_SET(ss, &fds);
-
-        int n = select(nfds, &fds, NULL, NULL, NULL);
-        if (n < 0)
-            throw FatalError("select error");
-
-        if (FD_ISSET(ps, &fds)) {
-            ++counter;
-            plot.processMessage();
+        // main server loop
+        fd_set fds;
+        int ps = plot.getSocket();
+        int ss = cs.getSocket();
+        int nfds = max(ps, ss) + 1;
+        int counter = 0;
+    
+        cout << "Server started." << endl;
+        while (true) {
+            FD_ZERO(&fds);
+            FD_SET(ps, &fds);
+            FD_SET(ss, &fds);
+    
+            int n = select(nfds, &fds, NULL, NULL, NULL);
+            if (n < 0)
+                throw FatalError("select error");
+    
+            if (FD_ISSET(ps, &fds)) {
+                ++counter;
+                plot.processMessage();
+            }
+    
+            /* isset not really necessary, but keep it for now */
+            if (FD_ISSET(ss, &fds)) {
+                cs.check_command();
+            }
         }
-
-        /* isset not really necessary, but keep it for now */
-        if (FD_ISSET(ss, &fds)) {
-            cs.check_command();
-        }
+    } catch (isc::cc::SessionError se) {
+        cout << se.what() << endl;
+        exit(1);
     }
-
+    
     return (0);
 }




More information about the bind10-changes mailing list