diff options
Diffstat (limited to 'etc/check-links.lua')
-rw-r--r-- | etc/check-links.lua | 31 |
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 | ----------------------------------------------------------------------------- |
8 | local dispatch, url, http, handler | 8 | local url = require("socket.url") |
9 | local dispatch = require("dispatch") | ||
10 | local http = require("socket.http") | ||
11 | dispatch.TIMEOUT = 10 | ||
9 | 12 | ||
13 | -- make sure the user knows how to invoke us | ||
10 | arg = arg or {} | 14 | arg = arg or {} |
11 | if table.getn(arg) < 1 then | 15 | if 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() |
14 | end | 18 | end |
15 | 19 | ||
16 | if arg[1] ~= "-n" then | 20 | -- '-n' means we are running in non-blocking mode |
17 | -- if using blocking I/O, simulate dispatcher interface | 21 | if 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 | ||
27 | else | ||
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 | 25 | else |
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() | ||
35 | end | 28 | end |
36 | 29 | ||
37 | local nthreads = 0 | 30 | local nthreads = 0 |