From a265491fcfe35570510bf7e28b56cdaed9fdab65 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Thu, 24 Oct 2013 12:33:00 +0200 Subject: [PATCH] Disable tracing in parts of hash and eio module Signed-off-by: Tobias Ulmer --- generic/eio.lua | 9 +++++---- generic/hash.lua | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/generic/eio.lua b/generic/eio.lua index 88f4336..aba9017 100644 --- a/generic/eio.lua +++ b/generic/eio.lua @@ -33,6 +33,7 @@ local e2lib = require("e2lib") local err = require("err") local leio = require("leio") local strict = require("strict") +local trace = require("trace") --- Numeric constant for stdin. eio.STDIN = 0; @@ -205,23 +206,23 @@ end function eio.readline(file) local rc, re, line, char - --rc, re = is_eio_object(file) - --if not rc then - -- return false, rc - --end + trace.disable() -- don't spam the logs with fgetc calls. line = "" while true do char, re = eio.fgetc(file) if not char then + trace.enable() return false, re elseif char == "\0" then -- fgets cannot handle embedded zeros, causing mayhem in C. -- We could do this in Lua, but lets signal an error till -- we have a use case. + trace.enable() return false, err.new("got NUL character while reading line") elseif char == "\n" or char == "" then line = line..char -- retain newline just like fgets does. + trace.enable() return line end diff --git a/generic/hash.lua b/generic/hash.lua index 530b2fb..c384572 100644 --- a/generic/hash.lua +++ b/generic/hash.lua @@ -32,6 +32,7 @@ local hash = {} local err = require("err") local strict = require("strict") +local trace = require("trace") require("sha1") --- create a hash context @@ -90,6 +91,8 @@ function hash.hash_file(hc, path) return nil, err.new("could not open file '%s'", path) end + trace.disable() + local buf = "" while true do buf = fd:read(64*1024) @@ -100,6 +103,8 @@ function hash.hash_file(hc, path) hash.hash_append(hc, buf) end + trace.enable() + fd:close() return true -- 2.39.5