summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/script_debugger_remote.cpp43
-rw-r--r--core/script_debugger_remote.h4
-rw-r--r--main/main.cpp2
3 files changed, 44 insertions, 5 deletions
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index a0a55ce86e..623dea5465 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -354,6 +354,13 @@ void ScriptDebuggerRemote::_get_output() {
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()) {
locking = true;
packet_peer_stream->put_var("message:" + messages.front()->get().message);
@@ -365,6 +372,20 @@ void ScriptDebuggerRemote::_get_output() {
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()) {
locking = true;
packet_peer_stream->put_var("error");
@@ -452,7 +473,11 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char
if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) {
- sdr->errors.push_back(oe);
+ if (sdr->errors.size() >= sdr->max_errors_per_frame) {
+ sdr->n_errors_dropped++;
+ } else {
+ sdr->errors.push_back(oe);
+ }
}
sdr->mutex->unlock();
@@ -890,10 +915,14 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_
mutex->lock();
if (!locking && tcp_client->is_connected_to_host()) {
- Message msg;
- msg.message = p_message;
- msg.data = p_args;
- messages.push_back(msg);
+ if (messages.size() >= max_messages_per_frame) {
+ n_messages_dropped++;
+ } else {
+ Message msg;
+ msg.message = p_message;
+ msg.data = p_args;
+ messages.push_back(msg);
+ }
}
mutex->unlock();
}
@@ -1010,7 +1039,11 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() :
requested_quit(false),
mutex(Mutex::create()),
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),
+ n_messages_dropped(0),
+ n_errors_dropped(0),
last_msec(0),
msec_count(0),
locking(false),
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index 15afc866e3..5a14ce32a8 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -86,7 +86,11 @@ class ScriptDebuggerRemote : public ScriptDebugger {
List<String> output_strings;
List<Message> messages;
+ int max_messages_per_frame;
+ int n_messages_dropped;
List<OutputError> errors;
+ int max_errors_per_frame;
+ int n_errors_dropped;
int max_cps;
int char_count;
diff --git a/main/main.cpp b/main/main.cpp
index ac68fe1296..86e72d8eb7 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -664,6 +664,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("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") {