diff mbox series

[ovs-dev] raft: Don't use HMAP_FOR_EACH_SAFE when logging commands.

Message ID 20220516111524.27240-1-dceara@redhat.com
State Accepted
Commit 2c24daa099f39a24febf96891694cb000ac62bf8
Headers show
Series [ovs-dev] raft: Don't use HMAP_FOR_EACH_SAFE when logging commands. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Dumitru Ceara May 16, 2022, 11:15 a.m. UTC
There's no need to do that because we're not changing the hmap.
Also, if DEBUG logging is disabled there's no need to iterate at
all.

Fixes: 5a9b53a51ec9 ("ovsdb raft: Fix duplicated transaction execution when leader failover.")
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
---
 ovsdb/raft.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Ilya Maximets May 31, 2022, 10:32 a.m. UTC | #1
On 5/16/22 13:15, Dumitru Ceara wrote:
> There's no need to do that because we're not changing the hmap.
> Also, if DEBUG logging is disabled there's no need to iterate at
> all.
> 
> Fixes: 5a9b53a51ec9 ("ovsdb raft: Fix duplicated transaction execution when leader failover.")
> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
> ---
>  ovsdb/raft.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Thanks!  Applied to master and 2.17.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/ovsdb/raft.c b/ovsdb/raft.c
index 530c5e5a3d82..c0e6687b484e 100644
--- a/ovsdb/raft.c
+++ b/ovsdb/raft.c
@@ -2266,8 +2266,12 @@  raft_command_initiate(struct raft *raft,
 static void
 log_all_commands(struct raft *raft)
 {
+    if (!VLOG_IS_DBG_ENABLED()) {
+        return;
+    }
+
     struct raft_command *cmd;
-    HMAP_FOR_EACH_SAFE (cmd, hmap_node, &raft->commands) {
+    HMAP_FOR_EACH (cmd, hmap_node, &raft->commands) {
         VLOG_DBG("raft command eid: "UUID_FMT, UUID_ARGS(&cmd->eid));
     }
 }