only: minor refactoring
This commit is contained in:
parent
27b48c72c2
commit
94181dd2f3
|
@ -263,7 +263,7 @@ public class BinaryProtocol {
|
||||||
tr.start();
|
tr.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dropPending() {
|
private static void dropPending(IoStream stream) {
|
||||||
synchronized (stream.getIoLock()) {
|
synchronized (stream.getIoLock()) {
|
||||||
if (stream.isClosed())
|
if (stream.isClosed())
|
||||||
return;
|
return;
|
||||||
|
@ -468,17 +468,17 @@ public class BinaryProtocol {
|
||||||
* @return null in case of IO issues
|
* @return null in case of IO issues
|
||||||
*/
|
*/
|
||||||
public byte[] executeCommand(char opcode, byte[] packet, String msg) {
|
public byte[] executeCommand(char opcode, byte[] packet, String msg) {
|
||||||
|
linkManager.assertCommunicationThread();
|
||||||
if (stream.isClosed())
|
if (stream.isClosed())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
byte[] fullRequest = getFullRequest((byte) opcode, packet);
|
byte[] fullRequest = getFullRequest((byte) opcode, packet);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
linkManager.assertCommunicationThread();
|
dropPending(stream);
|
||||||
dropPending();
|
|
||||||
if (Bug3923.obscene)
|
if (Bug3923.obscene)
|
||||||
log.info("Sending opcode " + opcode + " payload " + packet.length);
|
log.info("Sending opcode " + opcode + " payload " + packet.length);
|
||||||
sendPacket(fullRequest);
|
stream.sendPacket(fullRequest);
|
||||||
return receivePacket(msg);
|
return receivePacket(msg);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(msg + ": executeCommand failed: " + e);
|
log.error(msg + ": executeCommand failed: " + e);
|
||||||
|
@ -559,10 +559,6 @@ public class BinaryProtocol {
|
||||||
return state.getControllerConfiguration();
|
return state.getControllerConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPacket(byte[] command) throws IOException {
|
|
||||||
stream.sendPacket(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method blocks until a confirmation is received or {@link Timeouts#BINARY_IO_TIMEOUT} is reached
|
* This method blocks until a confirmation is received or {@link Timeouts#BINARY_IO_TIMEOUT} is reached
|
||||||
*
|
*
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class BinaryProtocolLogger {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// fragile or just scary: here we install a JVM level callback for gradual file footer
|
||||||
Runtime.getRuntime().addShutdownHook(hook);
|
Runtime.getRuntime().addShutdownHook(hook);
|
||||||
needCompositeLogger = linkManager.getCompositeLogicEnabled();
|
needCompositeLogger = linkManager.getCompositeLogicEnabled();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue