Skip to content

Commit

Permalink
NETWORKING: Fix Portability of SO_LINGER=0 in Tests (elastic#33895)
Browse files Browse the repository at this point in the history
* Setting SO_LINGER for open but not connected non-blocking sockets
throws on OSX
  * Fixed by only applying setting to connected sockets which will save
the same number of FDs as doing it on open sockets anyway
* closes elastic#33879
  • Loading branch information
original-brownbear authored Sep 21, 2018
1 parent 5f7f793 commit 3a5b8a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ public void addCloseListener(ActionListener<Void> listener) {

@Override
public void setSoLinger(int value) throws IOException {
if (isOpen()) {
getRawChannel().setOption(StandardSocketOptions.SO_LINGER, value);
SocketChannel rawChannel = getRawChannel();
if (rawChannel.isConnected()) {
rawChannel.setOption(StandardSocketOptions.SO_LINGER, value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.transport.nio;

import org.apache.lucene.util.Constants;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
Expand Down Expand Up @@ -100,7 +99,6 @@ protected int channelsPerNodeConnection() {
}

public void testConnectException() throws UnknownHostException {
assumeFalse("Broken on Darwin - https://github.com/elastic/elasticsearch/issues/33879", Constants.MAC_OS_X);
try {
serviceA.connectToNode(new DiscoveryNode("C", new TransportAddress(InetAddress.getByName("localhost"), 9876),
emptyMap(), emptySet(),Version.CURRENT));
Expand Down

0 comments on commit 3a5b8a7

Please sign in to comment.