Comparison

plugins/mod_admin_telnet.lua @ 10068:73a8192058f9

mod_admin_telnet: Move error handling to thread callback (fixes #1391) Avoids yielding over pcall boundry, fixes xmpp:ping() command on Lua 5.1
author Kim Alvefur <zash@zash.se>
date Fri, 10 May 2019 01:29:26 +0200
parent 10067:598befab492e
child 10083:f30d505e755b
comparison
equal deleted inserted replaced
10067:598befab492e 10068:73a8192058f9
60 self.data.conn:pause(); 60 self.data.conn:pause();
61 end 61 end
62 62
63 function runner_callbacks:error(err) 63 function runner_callbacks:error(err)
64 module:log("error", "Traceback[telnet]: %s", err); 64 module:log("error", "Traceback[telnet]: %s", err);
65
66 self.data.print("Fatal error while running command, it did not complete");
67 self.data.print("Error: "..tostring(err));
65 end 68 end
66 69
67 70
68 function console:new_session(conn) 71 function console:new_session(conn)
69 local w = function(s) conn:write(s:gsub("\n", "\r\n")); end; 72 local w = function(s) conn:write(s:gsub("\n", "\r\n")); end;
131 session.print("Sorry, I couldn't understand that... "..err); 134 session.print("Sorry, I couldn't understand that... "..err);
132 return; 135 return;
133 end 136 end
134 end 137 end
135 138
136 local ranok, taskok, message = pcall(chunk); 139 local taskok, message = chunk();
137
138 if not ranok then
139 session.print("Fatal error while running command, it did not complete");
140 session.print("Error: "..taskok);
141 return;
142 end
143 140
144 if not message then 141 if not message then
145 session.print("Result: "..tostring(taskok)); 142 session.print("Result: "..tostring(taskok));
146 return; 143 return;
147 elseif (not taskok) and message then 144 elseif (not taskok) and message then