test/sun/security/krb5/auto/KDC.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -147,10 +147,13 @@
     private Map<Option,Object> options = new HashMap<>();
     // Realm-specific krb5.conf settings
     private List<String> conf = new ArrayList<>();
 
     private Thread thread1, thread2, thread3;
+    private volatile boolean udpConcumerReady = false;
+    private volatile boolean tcpConcumerReady = false;
+    private volatile boolean dispatcherReady = false;
     DatagramSocket u1 = null;
     ServerSocket t1 = null;
 
     /**
      * Option names, to be expanded forever.

@@ -1226,10 +1229,11 @@
         this.port = port;
 
         // The UDP consumer
         thread1 = new Thread() {
             public void run() {
+                udpConcumerReady = true;
                 while (true) {
                     try {
                         byte[] inbuf = new byte[8192];
                         DatagramPacket p = new DatagramPacket(inbuf, inbuf.length);
                         udp.receive(p);

@@ -1246,10 +1250,11 @@
         thread1.start();
 
         // The TCP consumer
         thread2 = new Thread() {
             public void run() {
+                tcpConcumerReady = true;
                 while (true) {
                     try {
                         Socket socket = tcp.accept();
                         System.out.println("-----------------------------------------------");
                         System.out.println(">>>>> TCP connection established");

@@ -1268,10 +1273,11 @@
         thread2.start();
 
         // The dispatcher
         thread3 = new Thread() {
             public void run() {
+                dispatcherReady = true;
                 while (true) {
                     try {
                         q.take().send();
                     } catch (Exception e) {
                     }

@@ -1280,10 +1286,14 @@
         };
         thread3.setDaemon(true);
         thread3.start();
     }
 
+    boolean isReady() {
+        return udpConcumerReady && tcpConcumerReady && dispatcherReady;
+    }
+
     public void terminate() {
         try {
             thread1.stop();
             thread2.stop();
             thread3.stop();