ronantakizawa/codereview-bench huggingface dataset:
Repository: v2fly/v2ray-core
File: transport/internet/sockopt_darwin.go (Go)

Code before:
package internet

import (
	"golang.org/x/sys/unix"
)

const (
	// TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections.
	TCP_FASTOPEN_SERVER = 0x01 // nolint: revive,stylecheck
	// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
	TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck
	// syscall.TCP_KEEPINTVL is missing on some darwin architectures.
	sysTCP_KEEPINTVL = 0x101 // nolint: revive,stylecheck
)

func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
	if isTCPSocket(network) {
		switch config.Tfo {
		case SocketConfig_Enable:
			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, TCP_FASTOPEN_CLIENT); err != nil {
				return err
			}
		case SocketConfig_Disable:
			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, 0); err != nil {
				return err
			}
		}

		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
			if config.TcpKeepAliveIdle > 0 {
				if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil {
					return newError("failed to set TCP_KEEPINTVL", err)
				}
			}
			if config.TcpKeepAliveInterval > 0 {
				if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, sysTCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil {
					return newError("failed to set TCP_KEEPIDLE", err)
				}

Review comment (suggestion):
Which darwin architectures are missing `TCP_KEEPINTVL`? We are using `x/sys/unix` here, not `syscall`, please double check.

Code after:
package internet

import (
	"golang.org/x/sys/unix"
)

const (
	// TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections.
	TCP_FASTOPEN_SERVER = 0x01 // nolint: revive,stylecheck
	// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
	TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck
)

func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
	if isTCPSocket(network) {
		switch config.Tfo {
		case SocketConfig_Enable:
			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, TCP_FASTOPEN_CLIENT); err != nil {
				return err
			}
		case SocketConfig_Disable:
			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, 0); err != nil {
				return err
			}
		}

		if config.TcpKeepAliveIdle > 0 {
			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil {
				return newError("failed to set TCP_KEEPINTVL", err)
			}
		}
		if config.TcpKeepAliveInterval > 0 {
			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil {
				return newError("failed to set TCP_KEEPIDLE", err)
			}
		}

		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
Repository: v2fly/v2ray-core
File: transport/internet/quic/dialer.go (Go)

Code before:
}

func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsConfig *tls.Config, sockopt *internet.SocketConfig) (internet.Connection, error) {
	s.access.Lock()
	defer s.access.Unlock()

	if s.sessions == nil {
		s.sessions = make(map[net.Destination][]*sessionContext)
	}

	dest := net.DestinationFromAddr(destAddr)

	var sessions []*sessionContext
	if s, found := s.sessions[dest]; found {
		sessions = s
	}

	if true {
		conn := openStream(sessions, destAddr)
		if conn != nil {
			return conn, nil
		}
	}

	sessions = removeInactiveSessions(sessions)
	newError("dialing quic to ", dest).WriteToLog()
	rawConn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{
		IP:   []byte{0, 0, 0, 0},
		Port: 0,
	}, sockopt)
	if err != nil {
		return nil, err
	}

	quicConfig := &quic.Config{
		ConnectionIDLength:   12,
		HandshakeIdleTimeout: time.Second * 8,
		MaxIdleTimeout:       time.Second * 30,
		KeepAlive:            true,
	}

	conn, err := wrapSysConn(rawConn.(*net.UDPConn), config)
	if err != nil {
		rawConn.Close()
		return nil, err
	}

	session, err := quic.DialContext(context.Background(), conn, destAddr, "", tlsConfig.GetTLSConfig(tls.WithDestination(dest)), quicConfig)
	if err != nil {
		conn.Close()
		return nil, err

Review comment (suggestion):
```suggestion
	newError("dialing QUIC to ", dest).WriteToLog()
```

Code after:
}

