Changeset - bf55d8c7b5b8
[Not reviewed]
0 2 0
Jan Kaluza - 14 years ago 2011-11-07 13:10:42
hanzz.k@gmail.com
Check if vhosts are configured before using them
2 files changed with 12 insertions and 2 deletions:
0 comments (0 inline, 0 general)
include/transport/config.h
Show inline comments
 
@@ -34,6 +34,7 @@
 
#define CONFIG_BOOL(PTR, KEY) (*PTR)[KEY].as<bool>()
 
#define CONFIG_LIST(PTR, KEY) (*PTR)[KEY].as<std::list<std::string> >()
 
#define CONFIG_VECTOR(PTR, KEY) (*PTR)[KEY].as<std::vector<std::string> >()
 
#define CONFIG_HAS_KEY(PTR, KEY) (*PTR).hasKey(KEY)
 

	
 
namespace Transport {
 

	
 
@@ -75,6 +76,10 @@ class Config {
 

	
 
		bool reload();
 

	
 
		bool hasKey(const std::string &key) {
 
			return m_variables.find(key) != m_variables.end();
 
		}
 

	
 
		/// Returns value of variable defined by key.
 
		
 
		/// For variables in sections you can use "section.variable" key format.
spectrum_manager/src/main.cpp
Show inline comments
 
@@ -151,7 +151,10 @@ static void start_all_instances(ManagerConfig *config) {
 
					continue;
 
				}
 
 
				std::vector<std::string> vhosts = CONFIG_VECTOR(&cfg, "vhosts.vhost");
 
				
 
				std::vector<std::string> vhosts;
 
				if (CONFIG_HAS_KEY(&cfg, "vhosts.vhost"))
 
					vhosts = CONFIG_VECTOR(&cfg, "vhosts.vhost");
 
				vhosts.push_back(CONFIG_STRING(&cfg, "service.jid"));
 
 
				BOOST_FOREACH(std::string &vhost, vhosts) {
 
@@ -201,7 +204,9 @@ static void stop_all_instances(ManagerConfig *config) {
 
					std::cerr << "Can't load config file " << itr->path().string() << ". Skipping...\n";
 
				}
 
 
				std::vector<std::string> vhosts = CONFIG_VECTOR(&cfg, "vhosts.vhost");
 
				std::vector<std::string> vhosts;
 
				if (CONFIG_HAS_KEY(&cfg, "vhosts.vhost"))
 
					vhosts = CONFIG_VECTOR(&cfg, "vhosts.vhost");
 
				vhosts.push_back(CONFIG_STRING(&cfg, "service.jid"));
 
 
				BOOST_FOREACH(std::string &vhost, vhosts) {
0 comments (0 inline, 0 general)