diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-08-11 19:52:09 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-08-11 19:52:09 +0100 |
commit | fdf0b9db40067f3bfd2dc2be5609875d5173bcc7 (patch) | |
tree | 0fec8bb7f81d349c3936de1eddd3384286ac9fe0 /plugins/mod_bosh.lua | |
parent | d1a1b9e6d47c3fe2cb99bea649792a6a00f0a23b (diff) | |
download | prosody-fdf0b9db40067f3bfd2dc2be5609875d5173bcc7.tar.gz prosody-fdf0b9db40067f3bfd2dc2be5609875d5173bcc7.zip |
mod_bosh: Basic handling of rids (more to come)
Diffstat (limited to 'plugins/mod_bosh.lua')
-rw-r--r-- | plugins/mod_bosh.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index 1e3fd7ae..d8eb94e7 100644 --- a/plugins/mod_bosh.lua +++ b/plugins/mod_bosh.lua @@ -141,7 +141,7 @@ function stream_callbacks.streamopened(request, attr) -- New session sid = new_uuid(); - local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = attr.rid, host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, + 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, bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream, dispatch_stanza = core_process_stanza, log = logger.init("bosh"..sid), secure = request.secure }; @@ -206,6 +206,21 @@ function stream_callbacks.streamopened(request, attr) return; end + if session.rid then + local rid = tonumber(attr.rid); + if rid - session.rid > 1 then + session.log("warn", "rid too large (means a request was lost). Last rid: %d New rid: %s", session.rid, attr.rid); + elseif session.rid >= rid then + -- Repeated, ignore + session.log("debug", "rid repeated (on request %s), ignoring: %d", request.id, session.rid); + request.notopen = nil; + t_insert(session.requests, request); + return; + end + request.rid = rid; + session.rid = rid; + end + if attr.type == "terminate" then -- Client wants to end this session session:close(); |