aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-05-05 15:21:17 +0100
committerMatthew Wild <mwild1@gmail.com>2010-05-05 15:21:17 +0100
commitc51d0beea7af41fd615cb11640a2a6bb0fcf1aab (patch)
treefe15a9bda9db6cc20ecce075af90d8abd3f0d649
parent93b148715f75aa29947fa3181cdf22d8209431a8 (diff)
downloadprosody-c51d0beea7af41fd615cb11640a2a6bb0fcf1aab.tar.gz
prosody-c51d0beea7af41fd615cb11640a2a6bb0fcf1aab.zip
net.server_select, net.server_event: Support for :pause() and :resume() on connections
-rw-r--r--net/server_event.lua15
-rw-r--r--net/server_select.lua7
2 files changed, 21 insertions, 1 deletions
diff --git a/net/server_event.lua b/net/server_event.lua
index dde13e61..c28c5ce2 100644
--- a/net/server_event.lua
+++ b/net/server_event.lua
@@ -282,8 +282,21 @@ do
return nointerface, noreading, nowriting
end
+ --TODO: Deprecate
function interface_mt:lock_read(switch)
- return self:_lock(self.nointerface, switch, self.nowriting);
+ if switch then
+ return self:pause();
+ else
+ return self:resume();
+ end
+ end
+
+ function interface_mt:pause()
+ return self:_lock(self.nointerface, true, self.nowriting);
+ end
+
+ function interface_mt:resume()
+ return self:_lock(self.nointerface, false, self.nowriting);
end
function interface_mt:counter(c)
diff --git a/net/server_select.lua b/net/server_select.lua
index 48262ccc..6d6f7fbc 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -392,6 +392,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
maxreadlen = readlen or maxreadlen
return bufferlen, maxreadlen, maxsendlen
end
+ --TODO: Deprecate
handler.lock_read = function (self, switch)
if switch == true then
local tmp = _readlistlen
@@ -409,6 +410,12 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
end
return noread
end
+ handler.pause = function (self)
+ return self:lock_read(true);
+ end
+ handler.resume = function (self)
+ return self:lock_read(false);
+ end
handler.lock = function( self, switch )
handler.lock_read (switch)
if switch == true then