diff options
| author | Christian Hopps <chopps@labn.net> | 2023-06-16 07:19:53 -0400 |
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2023-06-18 14:02:47 -0400 |
| commit | babbdd43d5319dd370672f794a44f33bdcdc36e5 (patch) | |
| tree | a2300f5066d25d4f276b31516960b7b6687b9a41 /lib/mgmt_msg.c | |
| parent | 2b21ec2c4983a3219881c3dd16b61ae9560e9b26 (diff) | |
lib: mgmtd: re-purpose is_short_circuit and fix depth variable inc/dec
`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>
Diffstat (limited to 'lib/mgmt_msg.c')
| -rw-r--r-- | lib/mgmt_msg.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/mgmt_msg.c b/lib/mgmt_msg.c index ba69c20aba..ee5c1008bd 100644 --- a/lib/mgmt_msg.c +++ b/lib/mgmt_msg.c @@ -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; |
