1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Merge pull request #15297 from poke1024/runner-limit-errs

Limit number of errors and messages sent by runner
This commit is contained in:
Rémi Verschelde
2018-01-07 12:38:08 +01:00
committed by GitHub
3 changed files with 44 additions and 5 deletions

View File

@@ -355,6 +355,13 @@ void ScriptDebuggerRemote::_get_output() {
locking = false; locking = false;
} }
if (n_messages_dropped > 0) {
Message msg;
msg.message = "Too many messages! " + String::num_int64(n_messages_dropped) + " messages were dropped.";
messages.push_back(msg);
n_messages_dropped = 0;
}
while (messages.size()) { while (messages.size()) {
locking = true; locking = true;
packet_peer_stream->put_var("message:" + messages.front()->get().message); packet_peer_stream->put_var("message:" + messages.front()->get().message);
@@ -366,6 +373,20 @@ void ScriptDebuggerRemote::_get_output() {
locking = false; locking = false;
} }
if (n_errors_dropped > 0) {
OutputError oe;
oe.error = "TOO_MANY_ERRORS";
oe.error_descr = "Too many errors! " + String::num_int64(n_errors_dropped) + " errors were dropped.";
oe.warning = false;
uint64_t time = OS::get_singleton()->get_ticks_msec();
oe.hr = time / 3600000;
oe.min = (time / 60000) % 60;
oe.sec = (time / 1000) % 60;
oe.msec = time % 1000;
errors.push_back(oe);
n_errors_dropped = 0;
}
while (errors.size()) { while (errors.size()) {
locking = true; locking = true;
packet_peer_stream->put_var("error"); packet_peer_stream->put_var("error");
@@ -453,8 +474,12 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char
if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) { if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) {
if (sdr->errors.size() >= sdr->max_errors_per_frame) {
sdr->n_errors_dropped++;
} else {
sdr->errors.push_back(oe); sdr->errors.push_back(oe);
} }
}
sdr->mutex->unlock(); sdr->mutex->unlock();
} }
@@ -891,11 +916,15 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_
mutex->lock(); mutex->lock();
if (!locking && tcp_client->is_connected_to_host()) { if (!locking && tcp_client->is_connected_to_host()) {
if (messages.size() >= max_messages_per_frame) {
n_messages_dropped++;
} else {
Message msg; Message msg;
msg.message = p_message; msg.message = p_message;
msg.data = p_args; msg.data = p_args;
messages.push_back(msg); messages.push_back(msg);
} }
}
mutex->unlock(); mutex->unlock();
} }
@@ -1011,7 +1040,11 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() :
requested_quit(false), requested_quit(false),
mutex(Mutex::create()), mutex(Mutex::create()),
max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")), max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")),
max_messages_per_frame(GLOBAL_GET("network/limits/debugger_stdout/max_messages_per_frame")),
max_errors_per_frame(GLOBAL_GET("network/limits/debugger_stdout/max_errors_per_frame")),
char_count(0), char_count(0),
n_messages_dropped(0),
n_errors_dropped(0),
last_msec(0), last_msec(0),
msec_count(0), msec_count(0),
locking(false), locking(false),

View File

@@ -87,7 +87,11 @@ class ScriptDebuggerRemote : public ScriptDebugger {
List<String> output_strings; List<String> output_strings;
List<Message> messages; List<Message> messages;
int max_messages_per_frame;
int n_messages_dropped;
List<OutputError> errors; List<OutputError> errors;
int max_errors_per_frame;
int n_errors_dropped;
int max_cps; int max_cps;
int char_count; int char_count;

View File

@@ -665,6 +665,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60); GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60);
GLOBAL_DEF("network/limits/debugger_stdout/max_chars_per_second", 2048); GLOBAL_DEF("network/limits/debugger_stdout/max_chars_per_second", 2048);
GLOBAL_DEF("network/limits/debugger_stdout/max_messages_per_frame", 10);
GLOBAL_DEF("network/limits/debugger_stdout/max_errors_per_frame", 10);
if (debug_mode == "remote") { if (debug_mode == "remote") {