summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2008-02-15 15:01:52 +0000
committerpixel <pixel>2008-02-15 15:01:52 +0000
commit2638304a22ec91c45e8b759b71c04ad2a12f3069 (patch)
tree56e19625de981e53da926d3cb4ff445a27139efd /lib
parent7a97aaf58a4f01e560ac84c55576b638f199f6fc (diff)
Trying to lower the number of http clients...
Diffstat (limited to 'lib')
-rw-r--r--lib/tasklib.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/tasklib.lua b/lib/tasklib.lua
index fda990c..fc2ce51 100644
--- a/lib/tasklib.lua
+++ b/lib/tasklib.lua
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: tasklib.lua,v 1.5 2007-10-15 13:46:33 pixel Exp $ */
+/* $Id: tasklib.lua,v 1.6 2008-02-15 15:01:52 pixel Exp $ */
]]--
@@ -27,15 +27,23 @@
-- Create some simple bindings for the LuaTask system to hide the various ugly yields.
--
+local nb_clients = 0
+
function HttpClient(url, headers, vars)
+ if nb_clients >= 5 then
+ return Buffer()
+ end
+ nb_clients = nb_clients + 1
if type(headers) == "nil" then
- headers = {}
+ headers = {}
end
if type(vars) == "nil" then
- vars = {}
+ vars = {}
end
headers["User-Agent"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) Gecko/20061010 Firefox/2.0"
- return coroutine.yield("HttpClient", url, headers, vars)
+ local r = coroutine.yield("HttpClient", url, headers, vars)
+ nb_clients = nb_clients - 1
+ return r
end
function MailClient(smtp, subject, from, headers, tos, ccs, bccs, fakes, body)