Software /
code /
prosody
Comparison
plugins/mod_component.lua @ 981:71fce47dff7b
mod_component: Deregister component on disconnect
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 11 Apr 2009 22:22:24 +0100 |
parent | 979:d0fd49c4339c |
child | 1042:a3d77353c18a |
comparison
equal
deleted
inserted
replaced
980:b52d442161f2 | 981:71fce47dff7b |
---|---|
12 | 12 |
13 local t_concat = table.concat; | 13 local t_concat = table.concat; |
14 | 14 |
15 local connlisteners = require "net.connlisteners"; | 15 local connlisteners = require "net.connlisteners"; |
16 local cm_register_component = require "core.componentmanager".register_component; | 16 local cm_register_component = require "core.componentmanager".register_component; |
17 local cm_deregister_component = require "core.componentmanager".deregister_component; | |
17 local uuid_gen = require "util.uuid".generate; | 18 local uuid_gen = require "util.uuid".generate; |
18 local sha1 = require "util.hashes".sha1; | 19 local sha1 = require "util.hashes".sha1; |
19 local st = stanza; | 20 local st = stanza; |
20 local init_xmlhandlers = require "core.xmlhandlers"; | 21 local init_xmlhandlers = require "core.xmlhandlers"; |
21 | 22 |
194 function component_listener.disconnect(conn, err) | 195 function component_listener.disconnect(conn, err) |
195 local session = sessions[conn]; | 196 local session = sessions[conn]; |
196 if session then | 197 if session then |
197 (session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err)); | 198 (session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err)); |
198 if session.host then | 199 if session.host then |
199 if session.component then | 200 log("debug", "deregistering component"); |
200 deregister_component(session.host); | 201 cm_deregister_component(session.host); |
201 end | 202 hosts[session.host].connected = nil; |
202 end | 203 end |
203 sessions[conn] = nil; | 204 sessions[conn] = nil; |
204 session = nil; | 205 session = nil; |
205 collectgarbage("collect"); | 206 collectgarbage("collect"); |
206 end | 207 end |