diff options
author | Marc Laukien <marc@zeroc.com> | 2002-06-27 22:27:30 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-06-27 22:27:30 +0000 |
commit | 00353fc7b5549d23effdebabcfa2b38b5156f23a (patch) | |
tree | 1971293455ebc72318efc20814f3940a2395e187 /java/src | |
parent | make depend (diff) | |
download | ice-00353fc7b5549d23effdebabcfa2b38b5156f23a.tar.bz2 ice-00353fc7b5549d23effdebabcfa2b38b5156f23a.tar.xz ice-00353fc7b5549d23effdebabcfa2b38b5156f23a.zip |
removed backlog cleanup code
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceInternal/Connection.java | 84 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingConnectionFactory.java | 6 | ||||
-rw-r--r-- | java/src/IceInternal/Protocol.java | 9 | ||||
-rw-r--r-- | java/src/IceInternal/TraceUtil.java | 5 |
4 files changed, 90 insertions, 14 deletions
diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index f3bb30097e1..33ec2527665 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -387,6 +387,26 @@ public final class Connection extends EventHandler byte messageType = stream.readByte(); stream.pos(Protocol.headerSize); + // + // Check whether the connection is validated. + // + if(!_connectionValidated && messageType != Protocol.validateConnectionMsg) + { + // + // Yes, we must set _connectionValidated to true + // here. The connection gets implicitly validated + // by any kind of message. However, it's still a + // protocol error like any other if no explicit + // connection validation message was sent + // first. Also, if I wouldn't set + // _connecitonValidated to true here, then the + // ConnectionValidatedException would be + // translated int a CloseConnectionException. + // + _connectionValidated = true; + throw new Ice.ConnectionNotValidatedException(); + } + switch(messageType) { case Protocol.compressedRequestMsg: @@ -442,6 +462,24 @@ public final class Connection extends EventHandler break; } + case Protocol.validateConnectionMsg: + { + TraceUtil.traceHeader("received validate connection", stream, _logger, _traceLevels); + if(_endpoint.datagram()) + { + if(_warn) + { + _logger.warning("ignoring validate connection message for datagram connection:\n" + + _transceiver.toString()); + } + } + else + { + _connectionValidated = true; + } + break; + } + case Protocol.closeConnectionMsg: { TraceUtil.traceHeader("received close connection", stream, _logger, _traceLevels); @@ -702,24 +740,34 @@ public final class Connection extends EventHandler _warn = _instance.properties().getPropertyAsInt("Ice.ConnectionWarnings") > 0 ? true : false; _registeredWithPool = false; - if(_adapter != null) + if(_endpoint.datagram()) { // - // Incoming connections are always implicitly validated. + // Datagram connections are always implicitly validated. // _connectionValidated = true; } else { - // - // Outoging datagram connections are always validated - // implicitly. Outgoing non-datagram connections must receive a - // message from the server for connection validation. - // - //_connectionValidated = _endpoint.datagram(); - _connectionValidated = true; // TODO: Not finished yet. + if(_adapter != null) + { + // + // Incoming connections play the active role with + // respect to connection validation. + // + _connectionValidated = true; + validateConnection(); + } + else + { + // + // Outgoing connections are passive with respect to + // validation, i.e., they wait until they get a + // validate connection message from the server. + // + _connectionValidated = false; + } } - } protected void @@ -908,6 +956,17 @@ public final class Connection extends EventHandler } private void + validateConnection() + { + BasicStream os = new BasicStream(_instance); + os.writeByte(Protocol.protocolVersion); + os.writeByte(Protocol.encodingVersion); + os.writeByte(Protocol.validateConnectionMsg); + os.writeInt(Protocol.headerSize); // Message size. + _transceiver.write(os, _endpoint.timeout()); + } + + private void closeConnection() { BasicStream os = new BasicStream(_instance); @@ -916,6 +975,11 @@ public final class Connection extends EventHandler os.writeByte(Protocol.closeConnectionMsg); os.writeInt(Protocol.headerSize); // Message size. _transceiver.write(os, _endpoint.timeout()); + + // + // A close connection is always followed by a connection + // shutdown. + // _transceiver.shutdown(); } diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index f1f27db86c1..83538c6f09a 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -145,6 +145,11 @@ public class IncomingConnectionFactory extends EventHandler } else if(_state == StateClosed) { +// +// With the new connection validation, this code is not needed +// anymore. +// +/* try { // @@ -172,6 +177,7 @@ public class IncomingConnectionFactory extends EventHandler warning(ex); } } +*/ _acceptor.close(); diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java index 1b34b22840c..fa6cc04575d 100644 --- a/java/src/IceInternal/Protocol.java +++ b/java/src/IceInternal/Protocol.java @@ -34,8 +34,9 @@ final class Protocol final static byte requestMsg = 0; final static byte requestBatchMsg = 1; final static byte replyMsg = 2; - final static byte closeConnectionMsg = 3; - final static byte compressedRequestMsg = 4; - final static byte compressedRequestBatchMsg = 5; - final static byte compressedReplyMsg = 6; + final static byte validateConnectionMsg = 3; + final static byte closeConnectionMsg = 4; + final static byte compressedRequestMsg = 5; + final static byte compressedRequestBatchMsg = 6; + final static byte compressedReplyMsg = 7; } diff --git a/java/src/IceInternal/TraceUtil.java b/java/src/IceInternal/TraceUtil.java index 71e94e582bd..d40b2fa2bfa 100644 --- a/java/src/IceInternal/TraceUtil.java +++ b/java/src/IceInternal/TraceUtil.java @@ -236,6 +236,11 @@ final class TraceUtil out.write("(close connection)"); break; } + case Protocol.validateConnectionMsg: + { + out.write("(validate connection)"); + break; + } default: { out.write("(unknown)"); |