[xmppd-dev] commit r1533 - in trunk/jabberd14: . jabberd jabberd/lib jsm/modules
mail at jabberd.org
mail at jabberd.org
Mon Sep 8 11:30:29 CEST 2008
Author: mawis
Date: Mon Sep 8 11:30:29 2008
New Revision: 1533
Log:
Fix in mod_roster.cc, that was introduced with the new JabberID handling code (only in trunk, none of the branches). When subscriptions had been confirmed, with the wrong code the module always produced a new (duplicate) item on the roster.
Better handling of the new session control protocol: bouncing packets that are for a session manager using this protocol now trigger a session ended packet instead of a bounce with type='error'.
Modified:
trunk/jabberd14/ChangeLog
trunk/jabberd14/jabberd/deliver.cc
trunk/jabberd14/jabberd/lib/jabberdlib.h
trunk/jabberd14/jsm/modules/mod_roster.cc
Modified: trunk/jabberd14/ChangeLog
==============================================================================
--- trunk/jabberd14/ChangeLog Sun Sep 7 17:39:03 2008 (r1532)
+++ trunk/jabberd14/ChangeLog Mon Sep 8 11:30:29 2008 (r1533)
@@ -1,3 +1,9 @@
+2008-09-08 Matthias Wimmer <m at tthias.eu>
+
+ * jsm/modules/mod_roster.cc: fix duplicate roster item problem
+ * jabberd/lib/jabberdlib.h: better handling of new session control
+ * jabberd/deliver.cc: same
+
2008-09-07 Matthias Wimmer <m at tthias.eu>
* jabberd/lib/jabberid.cc: fix UTF-8 handling in JabberIDs
Modified: trunk/jabberd14/jabberd/deliver.cc
==============================================================================
--- trunk/jabberd14/jabberd/deliver.cc Sun Sep 7 17:39:03 2008 (r1532)
+++ trunk/jabberd14/jabberd/deliver.cc Mon Sep 8 11:30:29 2008 (r1533)
@@ -849,6 +849,8 @@
void deliver_fail(dpacket p, const char *err) {
xterror xt;
char message[MAX_LOG_SIZE];
+ xmlnode child = NULL;
+ char const* sc_sm = NULL;
log_debug2(ZONE, LOGT_DELIVER, "delivery failed (%s)", err);
@@ -867,6 +869,32 @@
log_warn(p->host, "dropping a %s xdb request to %s for %s", xmlnode_get_attrib_ns(p->x,"type", NULL), xmlnode_get_attrib_ns(p->x, "to", NULL), xmlnode_get_attrib_ns(p->x, "ns", NULL));
/* drop through and treat like a route failure */
case p_ROUTE:
+ // new session control protocol?
+ child = xmlnode_get_firstchild(p->x);
+ sc_sm = child ? xmlnode_get_attrib_ns(child, "sm", NS_SESSION) : NULL;
+ if (sc_sm) {
+ // control packet?
+ if (j_strcmp(xmlnode_get_namespace(child), NS_SESSION) == 0) {
+ // XXX
+ } else {
+ log_notice(p->host, "ending session/packet bounce: from=%s, to=%s, err=%s", xmlnode_get_attrib_ns(p->x, "from", NULL), xmlnode_get_attrib_ns(p->x, "to", NULL), err);
+
+ // routed packet for new session control protocol
+ xmlnode_hide(child);
+
+ xmlnode sc = xmlnode_insert_tag_ns(p->x, "session", "sc", NS_SESSION);
+ xmlnode_put_attrib_ns(sc, "action", NULL, NULL, "ended");
+ xmlnode_put_attrib_ns(sc, "c2s", "sc", NS_SESSION, xmlnode_get_attrib_ns(child, "c2s", NS_SESSION));
+ xmlnode_put_attrib_ns(sc, "sm", "sc", NS_SESSION, xmlnode_get_attrib_ns(child, "c2s", NS_SESSION));
+ xmlnode_put_attrib_ns(sc, "msg", "err", NS_JABBERD_ERRMSG, err);
+
+ jutil_tofrom(p->x);
+ deliver(dpacket_new(p->x), NULL);
+
+ break;
+ }
+ }
+
/* route packet bounce */
if (j_strcmp(xmlnode_get_attrib_ns(p->x, "type", NULL),"error") == 0) {
/* already bounced once, drop */
Modified: trunk/jabberd14/jabberd/lib/jabberdlib.h
==============================================================================
--- trunk/jabberd14/jabberd/lib/jabberdlib.h Sun Sep 7 17:39:03 2008 (r1532)
+++ trunk/jabberd14/jabberd/lib/jabberdlib.h Mon Sep 8 11:30:29 2008 (r1533)
@@ -1284,6 +1284,7 @@
#define NS_JABBERD_XDBSQL "http://jabberd.org/ns/xdbsql" /**< namespace for substitution in xdb_sql configuration */
#define NS_JABBERD_ACL "http://jabberd.org/ns/acl" /**< namespace for access control lists */
#define NS_JABBERD_LOOPCHECK "http://jabberd.org/ns/loopcheck" /**< namespace for loopchecking of s2s connections */
+#define NS_JABBERD_ERRMSG "http://jabberd.org/ns/errmsg" /**< namespace for session control error messages */
#define NS_SESSION "http://jabberd.jabberstudio.org/ns/session/1.0" /**< namespace of the jabberd2 session control protocol (http://jabberd.jabberstudio.org/dev/docs/session.shtml) */
Modified: trunk/jabberd14/jsm/modules/mod_roster.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_roster.cc Sun Sep 7 17:39:03 2008 (r1532)
+++ trunk/jabberd14/jsm/modules/mod_roster.cc Mon Sep 8 11:30:29 2008 (r1533)
@@ -84,6 +84,12 @@
}
}
+ // if something has changed: write back
+ if (removed_duplicate) {
+ log_debug2(ZONE, LOGT_ROSTER, "storing modified roster back");
+ xdb_set(u->si->xc, u->id, NS_ROSTER, ret);
+ }
+
return ret;
}
@@ -99,7 +105,9 @@
log_debug2(ZONE, LOGT_ROSTER, "getting item %s", jid_full(id));
std::ostringstream xpath;
- xpath << "*[@jid='" << id << "']";
+ xpath << "*[@jid='" << jid_full(id) << "']";
+
+ log_debug2(ZONE, LOGT_ROSTER, "xpath to use: %s", xpath.str().c_str());
xmlnode_vector ret_v = xmlnode_get_tags(roster, xpath.str().c_str(), m->si->std_namespace_prefixes);
More information about the dev
mailing list