func (s *clientConnections) openConnection(destAddr net.Addr, config *Config, tlsConfig *tls.Config, sockopt *internet.SocketConfig) (internet.Connection, error) {
	s.access.Lock()
	defer s.access.Unlock()

	if s.conns == nil {
		s.conns = make(map[net.Destination][]*connectionContext)
	}

	dest := net.DestinationFromAddr(destAddr)

	var conns []*connectionContext
	if s, found := s.conns[dest]; found {
		conns = s
	}

	{
		conn := openStream(conns, destAddr)
		if conn != nil {
			return conn, nil
		}
	}

	conns = removeInactiveConnections(conns)
  
  newError("dialing QUIC to ", dest).WriteToLog()

	rawConn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{
		IP:   []byte{0, 0, 0, 0},
		Port: 0,
	}, sockopt)
	if err != nil {
		return nil, err
	}

	quicConfig := &quic.Config{
		ConnectionIDLength:   12,
		HandshakeIdleTimeout: time.Second * 8,
		MaxIdleTimeout:       time.Second * 30,
		KeepAlive:            true,
	}

	sysConn, err := wrapSysConn(rawConn.(*net.UDPConn), config)
	if err != nil {
		rawConn.Close()
		return nil, err
	}

	conn, err := quic.DialContext(context.Background(), sysConn, destAddr, "", tlsConfig.GetTLSConfig(tls.WithDestination(dest)), quicConfig)
	if err != nil {
Repository: v2fly/v2ray-core
File: transport/internet/udp/hub_freebsd.go (Go)

Code before:
// RetrieveOriginalDest from stored laddr, caddr
func RetrieveOriginalDest(oob []byte) net.Destination {
	dec := gob.NewDecoder(bytes.NewBuffer(oob))
	var la, ra net.UDPAddr
	dec.Decode(&la)
	dec.Decode(&ra)
	ip, port, err := internet.OriginalDst(&la, &ra)
	if err != nil {
		return net.Destination{}
	}
	return net.UDPDestination(net.IPAddress(ip), net.Port(port))
}

// ReadUDPMsg stores laddr, caddr for later use
func ReadUDPMsg(conn *net.UDPConn, payload []byte, oob []byte) (int, int, int, *net.UDPAddr, error) {
	nBytes, addr, err := conn.ReadFromUDP(payload)
	var buf bytes.Buffer
	enc := gob.NewEncoder(&buf)
	udpAddr, ok := conn.LocalAddr().(*net.UDPAddr)
	if !ok {
		return 0, 0, 0, nil, errors.New("invalid local address")
	}
	if addr == nil {
		return 0, 0, 0, nil, errors.New("invalid remote address")
	}
	enc.Encode(udpAddr)
	enc.Encode(addr)
	var reader io.Reader = &buf
	noob, _ := reader.Read(oob)
	return nBytes, noob, 0, addr, err
}


Review comment (suggestion):
```suggestion
	if err != nil {
		return nBytes, 0, 0, addr, err
	}
	localAddr, ok := conn.LocalAddr().(*net.UDPAddr)
	if !ok {
		return 0, 0, 0, nil, errors.New("invalid local address")
	}
	enc.Encode(localAddr)
```

Code after:
// RetrieveOriginalDest from stored laddr, caddr
func RetrieveOriginalDest(oob []byte) net.Destination {
	dec := gob.NewDecoder(bytes.NewBuffer(oob))
	var la, ra net.UDPAddr
	dec.Decode(&la)
	dec.Decode(&ra)
	ip, port, err := internet.OriginalDst(&la, &ra)
	if err != nil {
		return net.Destination{}
	}
	return net.UDPDestination(net.IPAddress(ip), net.Port(port))
}

// ReadUDPMsg stores laddr, caddr for later use
func ReadUDPMsg(conn *net.UDPConn, payload []byte, oob []byte) (int, int, int, *net.UDPAddr, error) {
	nBytes, addr, err := conn.ReadFromUDP(payload)
	if err != nil {
		return nBytes, 0, 0, addr, err
	}

	var buf bytes.Buffer
	enc := gob.NewEncoder(&buf)
	localAddr, ok := conn.LocalAddr().(*net.UDPAddr)
	if !ok {
		return 0, 0, 0, nil, errors.New("invalid local address")
	}
	if addr == nil {
		return 0, 0, 0, nil, errors.New("invalid remote address")
	}
	enc.Encode(localAddr)
	enc.Encode(addr)

	var reader io.Reader = &buf
	noob, _ := reader.Read(oob)

	return nBytes, noob, 0, addr, nil
}
Repository: v2fly/v2ray-core
File: infra/conf/json/reader.go (Go)

Code before:
			p = append(p, x)
			v.state = StateDoubleQuote
		case StateSingleQuote:
			switch x {
			case '\'':
				v.state = StateContent
				p = append(p, x)
			case '\\':
				v.state = StateSingleQuoteEscape
				p = append(p, x)
			default:
				p = append(p, x)
			}
		case StateSingleQuoteEscape:
			p = append(p, x)
			v.state = StateSingleQuote
		case StateComment:
			if x == '\n' {
				v.state = StateContent
				p = append(p, x)
			}
		case StateSlash:
			switch x {
			case '/':
				v.state = StateComment
				p = p[:len(p)-1]
			case '*':
				v.state = StateMultilineComment
				p = p[:len(p)-1]
			default:
				p = append(p, x)
			}
		case StateMultilineComment:
			switch x {
			case '*':
				v.state = StateMultilineCommentStar
			case '\n':
				p = append(p, x)
			}
		case StateMultilineCommentStar:
			switch x {
			case '/':
				v.state = StateContent
			case '*':
				// Stay
			case '\n':
				p = append(p, x)
			default:
				v.state = StateMultilineComment
			}
		default:

Review comment (suggestion):
Hmm, this is still not correct, it can not rollback the last `'/'` if `len(p) == 0` (i.e. a new Read() call).

I guess we should error it out with `io.ErrShortBuffer` if `b` is not long enough, and handles this error by feeding a new buffer at [ReadFrom()](https://github.com/v2fly/v2ray-core/blob/5028310b1ef622c16efd04dac01bd687f179f0a8/common/buf/multi_buffer.go#L79-L96).

Code after:
			case '"':
				v.state = StateContent
				p = append(p, x)
			case '\\':
				v.state = StateDoubleQuoteEscape
				p = append(p, x)
			default:
				p = append(p, x)
			}
		case StateDoubleQuoteEscape:
			p = append(p, x)
			v.state = StateDoubleQuote
		case StateSingleQuote:
			switch x {
			case '\'':
				v.state = StateContent
				p = append(p, x)
			case '\\':
				v.state = StateSingleQuoteEscape
				p = append(p, x)
			default:
				p = append(p, x)
			}
		case StateSingleQuoteEscape:
			p = append(p, x)
			v.state = StateSingleQuote
		case StateComment:
			if x == '\n' {
				v.state = StateContent
				p = append(p, x)
			}
		case StateSlash:
			switch x {
			case '/':
				v.state = StateComment
			case '*':
				v.state = StateMultilineComment
			default:
				v.state = StateContent
				v.pending = append(v.pending, x)
				p = append(p, '/')
			}
		case StateMultilineComment:
			switch x {
			case '*':
				v.state = StateMultilineCommentStar
			case '\n':
				p = append(p, x)
			}
		case StateMultilineCommentStar:
			switch x {
Repository: v2fly/v2ray-core
File: proxy/trojan/protocol.go (Go)

Code before:
	buffer := buf.NewWithSize(addrPortBuf.Len() + 2 + 2 + int32(length))
	defer buffer.Release()

	if _, err := buffer.Write(addrPortBuf.Bytes()); err != nil {
		return 0, err
	}
	addrPortBuf.Release()
	if _, err := buffer.Write(lengthBuf[:]); err != nil {
		return 0, err
	}
	if _, err := buffer.Write(crlf); err != nil {
		return 0, err
	}
	if _, err := buffer.Write(payload); err != nil {
		return 0, err
	}
	_, err := w.Write(buffer.Bytes())
	if err != nil {
		return 0, err
	}

	return length, nil
}

// ConnReader is TCP Connection Reader Wrapper for trojan protocol
type ConnReader struct {
	io.Reader
	Target       net.Destination
	headerParsed bool
}

// ParseHeader parses the trojan protocol header
func (c *ConnReader) ParseHeader() error {
	var crlf [2]byte
	var command [1]byte
	var hash [56]byte
	if _, err := io.ReadFull(c.Reader, hash[:]); err != nil {
		return newError("failed to read user hash").Base(err)
	}

	if _, err := io.ReadFull(c.Reader, crlf[:]); err != nil {
		return newError("failed to read crlf").Base(err)
	}

	if _, err := io.ReadFull(c.Reader, command[:]); err != nil {
		return newError("failed to read command").Base(err)
	}

	network := net.Network_TCP
	if command[0] == commandUDP {
		network = net.Network_UDP

Review comment (performance):
```
	if _, err := buffer.Write(addrPortBuf.Bytes()); err != nil {
		return 0, err
	}
	addrPortBuf.Release()
```
If above branch returns, `addrPortBuf` is not released, may cause memory leak? 

Code after:
	var addrPortLen int32
	switch dest.Address.Family() {
	case net.AddressFamilyDomain:
		if protocol.IsDomainTooLong(dest.Address.Domain()) {
			return 0, newError("Super long domain is not supported: ", dest.Address.Domain())
		}
		addrPortLen = 1 + 1 + int32(len(dest.Address.Domain())) + 2
	case net.AddressFamilyIPv4:
		addrPortLen = 1 + 4 + 2
	case net.AddressFamilyIPv6:
		addrPortLen = 1 + 16 + 2
	default:
		panic("Unknown address type.")
	}

	length := len(payload)
	lengthBuf := [2]byte{}
	binary.BigEndian.PutUint16(lengthBuf[:], uint16(length))

	buffer := buf.NewWithSize(addrPortLen + 2 + 2 + int32(length))
	defer buffer.Release()

	if err := addrParser.WriteAddressPort(buffer, dest.Address, dest.Port); err != nil {
		return 0, err
	}
	if _, err := buffer.Write(lengthBuf[:]); err != nil {
		return 0, err
	}
	if _, err := buffer.Write(crlf); err != nil {
		return 0, err
	}
	if _, err := buffer.Write(payload); err != nil {
		return 0, err
	}
	_, err := w.Write(buffer.Bytes())
	if err != nil {
		return 0, err
	}

	return length, nil
}

// ConnReader is TCP Connection Reader Wrapper for trojan protocol
type ConnReader struct {
	io.Reader
	Target       net.Destination
	headerParsed bool
}

// ParseHeader parses the trojan protocol header
func (c *ConnReader) ParseHeader() error {
Repository: v2fly/v2ray-core
File: transport/internet/socket_activation_other.go (Go)

Code before:
//go:build !unix
// +build !unix

package internet

import "github.com/v2fly/v2ray-core/v5/common/net"

func activate_socket(address string) (net.Listener, error) {
	return nil, nil
}


Review comment (bug):
This code does not follow general coding style of Go language programs: if a action is failed, not failed to achieve its intended purpose as shown in function name, it must return an error.

Code after:
//go:build !unix
// +build !unix

package internet

import (
	"fmt"
	"github.com/v2fly/v2ray-core/v5/common/net"
)

func activateSocket(address string, f func(network, address string, fd uintptr)) (net.Listener, error) {
	return nil, fmt.Errorf("socket activation is not supported on this platform")
}
Repository: v2fly/v2ray-core
File: transport/internet/socket_activation_unix.go (Go)

Code before:
//go:build unix
// +build unix

package internet

import (
	"os"
	"strconv"
	"strings"
	"syscall"

	"github.com/v2fly/v2ray-core/v5/common/net"
)

func activate_socket(address string) (net.Listener, error) {
	if strings.HasPrefix(address, "/dev/fd/") {
		fd, err := strconv.Atoi(address[8:])
		if err != nil {
			return nil, err
		}
		_ = syscall.SetNonblock(fd, true)
		return net.FileListener(os.NewFile(uintptr(fd), address))
	} else {
		return nil, nil
	}
}


Review comment (suggestion):
Would you mind moving this address prefix checking logic back to `system_listener.go` ? This would allow an viewer of code to estimate code execution path without following into individual functions's implementation.

Also this would make it possible to return an error on these function if it cannot capture incoming socket fd.


Code after:
//go:build unix
// +build unix

package internet

import (
	"fmt"
	"os"
	"path"
	"strconv"
	"syscall"

	"github.com/v2fly/v2ray-core/v5/common/net"
)

func activateSocket(address string, f func(network, address string, fd uintptr)) (net.Listener, error) {
	fd, err := strconv.Atoi(path.Base(address))
	if err != nil {
		return nil, err
	}

	err = syscall.SetNonblock(fd, true)
	if err != nil {
		return nil, err
	}

	acceptConn, err := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_ACCEPTCONN)
	if err != nil {
		return nil, err
	}
	if acceptConn == 0 {
		return nil, fmt.Errorf("socket '%s' has not been marked to accept connections", address)
	}

	sockType, err := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_TYPE)
	if err != nil {
		return nil, err
	}
	if sockType != syscall.SOCK_STREAM {
		// XXX: currently only stream socks are supported
		return nil, fmt.Errorf("socket '%s' is not a stream socket", address)
Repository: valkey-io/valkey
File: src/cluster_legacy.c (C)

Code before:
        case CLUSTER_ENDPOINT_TYPE_UNKNOWN_ENDPOINT:
            return "";
    }
    return "unknown";
}

int clusterAllowFailoverCmd(client *c) {
    if (!server.cluster_enabled) {
        return 1;
    }
    addReplyError(c,"FAILOVER not allowed in cluster mode. "
                    "Use CLUSTER FAILOVER command instead.");
    return 0;
}

void clusterPromoteSelfToMaster(void) {
    replicationUnsetMaster();
}

void updateAllCachedNodesHealth(void) {
    dictIterator *di =  zmalloc(sizeof(*di));
    dictEntry *de;
    clusterNode *node;
    int overall_health_changed = 0;
    dictInitSafeIterator(di, server.cluster->nodes);
    while((de = dictNext(di)) != NULL) {
        node = dictGetVal(de);
        int present_is_node_healthy = isNodeAvailable(node);
        if (present_is_node_healthy != node->is_node_healthy) {
            overall_health_changed = 1;
            node->is_node_healthy = present_is_node_healthy;
        }
    }

    if (overall_health_changed) clearCachedClusterSlotsResp();
}

/* Replicate migrating and importing slot states to all replicas */
void clusterReplicateOpenSlots(void) {
    if (!server.cluster_enabled) return;

    int argc = 5;
    robj **argv = zmalloc(sizeof(robj*)*argc);

    argv[0] = shared.cluster;
    argv[1] = shared.setslot;

    for (int i = 0; i < 2; i++) {
        clusterNode **nodes_ptr = NULL;
        if (i == 0) {
            nodes_ptr = server.cluster->importing_slots_from;

Review comment (suggestion):
```suggestion
    dictIterator di;
    dictInitSafeIterator(&di, server.cluster->nodes);
    dictEntry *de;
    clusterNode *node;
    int overall_health_changed = 0;
    while((de = dictNext(&di)) != NULL) {
```
This is how you use the stack allocated version.

Code after:
    int argc = 5;
    robj **argv = zmalloc(sizeof(robj*)*argc);

    argv[0] = shared.cluster;
    argv[1] = shared.setslot;

    for (int i = 0; i < 2; i++) {
        clusterNode **nodes_ptr = NULL;
        if (i == 0) {
            nodes_ptr = server.cluster->importing_slots_from;
            argv[3] = shared.importing;
        } else {
            nodes_ptr = server.cluster->migrating_slots_to;
            argv[3] = shared.migrating;
        }

        for (int j = 0; j < CLUSTER_SLOTS; j++) {
            if (nodes_ptr[j] == NULL) continue;

            argv[2] = createStringObjectFromLongLongForValue(j);
            sds name = sdsnewlen(nodes_ptr[j]->name, sizeof(nodes_ptr[j]->name));
            argv[4] = createObject(OBJ_STRING, name);

            replicationFeedSlaves(0, argv, argc);

            decrRefCount(argv[2]);
            decrRefCount(argv[4]);
        }
    }

    zfree(argv);
}
Repository: valkey-io/valkey
File: src/cluster_legacy.c (C)

Code before:
    char *hostname = clusterNodeHostname(n);
    switch (server.cluster_preferred_endpoint_type) {
        case CLUSTER_ENDPOINT_TYPE_IP:
            return clusterNodeIp(n);
        case CLUSTER_ENDPOINT_TYPE_HOSTNAME:
            return (hostname != NULL && hostname[0] != '\0') ? hostname : "?";
        case CLUSTER_ENDPOINT_TYPE_UNKNOWN_ENDPOINT:
            return "";
    }
    return "unknown";
}

int clusterAllowFailoverCmd(client *c) {
    if (!server.cluster_enabled) {
        return 1;
    }
    addReplyError(c,"FAILOVER not allowed in cluster mode. "
                    "Use CLUSTER FAILOVER command instead.");
    return 0;
}

void clusterPromoteSelfToMaster(void) {
    replicationUnsetMaster();
}

void updateAllCachedNodesHealth(void) {
    dictIterator di;
    dictInitSafeIterator(&di, server.cluster->nodes);
    dictEntry *de;
    clusterNode *node;
    int overall_health_changed = 0;
    while((de = dictNext(&di)) != NULL) {
        node = dictGetVal(de);
        int present_is_node_healthy = isNodeAvailable(node);
        if (present_is_node_healthy != node->is_node_healthy) {
            overall_health_changed = 1;
            node->is_node_healthy = present_is_node_healthy;
        }
    }

    if (overall_health_changed) clearCachedClusterSlotsResponse();
}

/* Replicate migrating and importing slot states to all replicas */
void clusterReplicateOpenSlots(void) {
    if (!server.cluster_enabled) return;

    int argc = 5;
    robj **argv = zmalloc(sizeof(robj*)*argc);

    argv[0] = shared.cluster;

Review comment (performance):
I think this function name can be improved to be more clear about the action - it is not just an "update" but `invalidateSlotCommandCacheOnNodeHealthChange` or `invalidateTopologyCacheOnNodeHealthChange` if we anticipate more cache like this can be introduced.

Code after:
}

/* Replicate migrating and importing slot states to all replicas */
void clusterReplicateOpenSlots(void) {
    if (!server.cluster_enabled) return;

    int argc = 5;
    robj **argv = zmalloc(sizeof(robj*)*argc);

    argv[0] = shared.cluster;
    argv[1] = shared.setslot;

    for (int i = 0; i < 2; i++) {
        clusterNode **nodes_ptr = NULL;
        if (i == 0) {
            nodes_ptr = server.cluster->importing_slots_from;
            argv[3] = shared.importing;
        } else {
            nodes_ptr = server.cluster->migrating_slots_to;
            argv[3] = shared.migrating;
        }

        for (int j = 0; j < CLUSTER_SLOTS; j++) {
            if (nodes_ptr[j] == NULL) continue;

            argv[2] = createStringObjectFromLongLongForValue(j);
            sds name = sdsnewlen(nodes_ptr[j]->name, sizeof(nodes_ptr[j]->name));
            argv[4] = createObject(OBJ_STRING, name);

            replicationFeedSlaves(0, argv, argc);

            decrRefCount(argv[2]);
            decrRefCount(argv[4]);
        }
    }

    zfree(argv);
}