annotate src/org/eclipse/jetty/io/nio/SslConnection.java @ 1071:b4ba8a4d5a16

remove JBuffer.space()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2016 02:13:28 -0700
parents 9d357b9e4bcb
children 00704b28b9f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.io.nio;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 import java.io.IOException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import java.nio.ByteBuffer;
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 974
diff changeset
23 import java.nio.channels.SocketChannel;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import java.util.concurrent.atomic.AtomicBoolean;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import javax.net.ssl.SSLEngine;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 import javax.net.ssl.SSLEngineResult;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 import javax.net.ssl.SSLEngineResult.HandshakeStatus;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 import javax.net.ssl.SSLException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 import javax.net.ssl.SSLSession;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 import org.eclipse.jetty.io.AbstractConnection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import org.eclipse.jetty.io.AsyncEndPoint;
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
33 import org.eclipse.jetty.io.JBuffer;
1046
a8c92b0a08ed add JBuffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1038
diff changeset
34 import org.eclipse.jetty.io.BufferUtil;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import org.eclipse.jetty.io.EndPoint;
1003
Franklin Schmidt <fschmidt@gmail.com>
parents: 1002
diff changeset
36 import org.eclipse.jetty.server.AsyncHttpConnection;
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
37 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
38 import org.slf4j.LoggerFactory;
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
39
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 /* ------------------------------------------------------------ */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 /** SSL Connection.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 * An AysyncConnection that acts as an interceptor between and EndPoint and another
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 * Connection, that implements TLS encryption using an {@link SSLEngine}.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 * The connector uses an {@link AsyncEndPoint} (like {@link SelectChannelEndPoint}) as
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 * it's source/sink of encrypted data. It then provides {@link #getSslEndPoint()} to
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 * expose a source/sink of unencrypted data to another connection (eg HttpConnection).
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 */
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 959
diff changeset
50 public final class SslConnection extends AbstractConnection implements AsyncConnection
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 {
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
52 private final Logger _logger = LoggerFactory.getLogger("org.eclipse.jetty.io.nio.ssl");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
54 private static final JBuffer __ZERO_BUFFER = BufferUtil.EMPTY_BUFFER;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
56 private static final ThreadLocal<SslBuffers> __buffers = new ThreadLocal<SslBuffers>();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
57 private final SSLEngine _engine;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
58 private final SSLSession _session;
1003
Franklin Schmidt <fschmidt@gmail.com>
parents: 1002
diff changeset
59 private AsyncHttpConnection _connection;
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
60 private final SslEndPoint _sslEndPoint;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
61 private int _allocations;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
62 private SslBuffers _buffers;
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
63 private JBuffer _inbound;
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
64 private JBuffer _unwrapBuf;
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
65 private JBuffer _outbound;
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 945
diff changeset
66 private final AsyncEndPoint _aEndp;
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 978
diff changeset
67 private boolean _allowRenegotiate = true;
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 private boolean _handshook;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
69 private boolean _ishut;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
70 private boolean _oshut;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
71 private final AtomicBoolean _progressed = new AtomicBoolean();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
72
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 /* ------------------------------------------------------------ */
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 /* this is a half baked buffer pool
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
75 */
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
76 private static class SslBuffers
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 {
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
78 final JBuffer _in;
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
79 final JBuffer _out;
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
80 final JBuffer _unwrap;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
81
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
82 SslBuffers(int packetSize, int appSize)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
83 {
1046
a8c92b0a08ed add JBuffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1038
diff changeset
84 _in = BufferUtil.newBuffer(packetSize);
1068
9d357b9e4bcb fix BufferUtil.newBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1065
diff changeset
85 _in.limit(0);
1046
a8c92b0a08ed add JBuffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1038
diff changeset
86 _out = BufferUtil.newBuffer(packetSize);
1068
9d357b9e4bcb fix BufferUtil.newBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1065
diff changeset
87 _out.limit(0);
1046
a8c92b0a08ed add JBuffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1038
diff changeset
88 _unwrap = BufferUtil.newBuffer(appSize);
1068
9d357b9e4bcb fix BufferUtil.newBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1065
diff changeset
89 _unwrap.limit(0);
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
90 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
91 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
92
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 945
diff changeset
93 public SslConnection(SSLEngine engine,AsyncEndPoint endp)
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 {
973
4d9fe9cc554d simplify AbstractConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
95 super(endp);
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 978
diff changeset
96 _engine = engine;
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 978
diff changeset
97 _session = _engine.getSession();
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 978
diff changeset
98 _aEndp = endp;
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 945
diff changeset
99 _sslEndPoint = new SslEndPoint();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
101
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
102 /* ------------------------------------------------------------ */
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
103 /**
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
104 * Set if SSL re-negotiation is allowed. CVE-2009-3555 discovered
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
105 * a vulnerability in SSL/TLS with re-negotiation. If your JVM
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 * does not have CVE-2009-3555 fixed, then re-negotiation should
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
107 * not be allowed. CVE-2009-3555 was fixed in Sun java 1.6 with a ban
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
108 * of renegotiates in u19 and with RFC5746 in u22.
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
109 *
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 * @param allowRenegotiate
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
111 * true if re-negotiation is allowed (default false)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
112 */
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
113 public void setAllowRenegotiate(boolean allowRenegotiate)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 _allowRenegotiate = allowRenegotiate;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
116 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
117
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
118 private void allocateBuffers()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
119 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
120 synchronized (this)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
121 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
122 if (_allocations++==0)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
123 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
124 if (_buffers==null)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
126 _buffers=__buffers.get();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
127 if (_buffers==null)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
128 _buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2);
1065
158d1e6ac17f fix JBuffer.compact()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1062
diff changeset
129 _inbound = _buffers._in;
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
130 _outbound = _buffers._out;
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
131 _unwrapBuf=_buffers._unwrap;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
132 __buffers.set(null);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
133 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
134 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
135 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
136 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
137
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
138 private void releaseBuffers()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
139 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
140 synchronized (this)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
141 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 if (--_allocations==0)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
143 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
144 if (_buffers!=null &&
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
145 _inbound.remaining()==0 &&
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
146 _outbound.remaining()==0 &&
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
147 _unwrapBuf.remaining()==0)
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
148 {
1071
b4ba8a4d5a16 remove JBuffer.space()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1068
diff changeset
149 _inbound = null;
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
150 _outbound = null;
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
151 _unwrapBuf=null;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
152 __buffers.set(_buffers);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
153 _buffers=null;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
154 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
155 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
156 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
157 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
158
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 959
diff changeset
159 @Override
965
866f2e801618 handle() returns void
Franklin Schmidt <fschmidt@gmail.com>
parents: 960
diff changeset
160 public void handle() throws IOException
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
161 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
162 try
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
163 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
164 allocateBuffers();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
165
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
166 boolean progress=true;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
167
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
168 while (progress)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 progress=false;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
171
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
172 // If we are handshook let the delegate connection
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
173 if (_engine.getHandshakeStatus()!=HandshakeStatus.NOT_HANDSHAKING)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
174 progress=process(null,null);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
175
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
176 // handle the delegate connection
965
866f2e801618 handle() returns void
Franklin Schmidt <fschmidt@gmail.com>
parents: 960
diff changeset
177 _connection.handle();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
178
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
179 _logger.debug("{} handle {} progress={}", _session, this, progress);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
180 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
181 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
182 finally
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
183 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
184 releaseBuffers();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
185
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
186 if (!_ishut && _sslEndPoint.isInputShutdown() && _sslEndPoint.isOpen())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
187 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
188 _ishut=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
189 try
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
190 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
191 _connection.onInputShutdown();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
192 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
193 catch(Throwable x)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
194 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
195 _logger.warn("onInputShutdown failed", x);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
196 try{_sslEndPoint.close();}
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
197 catch(IOException e2){
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
198 _logger.trace("",e2);}
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
199 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
200 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
201 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
202 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
203
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 978
diff changeset
204 @Override
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
205 public boolean isSuspended()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
206 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
207 return false;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
209
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 978
diff changeset
210 @Override
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
211 public void onInputShutdown() throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
212 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
213 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
214
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
215 private synchronized boolean process(JBuffer toFill, JBuffer toFlush) throws IOException
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
216 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
217 boolean some_progress=false;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
218 try
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
219 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
220 // We need buffers to progress
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
221 allocateBuffers();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
222
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
223 // if we don't have a buffer to put received data into
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
224 if (toFill==null)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
225 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 // use the unwrapbuffer to hold received data.
1065
158d1e6ac17f fix JBuffer.compact()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1062
diff changeset
227 BufferUtil.compact(_unwrapBuf);
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
228 toFill=_unwrapBuf;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
229 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
230 // Else if the fill buffer is too small for the SSL session
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
231 else if (toFill.capacity()<_session.getApplicationBufferSize())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
232 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
233 // fill to the temporary unwrapBuffer
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
234 boolean progress=process(null,toFlush);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
235
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
236 // if we received any data,
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
237 if (_unwrapBuf!=null && _unwrapBuf.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
238 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
239 // transfer from temp buffer to fill buffer
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
240 _unwrapBuf.skip(toFill.put(_unwrapBuf));
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
241 return true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
242 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
243 else
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
244 // return progress from recursive call
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
245 return progress;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
246 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
247 // Else if there is some temporary data
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
248 else if (_unwrapBuf!=null && _unwrapBuf.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
249 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
250 // transfer from temp buffer to fill buffer
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
251 _unwrapBuf.skip(toFill.put(_unwrapBuf));
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
252 return true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
253 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
254
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
255 // If we are here, we have a buffer ready into which we can put some read data.
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
256
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
257 // If we have no data to flush, flush the empty buffer
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
258 if (toFlush==null)
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 978
diff changeset
259 toFlush = __ZERO_BUFFER;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
260
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
261 // While we are making progress processing SSL engine
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
262 boolean progress=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
263 while (progress)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
264 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
265 progress=false;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
266
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
267 // Do any real IO
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
268 int filled=0,flushed=0;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
269 try
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
270 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
271 // Read any available data
1071
b4ba8a4d5a16 remove JBuffer.space()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1068
diff changeset
272 if (_inbound.capacity()>_inbound.limit() && (filled=_endp.fill(_inbound))>0)
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
273 progress = true;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
274
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
275 // flush any output data
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
276 if (_outbound.hasRemaining() && (flushed=_endp.flush(_outbound))>0)
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
277 progress = true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
278 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
279 catch (IOException e)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
280 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
281 _endp.close();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
282 throw e;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
283 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
284 finally
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
285 {
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
286 _logger.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.remaining(),flushed,_outbound.remaining());
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
287 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
288
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
289 // handle the current hand share status
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
290 switch(_engine.getHandshakeStatus())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
291 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
292 case FINISHED:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
293 throw new IllegalStateException();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
294
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
295 case NOT_HANDSHAKING:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
296 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
297 // Try unwrapping some application data
1071
b4ba8a4d5a16 remove JBuffer.space()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1068
diff changeset
298 if (toFill.capacity()>toFill.limit() && _inbound.hasRemaining() && unwrap(toFill))
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
299 progress=true;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
300
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
301 // Try wrapping some application data
1071
b4ba8a4d5a16 remove JBuffer.space()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1068
diff changeset
302 if (toFlush.hasRemaining() && _outbound.capacity()>_outbound.limit() && wrap(toFlush))
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
303 progress=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
304 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
305 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
306
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
307 case NEED_TASK:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
308 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
309 // A task needs to be run, so run it!
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
310 Runnable task;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
311 while ((task=_engine.getDelegatedTask())!=null)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
312 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
313 progress=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
314 task.run();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
315 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
316
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
317 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
318 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
319
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
320 case NEED_WRAP:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
321 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
322 // The SSL needs to send some handshake data to the other side
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
323 if (_handshook && !_allowRenegotiate)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
324 _endp.close();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
325 else if (wrap(toFlush))
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
326 progress=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
327 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
328 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
329
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
330 case NEED_UNWRAP:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
331 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
332 // The SSL needs to receive some handshake data from the other side
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
333 if (_handshook && !_allowRenegotiate)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
334 _endp.close();
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
335 else if (!_inbound.hasRemaining()&&filled==-1)
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
336 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
337 // No more input coming
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
338 _endp.shutdownInput();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
339 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
340 else if (unwrap(toFill))
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
341 progress=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
342 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
343 break;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
344 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
345
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
346 // pass on ishut/oshut state
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
347 if (_endp.isOpen() && _endp.isInputShutdown() && !_inbound.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
348 closeInbound();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
349
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
350 if (_endp.isOpen() && _engine.isOutboundDone() && !_outbound.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
351 _endp.shutdownOutput();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
352
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
353 // remember if any progress has been made
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
354 some_progress|=progress;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
355 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
356
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
357 // If we are reading into the temp buffer and it has some content, then we should be dispatched.
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
358 if (toFill==_unwrapBuf && _unwrapBuf.hasRemaining() && !_connection.isSuspended())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
359 _aEndp.dispatch();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
360 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
361 finally
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
362 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
363 releaseBuffers();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
364 if (some_progress)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
365 _progressed.set(true);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
366 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
367 return some_progress;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
368 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
369
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
370 private void closeInbound()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
371 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
372 try
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
373 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
374 _engine.closeInbound();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
375 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
376 catch (SSLException x)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
377 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
378 _logger.debug("",x);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
379 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
380 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
381
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
382 private synchronized boolean wrap(final JBuffer buffer) throws IOException
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
383 {
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
384 ByteBuffer bbuf = buffer.getByteBuffer();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
385 final SSLEngineResult result;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
386
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
387 synchronized(bbuf)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
388 {
1065
158d1e6ac17f fix JBuffer.compact()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1062
diff changeset
389 BufferUtil.compact(_outbound);
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
390 ByteBuffer out_buffer = _outbound.getByteBuffer().duplicate();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
391 synchronized(out_buffer)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
392 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
393 try
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
394 {
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
395 out_buffer.position(_outbound.limit());
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
396 out_buffer.limit(out_buffer.capacity());
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
397 result = _engine.wrap(bbuf,out_buffer);
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
398 if (_logger.isDebugEnabled())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
399 _logger.debug("{} wrap {} {} consumed={} produced={}",
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
400 _session,
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
401 result.getStatus(),
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
402 result.getHandshakeStatus(),
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
403 result.bytesConsumed(),
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
404 result.bytesProduced());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
405
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
406 _outbound.limit(_outbound.limit()+result.bytesProduced());
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
407 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
408 catch(SSLException e)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
409 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
410 _logger.debug(String.valueOf(_endp), e);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
411 _endp.close();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
412 throw e;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
413 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
414 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
415 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
416
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
417 switch(result.getStatus())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
418 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
419 case BUFFER_UNDERFLOW:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
420 throw new IllegalStateException();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
421
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
422 case BUFFER_OVERFLOW:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
423 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
424
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
425 case OK:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
426 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
427 _handshook=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
428 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
429
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
430 case CLOSED:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
431 _logger.debug("wrap CLOSE {} {}",this,result);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
432 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
433 _endp.close();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
434 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
435
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
436 default:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
437 _logger.debug("{} wrap default {}",_session,result);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
438 throw new IOException(result.toString());
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
439 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
440
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
441 return result.bytesConsumed()>0 || result.bytesProduced()>0;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
442 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
443
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
444 private synchronized boolean unwrap(final JBuffer buffer) throws IOException
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
445 {
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
446 if (!_inbound.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
447 return false;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
448
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
449 ByteBuffer bbuf = buffer.getByteBuffer().duplicate();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
450 final SSLEngineResult result;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
451
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
452 synchronized(bbuf)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
453 {
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
454 ByteBuffer in_buffer = _inbound.getByteBuffer();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
455 synchronized(in_buffer)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
456 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
457 try
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
458 {
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
459 bbuf.position(buffer.limit());
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
460 bbuf.limit(buffer.capacity());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
461
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
462 result=_engine.unwrap(in_buffer,bbuf);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
463 if (_logger.isDebugEnabled())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
464 _logger.debug("{} unwrap {} {} consumed={} produced={}",
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
465 _session,
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
466 result.getStatus(),
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
467 result.getHandshakeStatus(),
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
468 result.bytesConsumed(),
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
469 result.bytesProduced());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
470
1065
158d1e6ac17f fix JBuffer.compact()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1062
diff changeset
471 BufferUtil.compact(_inbound);
1062
4a50422596b6 fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1049
diff changeset
472 buffer.limit(buffer.limit()+result.bytesProduced());
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
473 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
474 catch(SSLException e)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
475 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
476 _logger.debug(String.valueOf(_endp), e);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
477 _endp.close();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
478 throw e;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
479 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
480 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
481 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
482
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
483 switch(result.getStatus())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
484 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
485 case BUFFER_UNDERFLOW:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
486 if (_endp.isInputShutdown())
1065
158d1e6ac17f fix JBuffer.compact()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1062
diff changeset
487 _inbound.limit(0);
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
488 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
489
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
490 case BUFFER_OVERFLOW:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
491 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
492
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
493 case OK:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
494 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
495 _handshook=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
496 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
497
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
498 case CLOSED:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
499 _logger.debug("unwrap CLOSE {} {}",this,result);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
500 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
501 _endp.close();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
502 break;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
503
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
504 default:
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
505 _logger.debug("{} wrap default {}",_session,result);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
506 throw new IOException(result.toString());
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
507 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
508
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
509 //if (LOG.isDebugEnabled() && result.bytesProduced()>0)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
510 // LOG.debug("{} unwrapped '{}'",_session,buffer);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
511
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
512 return result.bytesConsumed()>0 || result.bytesProduced()>0;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
513 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
514
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 945
diff changeset
515 public SslEndPoint getSslEndPoint()
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
516 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
517 return _sslEndPoint;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
518 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
519
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
520 public String toString()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
521 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
522 return String.format("%s %s", super.toString(), _sslEndPoint);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
523 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
524
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 945
diff changeset
525
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 945
diff changeset
526 public final class SslEndPoint implements AsyncEndPoint
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
527 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
528 public SSLEngine getSslEngine()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
529 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
530 return _engine;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
531 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
532
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
533 public AsyncEndPoint getEndpoint()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
534 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
535 return _aEndp;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
536 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
537
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
538 public void shutdownOutput() throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
539 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
540 synchronized (SslConnection.this)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
541 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
542 _logger.debug("{} ssl endp.oshut {}",_session,this);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
543 _engine.closeOutbound();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
544 _oshut=true;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
545 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
546 flush();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
547 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
548
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
549 public boolean isOutputShutdown()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
550 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
551 synchronized (SslConnection.this)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
552 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
553 return _oshut||!isOpen()||_engine.isOutboundDone();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
554 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
555 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
556
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
557 public void shutdownInput() throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
558 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
559 _logger.debug("{} ssl endp.ishut!",_session);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
560 // We do not do a closeInput here, as SSL does not support half close.
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
561 // isInputShutdown works it out itself from buffer state and underlying endpoint state.
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
562 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
563
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
564 public boolean isInputShutdown()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
565 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
566 synchronized (SslConnection.this)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
567 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
568 return _endp.isInputShutdown() &&
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
569 !(_unwrapBuf!=null&&_unwrapBuf.hasRemaining()) &&
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
570 !(_inbound!=null&&_inbound.hasRemaining());
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
571 }
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
572 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
573
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
574 public void close() throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
575 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
576 _logger.debug("{} ssl endp.close",_session);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
577 _endp.close();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
578 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
579
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
580 public int fill(JBuffer buffer) throws IOException
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
581 {
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
582 int size=buffer.remaining();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
583 process(buffer, null);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
584
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
585 int filled=buffer.remaining()-size;
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
586
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
587 if (filled==0 && isInputShutdown())
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
588 return -1;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
589 return filled;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
590 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
591
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
592 public int flush(JBuffer buffer) throws IOException
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
593 {
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
594 int size = buffer.remaining();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
595 process(null, buffer);
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
596 return size-buffer.remaining();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
597 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
598
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
599 public int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
600 {
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
601 if (header!=null && header.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
602 return flush(header);
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
603 if (buffer!=null && buffer.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
604 return flush(buffer);
1037
3c4c7cc7904f rename Buffer.hasContent() to hasRemaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
605 if (trailer!=null && trailer.hasRemaining())
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
606 return flush(trailer);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
607 return 0;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
608 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
609
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
610 public boolean blockReadable(long millisecs) throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
611 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
612 long now = System.currentTimeMillis();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
613 long end=millisecs>0?(now+millisecs):Long.MAX_VALUE;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
614
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
615 while (now<end)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
616 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
617 if (process(null,null))
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
618 break;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
619 _endp.blockReadable(end-now);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
620 now = System.currentTimeMillis();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
621 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
622
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
623 return now<end;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
624 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
625
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
626 public boolean blockWritable(long millisecs) throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
627 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
628 return _endp.blockWritable(millisecs);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
629 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
630
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
631 public boolean isOpen()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
632 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
633 return _endp.isOpen();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
634 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
635
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 974
diff changeset
636 public SocketChannel getChannel()
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
637 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 974
diff changeset
638 return _endp.getChannel();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
639 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
640
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
641 public void flush() throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
642 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
643 process(null, null);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
644 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
645
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
646 public void dispatch()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
647 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
648 _aEndp.dispatch();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
649 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
650
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
651 public boolean hasProgressed()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
652 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
653 return _progressed.getAndSet(false);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
654 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
655
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
656 public String getLocalAddr()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
657 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
658 return _aEndp.getLocalAddr();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
659 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
660
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
661 public String getLocalHost()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
662 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
663 return _aEndp.getLocalHost();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
664 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
665
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
666 public int getLocalPort()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
667 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
668 return _aEndp.getLocalPort();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
669 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
670
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
671 public String getRemoteAddr()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
672 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
673 return _aEndp.getRemoteAddr();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
674 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
675
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
676 public String getRemoteHost()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
677 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
678 return _aEndp.getRemoteHost();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
679 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
680
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
681 public int getRemotePort()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
682 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
683 return _aEndp.getRemotePort();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
684 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
685
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
686 public boolean isBlocking()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
687 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
688 return false;
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
689 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
690
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
691 public int getMaxIdleTime()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
692 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
693 return _aEndp.getMaxIdleTime();
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
694 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
695
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
696 public void setMaxIdleTime(int timeMs) throws IOException
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
697 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
698 _aEndp.setMaxIdleTime(timeMs);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
699 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
700
1003
Franklin Schmidt <fschmidt@gmail.com>
parents: 1002
diff changeset
701 public void setConnection(AsyncHttpConnection connection)
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
702 {
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
703 _connection = connection;
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
704 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
705
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
706 public String toString()
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
707 {
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
708 // Do NOT use synchronized (SslConnection.this)
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
709 // because it's very easy to deadlock when debugging is enabled.
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
710 // We do a best effort to print the right toString() and that's it.
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
711 JBuffer inbound = _inbound;
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
712 JBuffer outbound = _outbound;
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
713 JBuffer unwrap = _unwrapBuf;
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
714 int i = inbound == null? -1 : inbound.remaining();
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
715 int o = outbound == null ? -1 : outbound.remaining();
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1037
diff changeset
716 int u = unwrap == null ? -1 : unwrap.remaining();
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
717 return String.format("SSL %s i/o/u=%d/%d/%d ishut=%b oshut=%b {%s}",
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
718 _engine.getHandshakeStatus(),
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
719 i, o, u,
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
720 _ishut, _oshut,
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
721 _connection);
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
722 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
723
940
b77d631b9e28 remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
724 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
725 }