Repository: valkey-io/valkey
File: src/cluster_legacy.c (C)

Code before:
                /* We should always receive a MEET packet on an inbound link. */
                serverAssert(link != sender->link);
                serverLog(LL_NOTICE, "Freeing outbound link to node %.40s (%s) after receiving a MEET packet "
                                     "from this known node",
                          sender->name, sender->human_nodename);
                freeClusterLink(sender->link);
            }
        }

        /* Anyway reply with a PONG */
        clusterSendPing(link, CLUSTERMSG_TYPE_PONG);
    }

    char ip[NET_IP_STR_LEN];
    int port;
    if (connAddr(link->conn, ip, sizeof(ip), &port, 1) != -1) {
        serverLog(LL_DEBUG, "%s packet received from: %.40s (%s) from client: %s:%d",
                  clusterGetMessageTypeString(type),
                  link->node ? link->node->name : "NULL",
                  link->node ? link->node->human_nodename : "",
                  ip, port);
    } else {
        serverLog(LL_WARNING, "Error resolving the address of packet sender %.40s (%s)",
                  link->node ? link->node->name : "NULL",
                  link->node ? link->node->human_nodename : "");
    }
    /* PING, PONG, MEET: process config information. */
    if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG || type == CLUSTERMSG_TYPE_MEET) {
        if (sender && nodeInMeetState(sender)) {
            /* Once we get a response for MEET from the sender, we can stop sending more MEET. */
            sender->flags &= ~CLUSTER_NODE_MEET;
            serverLog(LL_NOTICE, "Successfully completed handshake with %.40s (%s)", sender->name,
                      sender->human_nodename);
        }
        if (!link->inbound) {
            if (nodeInHandshake(link->node)) {
                /* If we already have this node, try to change the
                 * IP/port of the node with the new one. */
                if (sender) {
                    serverLog(LL_VERBOSE,
                              "Handshake: we already know node %.40s (%s), "
                              "updating the address if needed.",
                              sender->name, sender->human_nodename);
                    if (nodeUpdateAddressIfNeeded(sender, link, hdr)) {
                        clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG | CLUSTER_TODO_UPDATE_STATE);
                    }
                    /* Free this node as we already have it. This will
                     * cause the link to be freed as well. */
                    clusterDelNode(link->node);
                    return 0;
                }

Review comment (suggestion):
Again
```c
if (server.verbosity <= LL_VERBOSE) {
```

Code after:

                /* If this is a MEET packet from an unknown node, we still process
                 * the gossip section here since we have to trust the sender because
                 * of the message type. */
                clusterProcessGossipSection(hdr, link);
            } else if (sender->link && nodeExceedsHandshakeTimeout(sender, now)) {
                /* The MEET packet is from a known node, after the handshake timeout, so the sender
                 * thinks that I do not know it.
                 * Free my outbound link to that node, triggering a reconnect and a PING over the
                 * new link.
                 * Once that node receives our PING, it should recognize the new connection as an
                 * inbound link from me. We should only free the outbound link if the node is known
                 * for more time than the handshake timeout, since during this time, the other side
                 * might still be trying to complete the handshake. */

                /* We should always receive a MEET packet on an inbound link. */
                serverAssert(link != sender->link);
                serverLog(LL_NOTICE, "Freeing outbound link to node %.40s (%s) after receiving a MEET packet "
                                     "from this known node",
                          sender->name, sender->human_nodename);
                freeClusterLink(sender->link);
            }
        }

        /* Anyway reply with a PONG */
        clusterSendPing(link, CLUSTERMSG_TYPE_PONG);
    }

    if (server.verbosity <= LL_DEBUG) {
        char ip[NET_IP_STR_LEN];
        int port;
        if (connAddrPeerName(link->conn, ip, sizeof(ip), &port) != -1) {
            serverLog(LL_DEBUG, "%s packet received from: %.40s (%s) from client: %s:%d",
                      clusterGetMessageTypeString(type),
                      clusterLinkGetNodeName(link), clusterLinkGetHumanNodeName(link),
                      ip, port);
        } else {
            serverLog(LL_DEBUG, "Error resolving the address of packet sender %.40s (%s)",
                      clusterLinkGetNodeName(link), clusterLinkGetHumanNodeName(link));
        }
    }
    /* PING, PONG, MEET: process config information. */
    if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG || type == CLUSTERMSG_TYPE_MEET) {
        if (sender && nodeInMeetState(sender)) {
            /* Once we get a response for MEET from the sender, we can stop sending more MEET. */
            sender->flags &= ~CLUSTER_NODE_MEET;
            serverLog(LL_NOTICE, "Successfully completed handshake with %.40s (%s)", sender->name,
                      sender->human_nodename);
        }
        if (!link->inbound) {
            if (nodeInHandshake(link->node)) {