[xmppd-dev] commit r1560 - in trunk/jabberd14: jabberd jabberd/base resolver

mail at jabberd.org mail at jabberd.org
Thu Oct 22 01:12:35 CEST 2009


Author: mawis
Date: Thu Oct 22 01:12:33 2009
New Revision: 1560

Log:
Small cleanup of the deliver.cc interface
Handling of finished jobs in the resolver code changed

Modified:
   trunk/jabberd14/jabberd/base/base_accept.cc
   trunk/jabberd14/jabberd/deliver.cc
   trunk/jabberd14/jabberd/jabberd.h
   trunk/jabberd14/jabberd/mio_tls.cc
   trunk/jabberd14/resolver/resolver.cc
   trunk/jabberd14/resolver/resolver.h

Modified: trunk/jabberd14/jabberd/base/base_accept.cc
==============================================================================
--- trunk/jabberd14/jabberd/base/base_accept.cc	Mon Oct 19 20:33:44 2009	(r1559)
+++ trunk/jabberd14/jabberd/base/base_accept.cc	Thu Oct 22 01:12:33 2009	(r1560)
@@ -126,11 +126,9 @@
                 */
 
                 /* if we are supposed to be careful about what comes from this socket */
-                if(ai->restrict_var)
-                {
+                if(ai->restrict_var) {
                     jp = jpacket_new(x);
-                    if(jp->type == JPACKET_UNKNOWN || jp->to == NULL || jp->from == NULL || deliver_hostcheck(jp->from->get_domain().c_str()) != ai->i)
-                    {
+                    if (jp->type == JPACKET_UNKNOWN || jp->to == NULL || jp->from == NULL || !deliver_is_delivered_to(jp->from->get_domain(), ai->i)) {
                         jutil_error_xmpp(x,XTERROR_INTERNAL);
                         mio_write(m,x,NULL,0);
                         return;

Modified: trunk/jabberd14/jabberd/deliver.cc
==============================================================================
--- trunk/jabberd14/jabberd/deliver.cc	Mon Oct 19 20:33:44 2009	(r1559)
+++ trunk/jabberd14/jabberd/deliver.cc	Thu Oct 22 01:12:33 2009	(r1560)
@@ -714,15 +714,13 @@
  * @param host the hostname to get checked
  * @return the instance packets of this host get mapped to
  */
-instance deliver_hostcheck(char const* host) {
+bool deliver_is_delivered_to(Glib::ustring const& host, _instance const* i) {
     ilist l;
 
-    if (host == NULL)
-	return NULL;
-    if ((l = deliver_hashmatch(deliver__hnorm,host)) == NULL || l->next)
-	return NULL;
+    if ((l = deliver_hashmatch(deliver__hnorm, host.c_str())) == NULL || l->next)
+	return false;
 
-    return l->i;
+    return l->i == i;
 }
 
 /**

Modified: trunk/jabberd14/jabberd/jabberd.h
==============================================================================
--- trunk/jabberd14/jabberd/jabberd.h	Mon Oct 19 20:33:44 2009	(r1559)
+++ trunk/jabberd14/jabberd/jabberd.h	Thu Oct 22 01:12:33 2009	(r1560)
@@ -195,20 +195,21 @@
 
 /*** public functions for base modules ***/
 void register_config(pool p, char *node, cfhandler f, void *arg); /* register a function to handle that node in the config file */
-void register_instance(instance i, char const* host); /* associate an id with a hostname for that packet type */
-void unregister_instance(instance i, char const* host); /* disassociate an id with a hostname for that packet type */
-void register_routing_update_callback(instance i, register_notify f, void *arg); /**< register a function that gets called on registering/unregistering a host for an instance */
-void register_phandler(instance id, order o, phandler f, void *arg); /* register a function to handle delivery for this instance */
 void register_beat(int freq, beathandler f, void *arg); /* register the function to be called from the heartbeat, freq is how often, <= 0 is ignored */
 typedef void(*shutdown_func)(void*arg);
 void register_shutdown(shutdown_func f,void *arg); /* register to be notified when the server is shutting down */
 
+// functions in deliver.cc
+void register_instance(instance i, char const* host); /* associate an id with a hostname for that packet type */
+void unregister_instance(instance i, char const* host); /* disassociate an id with a hostname for that packet type */
+void register_routing_update_callback(instance i, register_notify f, void *arg); /**< register a function that gets called on registering/unregistering a host for an instance */
+void register_phandler(instance id, order o, phandler f, void *arg); /* register a function to handle delivery for this instance */
 dpacket dpacket_new(xmlnode x); /* create a new delivery packet from source xml */
 dpacket dpacket_copy(dpacket p); /* copy a packet (and it's flags) */
 void deliver(dpacket p, instance i); /* deliver packet from sending instance */
 void deliver_fail(dpacket p, const char *err); /* bounce a packet intelligently */
 void deliver_instance(instance i, dpacket p); /* deliver packet TO the instance, if the result != r_DONE, you have to handle the packet! */
-instance deliver_hostcheck(char const* host); /* util that returns the instance handling this hostname for normal packets */
+bool deliver_is_delivered_to(Glib::ustring const& host, _instance const* i); /* util that returns the instance handling this hostname for normal packets */
 bool deliver_is_uplink(instance i); // checks if an instance is configured to be the uplink
 std::set<Glib::ustring> deliver_routed_hosts(ptype type, instance i);
 

Modified: trunk/jabberd14/jabberd/mio_tls.cc
==============================================================================
--- trunk/jabberd14/jabberd/mio_tls.cc	Mon Oct 19 20:33:44 2009	(r1559)
+++ trunk/jabberd14/jabberd/mio_tls.cc	Thu Oct 22 01:12:33 2009	(r1560)
@@ -596,6 +596,7 @@
 	    continue;
 	}
 
+	/*
 	// load an OpenPGP key
 	if (j_strcmp(xmlnode_get_localname(cur), "openpgp") == 0) {
 	    char const *const pubfile = xmlnode_get_data(cur);
@@ -639,6 +640,7 @@
 
 	    continue;
 	}
+	*/
 
 	// setup protocols to use
 	if (j_strcmp(xmlnode_get_localname(cur), "protocols") == 0) {

Modified: trunk/jabberd14/resolver/resolver.cc
==============================================================================
--- trunk/jabberd14/resolver/resolver.cc	Mon Oct 19 20:33:44 2009	(r1559)
+++ trunk/jabberd14/resolver/resolver.cc	Thu Oct 22 01:12:33 2009	(r1560)
@@ -74,6 +74,9 @@
 	    std::istringstream buffer_stream(buffer);
 	    xmppd::lwresc::lwresult query_result(buffer_stream);
 
+	    // make sure the listener does not get deleted while it is running
+	    xmppd::xhash< xmppd::pointer<resolver_job> > pending_jobs_lock = pending_jobs;
+
 	    // send the signal for this result
 	    uint32_t serial = query_result.getSerial();
 	    std::map<uint32_t, std::pair<time_t, sigc::signal<void, xmppd::lwresc::lwresult const&> > >::iterator result_listener = result_listeners.find(serial);
@@ -197,9 +200,8 @@
 	}
 
 	void resolver::handle_completed_job(resolver_job& job) {
-	    // move the job from pending to finished
+	    // delete the job from the pending jobs list
 	    char const* host = job.get_packets().front()->host;
-	    finished_jobs.push_back(pending_jobs[host]);
 	    pending_jobs.erase(host);
 
 	    // get the packets
@@ -211,7 +213,7 @@
 	    // get the resolved ips
 	    Glib::ustring ips = job.get_result();
 
-	    log(xmppd::notice) << "Finished resolver job: " << job;
+	    log(xmppd::notice) << (ips.empty() ? "Finished resolver job without result: " : "Finished resolver job: ") << job;
 
 	    // resend the packets
 	    for (std::list<dpacket>::const_iterator p = packets.begin(); p != packets.end(); ++p) {

Modified: trunk/jabberd14/resolver/resolver.h
==============================================================================
--- trunk/jabberd14/resolver/resolver.h	Mon Oct 19 20:33:44 2009	(r1559)
+++ trunk/jabberd14/resolver/resolver.h	Thu Oct 22 01:12:33 2009	(r1560)
@@ -399,13 +399,6 @@
 		xmppd::xhash< xmppd::pointer<resolver_job> > pending_jobs;
 
 		/**
-		 * the jobs that have finished
-		 *
-		 * @todo we have to delete these jobs, after they returned
-		 */
-		std::list< xmppd::pointer<resolver_job> > finished_jobs;
-
-		/**
 		 * map containing the listeners for resolver results
 		 *
 		 * the key is the query serial which will be in the result


More information about the dev mailing list