Skip to content

RepUtils.openSocketChannel(xxx) #23

@bingbingtong

Description

@bingbingtong

Does the method RepUtils.openSocketChannel(xxx) have an FD leak under certain scenarios such as heavy packet loss?Could we add exception handling when creating the socket object, and close the channel immediately if creation fails?

` public static SocketChannel openSocketChannel(InetSocketAddress addr,
InetSocketAddress localAddr,
ConnectOptions connectOpts)
throws IOException {

    assert TestHookExecute.doHookIfSet(openSocketChannelHook, connectOpts);

    final SocketChannel channel = SocketChannel.open();
    final boolean blocking = connectOpts.getBlocking();
    channel.configureBlocking(blocking);

    final Socket socket = channel.socket();
    if (connectOpts.getReceiveBufferSize() != 0) {
        socket.setReceiveBufferSize(connectOpts.getReceiveBufferSize());
    }
    socket.setTcpNoDelay(connectOpts.getTcpNoDelay());
    socket.setSoTimeout(connectOpts.getReadTimeout());
    socket.setReuseAddress(connectOpts.getReuseAddr());
    InetSocketAddress bindAddr = connectOpts.getBindAnyLocalAddr() ? null : localAddr;
    socket.bind(bindAddr);

    if (blocking) {
        socket.connect(addr, connectOpts.getOpenTimeout());
    } else {
        channel.connect(addr); // TODO Add logic to close the channel when a channel exception occurs.
    }
    return channel;
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions