main.lua: Log connection failures and fire an event

Mon, 04 Jan 2016 11:04:23 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 04 Jan 2016 11:04:23 +0000
changeset 3
8d3d5d8afbad
parent 2
13a1d5e43a2b
child 4
ae185012e7ba

main.lua: Log connection failures and fire an event

main.lua file | annotate | diff | comparison | revisions
--- a/main.lua	Mon Jan 04 11:03:31 2016 +0000
+++ b/main.lua	Mon Jan 04 11:04:23 2016 +0000
@@ -37,6 +37,10 @@
 		assert(#img == img_size, "incorrect image size: actual:"..#img.." vs expected: "..img_size.." data: "..#data)
 		response.body = data:sub(end_idx+3);
 		events.fire_event("image-changed", { image = img });
+		if not response.partial then
+			log("warn", "connection to upstream lost");
+			events.fire_event("connection-lost");
+		end
 	end);
 end);
 

mercurial