MCPcopy Index your code
hub / github.com/apache/tomcat / await

Method await

java/org/apache/catalina/core/StandardServer.java:509–634  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

507 }
508
509 @Override
510 public void await() {
511 // Negative values - don't wait on port - tomcat is embedded or we just don't like ports
512 if (getPortWithOffset() == -2) {
513 // undocumented yet - for embedding apps that are around, alive.
514 return;
515 }
516 Thread currentThread = Thread.currentThread();
517 if (getPortWithOffset() == -1) {
518 try {
519 awaitThread = currentThread;
520 while (!stopAwait) {
521 try {
522 Thread.sleep(10000);
523 } catch (InterruptedException ex) {
524 // continue and check the flag
525 }
526 }
527 } finally {
528 awaitThread = null;
529 }
530 return;
531 }
532
533 // Set up a server socket to wait on
534 try {
535 awaitSocket = new ServerSocket(getPortWithOffset(), 1, InetAddress.getByName(address));
536 } catch (IOException ioe) {
537 log.error(sm.getString("standardServer.awaitSocket.fail", address, String.valueOf(getPortWithOffset()),
538 String.valueOf(getPort()), String.valueOf(getPortOffset())), ioe);
539 return;
540 }
541
542 try {
543 awaitThread = currentThread;
544
545 // Loop waiting for a connection and a valid command
546 while (!stopAwait) {
547 ServerSocket serverSocket = awaitSocket;
548 if (serverSocket == null) {
549 break;
550 }
551
552 // Wait for the next connection
553 Socket socket = null;
554 StringBuilder command = new StringBuilder();
555 try {
556 InputStream stream;
557 long acceptStartTime = System.currentTimeMillis();
558 try {
559 socket = serverSocket.accept();
560 socket.setSoTimeout(10 * 1000); // Ten seconds
561 stream = socket.getInputStream();
562 } catch (SocketTimeoutException ste) {
563 // This should never happen but bug 56684 suggests that
564 // it does.
565 log.warn(sm.getString("standardServer.accept.timeout",
566 Long.valueOf(System.currentTimeMillis() - acceptStartTime)), ste);

Callers

nothing calls this directly

Calls 15

getPortWithOffsetMethod · 0.95
getPortMethod · 0.95
getPortOffsetMethod · 0.95
lengthMethod · 0.80
errorMethod · 0.65
getStringMethod · 0.65
acceptMethod · 0.65
getInputStreamMethod · 0.65
warnMethod · 0.65
readMethod · 0.65
closeMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected