aboutsummaryrefslogtreecommitdiff
path: root/etc/check-links.lua
diff options
context:
space:
mode:
Diffstat (limited to 'etc/check-links.lua')
-rw-r--r--etc/check-links.lua31
1 files changed, 12 insertions, 19 deletions
diff --git a/etc/check-links.lua b/etc/check-links.lua
index e06cc91..725cd2a 100644
--- a/etc/check-links.lua
+++ b/etc/check-links.lua
@@ -5,33 +5,26 @@
5-- Author: Diego Nehab 5-- Author: Diego Nehab
6-- RCS ID: $$ 6-- RCS ID: $$
7----------------------------------------------------------------------------- 7-----------------------------------------------------------------------------
8local dispatch, url, http, handler 8local url = require("socket.url")
9local dispatch = require("dispatch")
10local http = require("socket.http")
11dispatch.TIMEOUT = 10
9 12
13-- make sure the user knows how to invoke us
10arg = arg or {} 14arg = arg or {}
11if table.getn(arg) < 1 then 15if table.getn(arg) < 1 then
12 print("Usage:\n luasocket check-links.lua [-n] {<url>}") 16 print("Usage:\n luasocket check-links.lua [-n] {<url>}")
13 exit() 17 exit()
14end 18end
15 19
16if arg[1] ~= "-n" then 20-- '-n' means we are running in non-blocking mode
17 -- if using blocking I/O, simulate dispatcher interface 21if arg[1] == "-n" then
18 url = require("socket.url") 22 -- if non-blocking I/O was requested, use real dispatcher interface
19 http = require("socket.http")
20 handler = {
21 start = function(self, f)
22 f()
23 end,
24 tcp = socket.tcp
25 }
26 http.TIMEOUT = 10
27else
28 -- if non-blocking I/O was requested, disable dispatcher
29 table.remove(arg, 1) 23 table.remove(arg, 1)
30 dispatch = require("dispatch") 24 handler = dispatch.newhandler("coroutine")
31 dispatch.TIMEOUT = 10 25else
32 url = require("socket.url") 26 -- if using blocking I/O, use fake dispatcher interface
33 http = require("socket.http") 27 handler = dispatch.newhandler("sequential")
34 handler = dispatch.newhandler()
35end 28end
36 29
37local nthreads = 0 30local nthreads = 0