[xmppd-dev] commit r1561 - in trunk/jabberd14: jabberd resolver
mail at jabberd.org
mail at jabberd.org
Thu Oct 22 03:21:18 CEST 2009
Author: mawis
Date: Thu Oct 22 03:21:18 2009
New Revision: 1561
Log:
Fix in resolver on handling destinations with multiple possible IP addresses to connect to
Improved dynamic routing
Improved logging in mio.cc (only on configuration errors or internal failures)
Modified:
trunk/jabberd14/jabberd/config.cc
trunk/jabberd14/jabberd/deliver.cc
trunk/jabberd14/jabberd/jabberd.h
trunk/jabberd14/jabberd/mio.cc
trunk/jabberd14/resolver/resolver_job.cc
Modified: trunk/jabberd14/jabberd/config.cc
==============================================================================
--- trunk/jabberd14/jabberd/config.cc Thu Oct 22 01:12:33 2009 (r1560)
+++ trunk/jabberd14/jabberd/config.cc Thu Oct 22 03:21:18 2009 (r1561)
@@ -448,6 +448,16 @@
}
/**
+ * pool_cleaner that deletes the static_hosts set of an instance
+ *
+ * @param arg pointer to the static_hosts set, that has to be deleted
+ */
+static void instance_cleanup_static_hosts(void *arg){
+ std::set<Glib::ustring>* static_hosts = static_cast<std::set<Glib::ustring>*>(arg);
+ delete static_hosts;
+}
+
+/**
* handle a second-level configuration file element (beside the <base/> element)
*
* @param x the configuration element to be handled
@@ -513,6 +523,8 @@
newi->x = x;
newi->module_init_funcs = new std::map<std::string, void*>();
pool_cleanup(newi->p, instance_cleanup_module_init_funcs, newi->module_init_funcs);
+ newi->static_hosts = new std::set<Glib::ustring>();
+ pool_cleanup(newi->p, instance_cleanup_static_hosts, newi->static_hosts);
/* make sure the id is valid for a hostname */
temp = jid_new(p, newi->id);
if (temp == NULL || j_strcmp(temp->get_domain().c_str(), newi->id) != 0) {
Modified: trunk/jabberd14/jabberd/deliver.cc
==============================================================================
--- trunk/jabberd14/jabberd/deliver.cc Thu Oct 22 01:12:33 2009 (r1560)
+++ trunk/jabberd14/jabberd/deliver.cc Thu Oct 22 03:21:18 2009 (r1561)
@@ -393,8 +393,12 @@
}
if (p->id->get_node() == "host") {
+ // check if routing for this host is already registered
+ xht ht = deliver_hashtable(i->type);
+ ilist l = static_cast<ilist>(xhash_get(ht, p->id->get_resource().c_str()));
/* dynamic register_instance crap */
- register_instance(i,p->id->get_resource().c_str());
+ if (!l)
+ register_instance(i,p->id->get_resource().c_str());
pool_free(p->p);
return;
}
@@ -476,6 +480,12 @@
log_debug2(ZONE, LOGT_REGISTER, "Unregistering %s with instance %s",host,i->id);
+ // check for fixed routings
+ if (host && i->static_hosts->find(Glib::ustring(host)) != i->static_hosts->end()) {
+ log_notice(i->id, "Not unregistering %s as this is a fixed routing.", host);
+ return;
+ }
+
ht = deliver_hashtable(i->type);
l = static_cast<ilist>(xhash_get(ht, host));
l = ilist_rem(l, i);
@@ -524,6 +534,7 @@
}
register_instance(i, host);
+ i->static_hosts->insert(Glib::ustring(host));
return r_DONE;
}
Modified: trunk/jabberd14/jabberd/jabberd.h
==============================================================================
--- trunk/jabberd14/jabberd/jabberd.h Thu Oct 22 01:12:33 2009 (r1560)
+++ trunk/jabberd14/jabberd/jabberd.h Thu Oct 22 03:21:18 2009 (r1561)
@@ -185,6 +185,7 @@
handel hds; /**< delivery handler */
register_notifier routing_update_callbacks; /**< list of callback functions, that should be called on a routing update */
std::map<std::string, void*>* module_init_funcs; /**< map with the modules of this instance, key is name, value is init function */
+ std::set<Glib::ustring>* static_hosts; /**< set of host that are fixed configured for this host */
};
/** Config file handler function callback definition */
Modified: trunk/jabberd14/jabberd/mio.cc
==============================================================================
--- trunk/jabberd14/jabberd/mio.cc Thu Oct 22 01:12:33 2009 (r1560)
+++ trunk/jabberd14/jabberd/mio.cc Thu Oct 22 03:21:18 2009 (r1561)
@@ -682,7 +682,9 @@
saddr = make_addr(cd->ip);
#endif
if (saddr == NULL) {
- newm->connect_errmsg = "Could not resolve hostname or parse IP address";
+ std::ostringstream message;
+ message << "Could not resolve hostname or parse IP address: " << cd->ip;
+ newm->connect_errmsg = pstrdup(newm->p, message.str().c_str());
if (cd->cb != NULL)
(*cd->cb)(newm, MIO_CLOSED, cd->cb_arg, NULL, NULL, 0);
cd->connected = -1;
Modified: trunk/jabberd14/resolver/resolver_job.cc
==============================================================================
--- trunk/jabberd14/resolver/resolver_job.cc Thu Oct 22 01:12:33 2009 (r1560)
+++ trunk/jabberd14/resolver/resolver_job.cc Thu Oct 22 03:21:18 2009 (r1561)
@@ -121,7 +121,7 @@
try {
xmppd::lwresc::a_record const* rr = dynamic_cast<xmppd::lwresc::a_record const*>(*p);
- result_buffer << " " << rr->getAddress() << ":" << current_providing_host->second;
+ result_buffer << "," << rr->getAddress() << ":" << current_providing_host->second;
} catch (std::bad_cast) {
}
}
@@ -168,7 +168,7 @@
try {
xmppd::lwresc::aaaa_record const* rr = dynamic_cast<xmppd::lwresc::aaaa_record const*>(*p);
- result_buffer << " [" << rr->getAddress() << "]:" << current_providing_host->second;
+ result_buffer << ",[" << rr->getAddress() << "]:" << current_providing_host->second;
} catch (std::bad_cast) {
}
}
More information about the dev
mailing list