You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/03/17 22:45:04 UTC

[incubator-nlpcraft] branch NLPCRAFT-19 created (now 05519e3)

This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a change to branch NLPCRAFT-19
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git.


      at 05519e3  Fix for NLPCRAFT-19.

This branch includes the following new commits:

     new 05519e3  Fix for NLPCRAFT-19.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-nlpcraft] 01/01: Fix for NLPCRAFT-19.

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-19
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git

commit 05519e3e8a8b1e404c27205bbaf98ef705f843f1
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Tue Mar 17 15:44:50 2020 -0700

    Fix for NLPCRAFT-19.
---
 .../nlpcraft/probe/mgrs/conn/NCConnectionManager.scala  | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala b/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
index ad69e71..b200b87 100644
--- a/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
+++ b/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
@@ -275,6 +275,8 @@ object NCConnectionManager extends NCService {
     override def start(parent: Span = null): NCService = startScopedSpan("start", parent) { _ ⇒
         require(NCCommandManager.isStarted)
         require(NCModelManager.isStarted)
+        
+        val ctrlLatch = new CountDownLatch(1)
      
         ctrlThread = U.mkThread("probe-ctrl-thread") { t ⇒
             var dnSock: NCSocket = null
@@ -320,7 +322,7 @@ object NCConnectionManager extends NCService {
                     
                     upSock.socket.setSoTimeout(SO_TIMEOUT)
             
-                    val latch = new CountDownLatch(1)
+                    val exitLatch = new CountDownLatch(1)
             
                     /**
                       *
@@ -335,7 +337,7 @@ object NCConnectionManager extends NCService {
                             logger.info(msg)
                         caller.interrupt() // Interrupt current calling thread.
                 
-                        latch.countDown()
+                        exitLatch.countDown()
                     }
             
                     upThread = U.mkThread("probe-uplink") { t ⇒
@@ -389,10 +391,14 @@ object NCConnectionManager extends NCService {
                     upThread.start()
                     dnThread.start()
                     
+                    // Indicate that server connection is established.
+                    ctrlLatch.countDown()
+                    
                     logger.info("REST server connection established.")
                     
-                    while (!t.isInterrupted && latch.getCount > 0) U.ignoreInterrupt {
-                        latch.await()
+                    // Wait until probe connection is closed.
+                    while (!t.isInterrupted && exitLatch.getCount > 0) U.ignoreInterrupt {
+                        exitLatch.await()
                     }
                     
                     closeAll()
@@ -444,6 +450,9 @@ object NCConnectionManager extends NCService {
         }
      
         ctrlThread.start()
+        
+        // Only return when probe successfully connected to the server.
+        ctrlLatch.await()
      
         super.start()
     }