From f598f10d720f8f5f9ec6158aeb41343ea179d4fe Mon Sep 17 00:00:00 2001 From: bel Date: Sun, 27 Oct 2013 01:26:51 +0200 Subject: [PATCH] WebSocket test could use busy_timeout of DB instead of busy loop --- test/websocket.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/websocket.lua b/test/websocket.lua index e0885550..c2ca6202 100644 --- a/test/websocket.lua +++ b/test/websocket.lua @@ -2,6 +2,7 @@ local db = sqlite3.open('requests.db') if db then + db:busy_timeout(200); -- Create a table if it is not created already db:exec([[ CREATE TABLE IF NOT EXISTS requests ( @@ -14,14 +15,16 @@ if db then ]]) end + + local function logDB(method) -- Add entry about this request local r; - repeat + --repeat r = db:exec([[INSERT INTO requests VALUES(NULL, datetime("now"), "]] .. method .. [[", "]] .. mg.request_info.uri .. [[", "]] .. mg.request_info.remote_port .. [[");]]); - until r~=5; + --until r~=5; - --[[ + ---[[ -- alternative logging (to a file) local f = io.open("R:\\log.txt", "a"); f:write(os.date() .. " - " .. method .. " - " .. mg.request_info.uri .. " - " .. mg.request_info.remote_port .. " <" .. r .. ">\n")