comparison src/org/eclipse/jetty/server/BlockingHttpConnection.java @ 1035:898774c2cd87

remove HttpGenerator.returnBuffers()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 21:09:57 -0600
parents 4ada7a8c128a
children
comparison
equal deleted inserted replaced
1034:563458c4dc93 1035:898774c2cd87
42 } 42 }
43 43
44 @Override 44 @Override
45 public void handle() throws IOException 45 public void handle() throws IOException
46 { 46 {
47 try 47 // do while the endpoint is open
48 // AND the connection has not changed
49 while (_endp.isOpen())
48 { 50 {
49 // do while the endpoint is open 51 try
50 // AND the connection has not changed
51 while (_endp.isOpen())
52 { 52 {
53 try 53 // If we are not ended then parse available
54 if (!_parser.isComplete() && !_endp.isInputShutdown())
55 _parser.parseAvailable();
56
57 // Do we have more generating to do?
58 // Loop here because some writes may take multiple steps and
59 // we need to flush them all before potentially blocking in the
60 // next loop.
61 if (_generator.isCommitted() && !_generator.isComplete() && !_endp.isOutputShutdown())
62 _generator.flushBuffer();
63
64 // Flush buffers
65 _endp.flush();
66 }
67 catch (HttpException e)
68 {
69 if (LOG.isDebugEnabled())
54 { 70 {
55 // If we are not ended then parse available 71 LOG.debug("uri="+_uri);
56 if (!_parser.isComplete() && !_endp.isInputShutdown()) 72 LOG.debug("fields="+_requestFields);
57 _parser.parseAvailable(); 73 LOG.debug("",e);
74 }
75 _generator.sendError(e.getStatus(), e.getReason(), null, true);
76 initParser();
77 _endp.shutdownOutput();
78 }
79 finally
80 {
81 // Is this request/response round complete and are fully flushed?
82 if (_parser.isComplete() && _generator.isComplete())
83 {
84 // Reset the parser/generator
85 reset();
58 86
59 // Do we have more generating to do? 87 // TODO Is this required?
60 // Loop here because some writes may take multiple steps and 88 if (!_generator.isPersistent() && !_endp.isOutputShutdown())
61 // we need to flush them all before potentially blocking in the 89 {
62 // next loop. 90 LOG.warn("Safety net oshut!!! Please open a bugzilla");
63 if (_generator.isCommitted() && !_generator.isComplete() && !_endp.isOutputShutdown()) 91 _endp.shutdownOutput();
64 _generator.flushBuffer(); 92 }
65
66 // Flush buffers
67 _endp.flush();
68 } 93 }
69 catch (HttpException e) 94
95 // If we don't have a committed response and we are not suspended
96 if (_endp.isInputShutdown() && _generator.isIdle())
70 { 97 {
71 if (LOG.isDebugEnabled()) 98 // then no more can happen, so close.
72 { 99 _endp.close();
73 LOG.debug("uri="+_uri);
74 LOG.debug("fields="+_requestFields);
75 LOG.debug("",e);
76 }
77 _generator.sendError(e.getStatus(), e.getReason(), null, true);
78 initParser();
79 _endp.shutdownOutput();
80 }
81 finally
82 {
83 // Is this request/response round complete and are fully flushed?
84 if (_parser.isComplete() && _generator.isComplete())
85 {
86 // Reset the parser/generator
87 reset();
88
89 // TODO Is this required?
90 if (!_generator.isPersistent() && !_endp.isOutputShutdown())
91 {
92 LOG.warn("Safety net oshut!!! Please open a bugzilla");
93 _endp.shutdownOutput();
94 }
95 }
96
97 // If we don't have a committed response and we are not suspended
98 if (_endp.isInputShutdown() && _generator.isIdle())
99 {
100 // then no more can happen, so close.
101 _endp.close();
102 }
103 } 100 }
104 } 101 }
105 } 102 }
106 finally
107 {
108 _generator.returnBuffers();
109 }
110 } 103 }
111 } 104 }