From 5f45af132121b05ca0f41ea9148276a57e971170 Mon Sep 17 00:00:00 2001 From: Jiangtao Hu Date: Tue, 2 Jan 2018 18:52:51 -0800 Subject: [PATCH] dreamview: add max update size check. --- modules/dreamview/backend/common/dreamview_gflags.cc | 4 ++++ modules/dreamview/backend/common/dreamview_gflags.h | 2 ++ .../backend/simulation_world/simulation_world_updater.cc | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/modules/dreamview/backend/common/dreamview_gflags.cc b/modules/dreamview/backend/common/dreamview_gflags.cc index 7c98417725..eecffd12fd 100644 --- a/modules/dreamview/backend/common/dreamview_gflags.cc +++ b/modules/dreamview/backend/common/dreamview_gflags.cc @@ -62,3 +62,7 @@ DEFINE_double(sim_map_radius, 300.0, "elements around the car."); DEFINE_int32(dreamview_worker_num, 3, "number of dreamview thread workers"); +DEFINE_bool(enable_update_size_check, true, + "True to check if the update byte number is less than threshold"); +DEFINE_uint32(max_update_size, 1000000, + "number of max update bytes allowed to push to dreamview FE"); diff --git a/modules/dreamview/backend/common/dreamview_gflags.h b/modules/dreamview/backend/common/dreamview_gflags.h index 70b4f17511..e866ec66ed 100644 --- a/modules/dreamview/backend/common/dreamview_gflags.h +++ b/modules/dreamview/backend/common/dreamview_gflags.h @@ -42,5 +42,7 @@ DECLARE_string(ssl_certificate); DECLARE_double(sim_map_radius); DECLARE_int32(dreamview_worker_num); +DECLARE_bool(enable_update_size_check); +DECLARE_uint32(max_update_size); #endif // MODULES_DREAMVIEW_BACKEND_COMMON_DREAMVIEW_GFLAGS_H_ diff --git a/modules/dreamview/backend/simulation_world/simulation_world_updater.cc b/modules/dreamview/backend/simulation_world/simulation_world_updater.cc index aaa085fe75..7a14c43a75 100644 --- a/modules/dreamview/backend/simulation_world/simulation_world_updater.cc +++ b/modules/dreamview/backend/simulation_world/simulation_world_updater.cc @@ -119,6 +119,11 @@ SimulationWorldUpdater::SimulationWorldUpdater(WebSocketHandler *websocket, to_send = requestPlanning ? simulation_world_with_planning_json_ : simulation_world_json_; } + if (FLAGS_enable_update_size_check && !requestPlanning && + to_send.size() > FLAGS_max_update_size) { + AWARN << "update size is too big:" << to_send.size(); + return; + } websocket_->SendData(conn, to_send, true); }); -- GitLab