comparison src/org/eclipse/jetty/io/nio/SslConnection.java @ 1037:3c4c7cc7904f

rename Buffer.hasContent() to hasRemaining()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 21:54:34 -0600
parents 21910079096e
children b71ad168fe34
comparison
equal deleted inserted replaced
1036:b87f97f6418a 1037:3c4c7cc7904f
228 { 228 {
229 // fill to the temporary unwrapBuffer 229 // fill to the temporary unwrapBuffer
230 boolean progress=process(null,toFlush); 230 boolean progress=process(null,toFlush);
231 231
232 // if we received any data, 232 // if we received any data,
233 if (_unwrapBuf!=null && _unwrapBuf.hasContent()) 233 if (_unwrapBuf!=null && _unwrapBuf.hasRemaining())
234 { 234 {
235 // transfer from temp buffer to fill buffer 235 // transfer from temp buffer to fill buffer
236 _unwrapBuf.skip(toFill.put(_unwrapBuf)); 236 _unwrapBuf.skip(toFill.put(_unwrapBuf));
237 return true; 237 return true;
238 } 238 }
239 else 239 else
240 // return progress from recursive call 240 // return progress from recursive call
241 return progress; 241 return progress;
242 } 242 }
243 // Else if there is some temporary data 243 // Else if there is some temporary data
244 else if (_unwrapBuf!=null && _unwrapBuf.hasContent()) 244 else if (_unwrapBuf!=null && _unwrapBuf.hasRemaining())
245 { 245 {
246 // transfer from temp buffer to fill buffer 246 // transfer from temp buffer to fill buffer
247 _unwrapBuf.skip(toFill.put(_unwrapBuf)); 247 _unwrapBuf.skip(toFill.put(_unwrapBuf));
248 return true; 248 return true;
249 } 249 }
267 // Read any available data 267 // Read any available data
268 if (_inbound.space()>0 && (filled=_endp.fill(_inbound))>0) 268 if (_inbound.space()>0 && (filled=_endp.fill(_inbound))>0)
269 progress = true; 269 progress = true;
270 270
271 // flush any output data 271 // flush any output data
272 if (_outbound.hasContent() && (flushed=_endp.flush(_outbound))>0) 272 if (_outbound.hasRemaining() && (flushed=_endp.flush(_outbound))>0)
273 progress = true; 273 progress = true;
274 } 274 }
275 catch (IOException e) 275 catch (IOException e)
276 { 276 {
277 _endp.close(); 277 _endp.close();
289 throw new IllegalStateException(); 289 throw new IllegalStateException();
290 290
291 case NOT_HANDSHAKING: 291 case NOT_HANDSHAKING:
292 { 292 {
293 // Try unwrapping some application data 293 // Try unwrapping some application data
294 if (toFill.space()>0 && _inbound.hasContent() && unwrap(toFill)) 294 if (toFill.space()>0 && _inbound.hasRemaining() && unwrap(toFill))
295 progress=true; 295 progress=true;
296 296
297 // Try wrapping some application data 297 // Try wrapping some application data
298 if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) 298 if (toFlush.hasRemaining() && _outbound.space()>0 && wrap(toFlush))
299 progress=true; 299 progress=true;
300 } 300 }
301 break; 301 break;
302 302
303 case NEED_TASK: 303 case NEED_TASK:
326 case NEED_UNWRAP: 326 case NEED_UNWRAP:
327 { 327 {
328 // The SSL needs to receive some handshake data from the other side 328 // The SSL needs to receive some handshake data from the other side
329 if (_handshook && !_allowRenegotiate) 329 if (_handshook && !_allowRenegotiate)
330 _endp.close(); 330 _endp.close();
331 else if (!_inbound.hasContent()&&filled==-1) 331 else if (!_inbound.hasRemaining()&&filled==-1)
332 { 332 {
333 // No more input coming 333 // No more input coming
334 _endp.shutdownInput(); 334 _endp.shutdownInput();
335 } 335 }
336 else if (unwrap(toFill)) 336 else if (unwrap(toFill))
338 } 338 }
339 break; 339 break;
340 } 340 }
341 341
342 // pass on ishut/oshut state 342 // pass on ishut/oshut state
343 if (_endp.isOpen() && _endp.isInputShutdown() && !_inbound.hasContent()) 343 if (_endp.isOpen() && _endp.isInputShutdown() && !_inbound.hasRemaining())
344 closeInbound(); 344 closeInbound();
345 345
346 if (_endp.isOpen() && _engine.isOutboundDone() && !_outbound.hasContent()) 346 if (_endp.isOpen() && _engine.isOutboundDone() && !_outbound.hasRemaining())
347 _endp.shutdownOutput(); 347 _endp.shutdownOutput();
348 348
349 // remember if any progress has been made 349 // remember if any progress has been made
350 some_progress|=progress; 350 some_progress|=progress;
351 } 351 }
352 352
353 // If we are reading into the temp buffer and it has some content, then we should be dispatched. 353 // If we are reading into the temp buffer and it has some content, then we should be dispatched.
354 if (toFill==_unwrapBuf && _unwrapBuf.hasContent() && !_connection.isSuspended()) 354 if (toFill==_unwrapBuf && _unwrapBuf.hasRemaining() && !_connection.isSuspended())
355 _aEndp.dispatch(); 355 _aEndp.dispatch();
356 } 356 }
357 finally 357 finally
358 { 358 {
359 releaseBuffers(); 359 releaseBuffers();
448 return result.bytesConsumed()>0 || result.bytesProduced()>0; 448 return result.bytesConsumed()>0 || result.bytesProduced()>0;
449 } 449 }
450 450
451 private synchronized boolean unwrap(final Buffer buffer) throws IOException 451 private synchronized boolean unwrap(final Buffer buffer) throws IOException
452 { 452 {
453 if (!_inbound.hasContent()) 453 if (!_inbound.hasRemaining())
454 return false; 454 return false;
455 455
456 ByteBuffer bbuf=extractByteBuffer(buffer); 456 ByteBuffer bbuf=extractByteBuffer(buffer);
457 final SSLEngineResult result; 457 final SSLEngineResult result;
458 458
590 public boolean isInputShutdown() 590 public boolean isInputShutdown()
591 { 591 {
592 synchronized (SslConnection.this) 592 synchronized (SslConnection.this)
593 { 593 {
594 return _endp.isInputShutdown() && 594 return _endp.isInputShutdown() &&
595 !(_unwrapBuf!=null&&_unwrapBuf.hasContent()) && 595 !(_unwrapBuf!=null&&_unwrapBuf.hasRemaining()) &&
596 !(_inbound!=null&&_inbound.hasContent()); 596 !(_inbound!=null&&_inbound.hasRemaining());
597 } 597 }
598 } 598 }
599 599
600 public void close() throws IOException 600 public void close() throws IOException
601 { 601 {
622 return size-buffer.length(); 622 return size-buffer.length();
623 } 623 }
624 624
625 public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException 625 public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException
626 { 626 {
627 if (header!=null && header.hasContent()) 627 if (header!=null && header.hasRemaining())
628 return flush(header); 628 return flush(header);
629 if (buffer!=null && buffer.hasContent()) 629 if (buffer!=null && buffer.hasRemaining())
630 return flush(buffer); 630 return flush(buffer);
631 if (trailer!=null && trailer.hasContent()) 631 if (trailer!=null && trailer.hasRemaining())
632 return flush(trailer); 632 return flush(trailer);
633 return 0; 633 return 0;
634 } 634 }
635 635
636 public boolean blockReadable(long millisecs) throws IOException 636 public boolean blockReadable(long millisecs) throws IOException