]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: mgmtd: re-purpose is_short_circuit and fix depth variable inc/dec
authorChristian Hopps <chopps@labn.net>
Fri, 16 Jun 2023 11:19:53 +0000 (07:19 -0400)
committerChristian Hopps <chopps@labn.net>
Sun, 18 Jun 2023 18:02:47 +0000 (14:02 -0400)
`is_short_circuit` now is set to true when a message is being
short-circuit handled.

`short_circuit_depth` was being inc/dec inside conditional macro, move
that out of the macro.

Signed-off-by: Christian Hopps <chopps@labn.net>
lib/mgmt_msg.c
lib/mgmt_msg.h

index ba69c20aba72a78d6b0dedf854cb4147c841837a..ee5c1008bd0c8431c1f1d479ed1e61c2979d8373 100644 (file)
@@ -548,20 +548,26 @@ int msg_conn_send_msg(struct msg_conn *conn, uint8_t version, void *msg,
        if (conn->remote_conn && short_circuit_ok) {
                uint8_t *buf = msg;
                size_t n = mlen;
+               bool old;
 
                if (packf) {
                        buf = XMALLOC(MTYPE_TMP, mlen);
                        n = packf(msg, buf);
                }
 
+               ++conn->short_circuit_depth;
                MGMT_MSG_DBG(dbgtag, "SC send: depth %u msg: %p",
-                            ++conn->short_circuit_depth, msg);
+                            conn->short_circuit_depth, msg);
 
+               old = conn->remote_conn->is_short_circuit;
+               conn->remote_conn->is_short_circuit = true;
                conn->remote_conn->handle_msg(version, buf, n,
                                              conn->remote_conn);
+               conn->remote_conn->is_short_circuit = old;
 
+               --conn->short_circuit_depth;
                MGMT_MSG_DBG(dbgtag, "SC return from depth: %u msg: %p",
-                            conn->short_circuit_depth--, msg);
+                            conn->short_circuit_depth, msg);
 
                if (packf)
                        XFREE(MTYPE_TMP, buf);
@@ -661,12 +667,10 @@ static bool msg_client_connect_short_circuit(struct msg_client *client)
        set_nonblocking(sockets[0]);
        setsockopt_so_sendbuf(sockets[0], client->conn.mstate.max_write_buf);
        setsockopt_so_recvbuf(sockets[0], client->conn.mstate.max_read_buf);
-       client->conn.is_short_circuit = true;
 
        /* server side */
        memset(&su, 0, sizeof(union sockunion));
        server_conn = server->create(sockets[1], &su);
-       server_conn->is_short_circuit = true;
 
        client->conn.remote_conn = server_conn;
        server_conn->remote_conn = &client->conn;
index 9fdcb9ecd35621e02cd3dae3e09e4e36e4f67fa6..dd7ae59f9162fb5de87d76c40292cc9f00af72b3 100644 (file)
@@ -98,8 +98,8 @@ struct msg_conn {
                           struct msg_conn *conn);
        void *user;
        uint short_circuit_depth;
+       bool is_short_circuit;  /* true when the message being handled is SC */
        bool is_client;
-       bool is_short_circuit;
        bool debug;
 };