#19083: uhttpd / Luci : New stderr logging reveals errors at refresh of overview
page
---------------------+----------------------------------
  Reporter:  hnyman  |      Owner:
      Type:  defect  |     Status:  new
  Priority:  normal  |  Milestone:  Chaos Calmer (trunk)
 Component:  luci    |    Version:  Trunk
Resolution:          |   Keywords:  uhttpd luci
---------------------+----------------------------------

Comment (by hnyman):

 The reason for the error from line 153 is probably an unnecessary close
 for the png file:
 https://github.com/openwrt/luci/blob/master/applications/luci-app-
 statistics/luasrc/controller/luci_statistics/luci_statistics.lua#L153
 {{{
         -- deliver image
         if vars.img then
                 local l12 = require "luci.ltn12"
                 local png = io.open(graph.opts.imgpath .. "/" ..
 vars.img:gsub("%.+", "."), "r")
                 if png then
                         luci.http.prepare_content("image/png")
                         l12.pump.all(l12.source.file(png),
 luci.http.write)
                         png:close()
 }}}

 I am no lua expert, but I think that the function source.file already
 closes the file after the last block has been read, so an explicit close
 in uci_statistics.lua is probably unnecessary.
 https://github.com/openwrt/luci/blob/master/modules/luci-
 base/luasrc/ltn12.lua#L119
 {{{
 function source.file(handle, io_err)
     if handle then
         return function()
             local chunk = handle:read(BLOCKSIZE)
             if chunk and chunk:len() == 0 then chunk = nil end
             if not chunk then handle:close() end
             return chunk
         end
     else return source.error(io_err or "unable to open file") end
 end
 }}}

--
Ticket URL: <https://dev.openwrt.org/ticket/19083#comment:3>
OpenWrt <http://openwrt.org>
Opensource Wireless Router Technology
_______________________________________________
openwrt-tickets mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-tickets

Reply via email to