acelyc111 commented on code in PR #2148:
URL: 
https://github.com/apache/incubator-pegasus/pull/2148#discussion_r1853371413


##########
src/meta/server_state.h:
##########
@@ -140,19 +140,26 @@ class server_state
 
     void lock_read(zauto_read_lock &other);
     void lock_write(zauto_write_lock &other);
-    const meta_view get_meta_view() { return {&_all_apps, &_nodes}; }
+
+    meta_view get_meta_view() { return {&_all_apps, &_nodes}; }
+
     std::shared_ptr<app_state> get_app(const std::string &name) const
     {
-        auto iter = _exist_apps.find(name);
-        if (iter == _exist_apps.end())
-            return nullptr;
+        const auto &iter = _exist_apps.find(name);

Review Comment:
   It would be simpler if using find* in map-utils.h



##########
src/meta/server_state.cpp:
##########
@@ -3020,31 +3024,87 @@ void server_state::set_app_envs(const app_env_rpc 
&env_rpc)
     app_info ainfo;
     std::string app_path;
     {
+        FAIL_POINT_INJECT_NOT_RETURN_F("set_app_envs_failed", [app_name, 
this](std::string_view s) {
+            zauto_write_lock l(_lock);
+
+            if (s == "not_found") {
+                CHECK_EQ(_exist_apps.erase(app_name), 1);
+                return;
+            }
+
+            if (s == "dropping") {
+                const auto &iter = _exist_apps.find(app_name);
+                CHECK_TRUE(iter != _exist_apps.end());

Review Comment:
   Use `gutil::FindOrDie()` would simplify the code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to