Browse Source

[1546] delay listening to config/command from the module cc session
until the initial configuration is completed. otherwise it confuses
communication with the socket creator and makes listen_on fail.

JINMEI Tatuya 13 years ago
parent
commit
be7b75528c
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/bin/resolver/main.cc

+ 11 - 1
src/bin/resolver/main.cc

@@ -209,9 +209,16 @@ main(int argc, char* argv[]) {
 
 
         cc_session = new Session(io_service.get_io_service());
         cc_session = new Session(io_service.get_io_service());
         isc::server_common::initSocketReqeustor(*cc_session);
         isc::server_common::initSocketReqeustor(*cc_session);
+
+        // We delay starting listening to new commands/config just before we
+        // go into the main loop to avoid confusion due to mixture of
+        // synchronous and asynchronous operations (this would happen in
+        // initial communication with the socket creator that takes place in
+        // updateConfig()).  Until then all operations on the CC session will
+        // take place synchronously.
         config_session = new ModuleCCSession(specfile, *cc_session,
         config_session = new ModuleCCSession(specfile, *cc_session,
                                              my_config_handler,
                                              my_config_handler,
-                                             my_command_handler);
+                                             my_command_handler, false);
         LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_CONFIG_CHANNEL);
         LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_CONFIG_CHANNEL);
 
 
         // FIXME: This does not belong here, but inside Boss
         // FIXME: This does not belong here, but inside Boss
@@ -229,6 +236,9 @@ main(int argc, char* argv[]) {
         resolver->updateConfig(config_session->getFullConfig(), true);
         resolver->updateConfig(config_session->getFullConfig(), true);
         LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_CONFIG_LOADED);
         LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_CONFIG_LOADED);
 
 
+        // Now start asynchronous read.
+        config_session->start();
+
         LOG_INFO(resolver_logger, RESOLVER_STARTED);
         LOG_INFO(resolver_logger, RESOLVER_STARTED);
         io_service.run();
         io_service.run();
     } catch (const std::exception& ex) {
     } catch (const std::exception& ex) {