Skip to content

Commit 80aa453

Browse files
author
Matthew Sackman
committed
Reduce multiheadedness
2 parents 657c653 + eb42e08 commit 80aa453

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

src/com/rabbitmq/client/impl/AMQConnection.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public class AMQConnection extends ShutdownNotifierComponent implements Connecti
5454
/** Timeout used while waiting for AMQP handshaking to complete (milliseconds) */
5555
public static final int HANDSHAKE_TIMEOUT = 10000;
5656

57-
/** Timeout used while waiting for a connection.close-ok (milliseconds) */
58-
public static final int CONNECTION_CLOSING_TIMEOUT = 10000;
59-
6057
/**
6158
* Retrieve a copy of the default table of client properties that
6259
* will be sent to the server during connection startup. This
@@ -593,11 +590,7 @@ public SocketCloseWait(ShutdownSignalException sse) {
593590

594591
@Override public void run() {
595592
try {
596-
_appContinuation.uninterruptibleGet(CONNECTION_CLOSING_TIMEOUT);
597-
} catch (TimeoutException ise) {
598-
// Broker didn't close socket on time, force socket close
599-
// FIXME: notify about timeout exception?
600-
_frameHandler.close();
593+
_appContinuation.uninterruptibleGet();
601594
} finally {
602595
_running = false;
603596
_channel0.notifyOutstandingRpc(cause);
@@ -695,8 +688,7 @@ public void abort(int closeCode, String closeMessage, int timeout)
695688
/**
696689
* Protected API - Delegates to {@link
697690
* #close(int,String,boolean,Throwable,int,boolean) the
698-
* six-argument close method}, passing
699-
* {@link #CONNECTION_CLOSING_TIMEOUT} for the timeout, and
691+
* six-argument close method}, passing -1 for the timeout, and
700692
* false for the abort flag.
701693
*/
702694
public void close(int closeCode,
@@ -705,8 +697,7 @@ public void close(int closeCode,
705697
Throwable cause)
706698
throws IOException
707699
{
708-
close(closeCode, closeMessage, initiatedByApplication, cause,
709-
CONNECTION_CLOSING_TIMEOUT, false);
700+
close(closeCode, closeMessage, initiatedByApplication, cause, -1, false);
710701
}
711702

712703
/**

src/com/rabbitmq/client/impl/SocketFrameHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class SocketFrameHandler implements FrameHandler {
4141
/** Socket's outputstream - data to the broker - synchronized on */
4242
private final DataOutputStream _outputStream;
4343

44+
/** Time to linger before closing the socket forcefully. */
45+
public static final int SOCKET_CLOSING_TIMEOUT = 1;
46+
4447
/**
4548
* @param socket the socket to use
4649
*/
@@ -138,6 +141,7 @@ public void writeFrame(Frame frame) throws IOException {
138141

139142
public void close() {
140143
try {
144+
_socket.setSoLinger(true, SOCKET_CLOSING_TIMEOUT);
141145
_socket.close();
142146
} catch (IOException ioe) {
143147
// Ignore.

test/src/com/rabbitmq/client/test/CloseInMainLoop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void handleConsumerException(Channel channel,
6666
"Internal error in Consumer " + consumerTag,
6767
false,
6868
exception,
69-
AMQConnection.CONNECTION_CLOSING_TIMEOUT,
69+
-1,
7070
false);
7171
} catch (Throwable e) {
7272
// Man, this clearly isn't our day.

0 commit comments

Comments
 (0)