comparison src/org/eclipse/jetty/io/nio/SslConnection.java @ 1065:158d1e6ac17f

fix JBuffer.compact()
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 09 Nov 2016 04:36:05 -0700
parents 4a50422596b6
children 9d357b9e4bcb
comparison
equal deleted inserted replaced
1064:a0abb16cf6e7 1065:158d1e6ac17f
121 if (_buffers==null) 121 if (_buffers==null)
122 { 122 {
123 _buffers=__buffers.get(); 123 _buffers=__buffers.get();
124 if (_buffers==null) 124 if (_buffers==null)
125 _buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2); 125 _buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2);
126 _inbound=_buffers._in; 126 _inbound = _buffers._in;
127 _outbound = _buffers._out; 127 _outbound = _buffers._out;
128 _unwrapBuf=_buffers._unwrap; 128 _unwrapBuf=_buffers._unwrap;
129 __buffers.set(null); 129 __buffers.set(null);
130 } 130 }
131 } 131 }
219 219
220 // if we don't have a buffer to put received data into 220 // if we don't have a buffer to put received data into
221 if (toFill==null) 221 if (toFill==null)
222 { 222 {
223 // use the unwrapbuffer to hold received data. 223 // use the unwrapbuffer to hold received data.
224 _unwrapBuf.compact(); 224 BufferUtil.compact(_unwrapBuf);
225 toFill=_unwrapBuf; 225 toFill=_unwrapBuf;
226 } 226 }
227 // Else if the fill buffer is too small for the SSL session 227 // Else if the fill buffer is too small for the SSL session
228 else if (toFill.capacity()<_session.getApplicationBufferSize()) 228 else if (toFill.capacity()<_session.getApplicationBufferSize())
229 { 229 {
381 ByteBuffer bbuf = buffer.getByteBuffer(); 381 ByteBuffer bbuf = buffer.getByteBuffer();
382 final SSLEngineResult result; 382 final SSLEngineResult result;
383 383
384 synchronized(bbuf) 384 synchronized(bbuf)
385 { 385 {
386 _outbound.compact(); 386 BufferUtil.compact(_outbound);
387 ByteBuffer out_buffer = _outbound.getByteBuffer().duplicate(); 387 ByteBuffer out_buffer = _outbound.getByteBuffer().duplicate();
388 synchronized(out_buffer) 388 synchronized(out_buffer)
389 { 389 {
390 try 390 try
391 { 391 {
463 result.getStatus(), 463 result.getStatus(),
464 result.getHandshakeStatus(), 464 result.getHandshakeStatus(),
465 result.bytesConsumed(), 465 result.bytesConsumed(),
466 result.bytesProduced()); 466 result.bytesProduced());
467 467
468 _inbound.compact(); 468 BufferUtil.compact(_inbound);
469 buffer.limit(buffer.limit()+result.bytesProduced()); 469 buffer.limit(buffer.limit()+result.bytesProduced());
470 } 470 }
471 catch(SSLException e) 471 catch(SSLException e)
472 { 472 {
473 _logger.debug(String.valueOf(_endp), e); 473 _logger.debug(String.valueOf(_endp), e);
479 479
480 switch(result.getStatus()) 480 switch(result.getStatus())
481 { 481 {
482 case BUFFER_UNDERFLOW: 482 case BUFFER_UNDERFLOW:
483 if (_endp.isInputShutdown()) 483 if (_endp.isInputShutdown())
484 _inbound.clear(); 484 _inbound.limit(0);
485 break; 485 break;
486 486
487 case BUFFER_OVERFLOW: 487 case BUFFER_OVERFLOW:
488 break; 488 break;
489 489