Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/Connector.java @ 905:e7175965e6cf
remove Connector._acceptorThreads
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 07 Oct 2016 00:59:18 -0600 |
parents | 5d9b213aaed0 |
children | eaf271fb747f |
comparison
equal
deleted
inserted
replaced
904:5d9b213aaed0 | 905:e7175965e6cf |
---|---|
66 | 66 |
67 protected int _maxIdleTime = 200000; | 67 protected int _maxIdleTime = 200000; |
68 protected int _lowResourceMaxIdleTime = -1; | 68 protected int _lowResourceMaxIdleTime = -1; |
69 protected int _soLingerTime = -1; | 69 protected int _soLingerTime = -1; |
70 | 70 |
71 private transient Thread[] _acceptorThreads; | |
72 | |
73 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl(); | 71 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl(); |
74 | 72 |
75 public Connector(Server server,int port) { | 73 public Connector(Server server,int port) { |
76 this.server = server; | 74 this.server = server; |
77 this.port = port; | 75 this.port = port; |
219 open(); | 217 open(); |
220 | 218 |
221 super.doStart(); | 219 super.doStart(); |
222 | 220 |
223 // Start selector thread | 221 // Start selector thread |
224 synchronized (this) | 222 ThreadPoolExecutor _threadPool = server.threadPool; |
225 { | 223 for (int i = 0; i < _acceptors; i++) |
226 _acceptorThreads = new Thread[getAcceptors()]; | 224 _threadPool.execute(new Acceptor(i)); |
227 | 225 if (server.isLowOnThreads()) |
228 ThreadPoolExecutor _threadPool = server.threadPool; | 226 LOG.warn("insufficient threads configured for {}",this); |
229 for (int i = 0; i < _acceptorThreads.length; i++) | |
230 _threadPool.execute(new Acceptor(i)); | |
231 if (server.isLowOnThreads()) | |
232 LOG.warn("insufficient threads configured for {}",this); | |
233 } | |
234 | 227 |
235 LOG.info("Started {}",this); | 228 LOG.info("Started {}",this); |
236 } | 229 } |
237 | 230 |
238 /* ------------------------------------------------------------ */ | 231 /* ------------------------------------------------------------ */ |
247 { | 240 { |
248 LOG.warn("",e); | 241 LOG.warn("",e); |
249 } | 242 } |
250 | 243 |
251 super.doStop(); | 244 super.doStop(); |
252 | 245 } |
253 Thread[] acceptors; | 246 |
254 synchronized (this) | |
255 { | |
256 acceptors = _acceptorThreads; | |
257 _acceptorThreads = null; | |
258 } | |
259 if (acceptors != null) | |
260 { | |
261 for (Thread thread : acceptors) | |
262 { | |
263 if (thread != null) | |
264 thread.interrupt(); | |
265 } | |
266 } | |
267 } | |
268 | |
269 /* ------------------------------------------------------------ */ | |
270 public void join() throws InterruptedException | |
271 { | |
272 Thread[] threads; | |
273 synchronized(this) | |
274 { | |
275 threads=_acceptorThreads; | |
276 } | |
277 if (threads != null) | |
278 for (Thread thread : threads) | |
279 if (thread != null) | |
280 thread.join(); | |
281 } | |
282 | 247 |
283 /* ------------------------------------------------------------ */ | 248 /* ------------------------------------------------------------ */ |
284 protected void configure(Socket socket) throws IOException | 249 protected void configure(Socket socket) throws IOException |
285 { | 250 { |
286 try | 251 try |
431 | 396 |
432 /* ------------------------------------------------------------ */ | 397 /* ------------------------------------------------------------ */ |
433 public void run() | 398 public void run() |
434 { | 399 { |
435 Thread current = Thread.currentThread(); | 400 Thread current = Thread.currentThread(); |
436 String name; | 401 String name = current.getName(); |
437 synchronized (Connector.this) | 402 current.setName(name + " Acceptor" + _acceptor + " " + Connector.this); |
438 { | |
439 if (_acceptorThreads == null) | |
440 return; | |
441 | |
442 _acceptorThreads[_acceptor] = current; | |
443 name = _acceptorThreads[_acceptor].getName(); | |
444 current.setName(name + " Acceptor" + _acceptor + " " + Connector.this); | |
445 } | |
446 | 403 |
447 try | 404 try |
448 { | 405 { |
449 while (isRunning() && getConnection() != null) | 406 while (isRunning() && getConnection() != null) |
450 { | 407 { |
472 } | 429 } |
473 } | 430 } |
474 finally | 431 finally |
475 { | 432 { |
476 current.setName(name); | 433 current.setName(name); |
477 | |
478 synchronized (Connector.this) | |
479 { | |
480 if (_acceptorThreads != null) | |
481 _acceptorThreads[_acceptor] = null; | |
482 } | |
483 } | 434 } |
484 } | 435 } |
485 } | 436 } |
486 | 437 |
487 public String getName() | 438 public String getName() |