# HG changeset patch # User Matthew Wild # Date 1234377044 0 # Node ID 31d5be1371cf1fe1e648f04eac5eb7a8ecec0eb9 # Parent 89eb9f59993ca08e0f0e0a52589d74d095922894# Parent 1de8a32f81e91d859aa395ec3eb4ad30af75f154 Merge with waqas for MUC/routing fixes diff -r 1de8a32f81e9 -r 31d5be1371cf core/stanza_router.lua diff -r 1de8a32f81e9 -r 31d5be1371cf net/server.lua --- a/net/server.lua Wed Feb 11 23:26:18 2009 +0500 +++ b/net/server.lua Wed Feb 11 18:30:44 2009 +0000 @@ -362,7 +362,7 @@ _closelist[ handler ] = "send buffer exceeded" -- cannot close the client at the moment, have to wait to the end of the cycle handler.write = idfalse -- dont write anymore return false - elseif not _sendlist[ socket ] then + elseif socket and not _sendlist[ socket ] then _sendlistlen = _sendlistlen + 1 _sendlist[ _sendlistlen ] = socket _sendlist[ socket ] = _sendlistlen @@ -439,7 +439,7 @@ out_put( "server.lua: client ", ip, ":", clientport, " error: ", err ) fatalerror = true disconnect( handler, err ) - handler.close( ) + _ = handler and handler.close( ) return false end end diff -r 1de8a32f81e9 -r 31d5be1371cf plugins/mod_bosh.lua --- a/plugins/mod_bosh.lua Wed Feb 11 23:26:18 2009 +0500 +++ b/plugins/mod_bosh.lua Wed Feb 11 18:30:44 2009 +0000 @@ -42,7 +42,7 @@ log("debug", "Request %s suffered error %s", tostring(request.id), body); return; end - log("debug", "Handling new request %s: %s\n----------", request.id, tostring(body)); + --log("debug", "Handling new request %s: %s\n----------", request.id, tostring(body)); request.notopen = true; request.log = log; local parser = lxp.new(init_xmlhandlers(request, stream_callbacks), "|"); @@ -79,7 +79,7 @@ waiting_requests[request] = true; end - log("debug", "Had nothing to say, so leaving request unanswered for now"); + log("debug", "Have nothing to say, so leaving request unanswered for now"); return true; end end @@ -101,8 +101,6 @@ end function stream_callbacks.streamopened(request, attr) - print("Attr:") - for k,v in pairs(attr) do print("", k, v); end log("debug", "BOSH body open (sid: %s)", attr.sid); local sid = attr.sid if not sid then @@ -139,7 +137,7 @@ log("debug", "We have an open request, so using that to send with"); response.body = t_concat{"", tostring(s), "" }; oldest_request:send(response); - log("debug", "Sent"); + --log("debug", "Sent"); if oldest_request.stayopen then if #r>1 then -- Move front request to back @@ -245,6 +243,7 @@ (session.log or log)("debug", "BOSH client inactive too long, destroying session at %d", now); sessions[session.sid] = nil; inactive_sessions[session] = nil; + session.bosh_max_inactive = nil; -- Stop us marking this session as active during destroy sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds"); end else diff -r 1de8a32f81e9 -r 31d5be1371cf util/stanza.lua --- a/util/stanza.lua Wed Feb 11 23:26:18 2009 +0500 +++ b/util/stanza.lua Wed Feb 11 18:30:44 2009 +0000 @@ -12,6 +12,7 @@ local t_remove = table.remove; local t_concat = table.concat; local s_format = string.format; +local s_match = string.match; local tostring = tostring; local setmetatable = setmetatable; local pairs = pairs; @@ -114,11 +115,22 @@ local xml_escape = xml_escape; local function dostring(t, buf, self, xml_escape) + local nsid, ns, attrk = 0; t_insert(buf, "<"); t_insert(buf, t.name); for k, v in pairs(t.attr) do if type(k) == "string" then t_insert(buf, " "); - t_insert(buf, k); + ns, attrk = s_match(k, "^([^|]+)|(.+)$"); + if ns then + nsid = (nsid or -1) + 1; + t_insert(buf, "xmlns:ns"..nsid); + t_insert(buf, "='"); + t_insert(buf, (xml_escape(tostring(ns)))); + t_insert(buf, "' "); + t_insert(buf, "ns"..nsid..":"..attrk); + else + t_insert(buf, k); + end t_insert(buf, "='"); t_insert(buf, (xml_escape(tostring(v)))); t_insert(buf, "'");