aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_event.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-07-22 17:08:09 +0100
committerMatthew Wild <mwild1@gmail.com>2012-07-22 17:08:09 +0100
commitacdcd2b37388a3596c25c2d4c6bc802094a58dec (patch)
tree2593981ba2580f7c824501dc13223411d34fab49 /net/server_event.lua
parent546db4be6d3e112193599d4bb8cc062003d3cd7b (diff)
parent193ea4ef3030ab24da31f86031f6ea8386331099 (diff)
downloadprosody-acdcd2b37388a3596c25c2d4c6bc802094a58dec.tar.gz
prosody-acdcd2b37388a3596c25c2d4c6bc802094a58dec.zip
Merge 0.9->trunk
Diffstat (limited to 'net/server_event.lua')
-rw-r--r--net/server_event.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/server_event.lua b/net/server_event.lua
index 03a7708c..3c4185af 100644
--- a/net/server_event.lua
+++ b/net/server_event.lua
@@ -249,7 +249,7 @@ do
return true
end
function interface_mt:_destroy() -- close this interface + events and call last listener
- debug( "closing client with id:", self.id )
+ debug( "closing client with id:", self.id, self.fatalerror )
self:_lock( true, true, true ) -- first of all, lock the interface to avoid further actions
local _
_ = self.eventread and self.eventread:close( ) -- close events; this must be called outside of the event callbacks!
@@ -328,22 +328,22 @@ do
end
return true
end
- function interface_mt:close(now)
+ function interface_mt:close()
if self.nointerface then return nil, "locked"; end
debug( "try to close client connection with id:", self.id )
if self.type == "client" then
self.fatalerror = "client to close"
- if ( not self.eventwrite ) or now then -- try to close immediately
- self:_lock( true, true, true )
- self:_close()
- return true
- else -- wait for incomplete write request
+ if self.eventwrite then -- wait for incomplete write request
self:_lock( true, true, false )
debug "closing delayed until writebuffer is empty"
return nil, "writebuffer not empty, waiting"
+ else -- close now
+ self:_lock( true, true, true )
+ self:_close()
+ return true
end
else
- debug( "try to close server with id:", tostring(self.id), "args:", tostring(now) )
+ debug( "try to close server with id:", tostring(self.id))
self.fatalerror = "server to close"
self:_lock( true )
self:_close( 0 ) -- add new event to remove the server interface