Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 3041:7489ac1d5938
mod_bosh: Fix handling of rids by not dropping requests with repeated rids (assign them their sid instead), and always starting a session with first_rid-1.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 17 May 2010 11:46:54 +0100 |
parent | 3040:c02d0e7e088e |
child | 3042:b1961f6c9853 |
comparison
equal
deleted
inserted
replaced
3040:c02d0e7e088e | 3041:7489ac1d5938 |
---|---|
143 return; | 143 return; |
144 end | 144 end |
145 | 145 |
146 -- New session | 146 -- New session |
147 sid = new_uuid(); | 147 sid = new_uuid(); |
148 local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid), host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, | 148 local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid)-1, host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, |
149 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, | 149 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, |
150 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream, | 150 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream, |
151 dispatch_stanza = core_process_stanza, log = logger.init("bosh"..sid), secure = request.secure }; | 151 dispatch_stanza = core_process_stanza, log = logger.init("bosh"..sid), secure = request.secure }; |
152 sessions[sid] = session; | 152 sessions[sid] = session; |
153 | 153 |
210 local diff = rid - session.rid; | 210 local diff = rid - session.rid; |
211 if diff > 1 then | 211 if diff > 1 then |
212 session.log("warn", "rid too large (means a request was lost). Last rid: %d New rid: %s", session.rid, attr.rid); | 212 session.log("warn", "rid too large (means a request was lost). Last rid: %d New rid: %s", session.rid, attr.rid); |
213 elseif diff <= 0 then | 213 elseif diff <= 0 then |
214 -- Repeated, ignore | 214 -- Repeated, ignore |
215 session.log("debug", "rid repeated (on request %s), ignoring: %d", request.id, session.rid); | 215 session.log("debug", "rid repeated (on request %s), ignoring: %s (diff %d)", request.id, session.rid, diff); |
216 request.notopen = nil; | 216 request.notopen = nil; |
217 request.sid = sid; | |
217 t_insert(session.requests, request); | 218 t_insert(session.requests, request); |
218 return; | 219 return; |
219 end | 220 end |
220 session.rid = rid; | 221 session.rid = rid; |
221 end | 222 end |