Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix links the same as monitoring

  • Loading branch information...
commit c21248de846634efc46582aeef1acd5f69bea139 1 parent 73f34e3
authored November 09, 2012
28  src/main/scala/scalang/Node.scala
@@ -480,8 +480,11 @@ class ErlangNode(val name : Symbol, val cookie : String, config : NodeConfig) ex
480 480
     }
481 481
 
482 482
     if (isLocal(to)) {
483  
-      for (p <- process(to)) {
484  
-        p.registerLink(from)
  483
+      process(to) match {
  484
+        case Some(p : ProcessAdapter) =>
  485
+          p.registerLink(from)
  486
+        case None =>
  487
+          break(link, 'noproc)
485 488
       }
486 489
     } else {
487 490
       getOrConnectAndSend(to.node, LinkMessage(from, to), { channel =>
@@ -531,8 +534,13 @@ class ErlangNode(val name : Symbol, val cookie : String, config : NodeConfig) ex
531 534
         if (!isLocal(from))
532 535
           links.getOrElseUpdate(channel, new NonBlockingHashSet[Link]).add(link)
533 536
       case None =>
534  
-        if (!isLocal(from))
  537
+        if (isLocal(from)) {
  538
+          log.warn("Try to link non-live process %s to %s", from, to)
  539
+          val link = Link(from, to)
  540
+          break(link, 'noproc)
  541
+        } else {
535 542
           links.getOrElseUpdate(channel, new NonBlockingHashSet[Link]).add(Link(from, to))
  543
+        }
536 544
     }
537 545
 
538 546
     process(to) match {
@@ -542,8 +550,13 @@ class ErlangNode(val name : Symbol, val cookie : String, config : NodeConfig) ex
542 550
           links.getOrElseUpdate(channel, new NonBlockingHashSet[Link]).add(link)
543 551
 
544 552
       case None =>
545  
-        if (!isLocal(to))
  553
+        if (isLocal(to)) {
  554
+          log.warn("Try to link non-live process %s to %s", to, from)
  555
+          val link = Link(from, to)
  556
+          break(link, 'noproc)
  557
+        } else {
546 558
           links.getOrElseUpdate(channel, new NonBlockingHashSet[Link]).add(Link(from, to))
  559
+        }
547 560
     }
548 561
   }
549 562
 
@@ -776,6 +789,13 @@ class ErlangNode(val name : Symbol, val cookie : String, config : NodeConfig) ex
776 789
     } else {
777 790
       getOrConnectAndSend(to.node, ExitMessage(from,to,reason))
778 791
     }
  792
+    if (isLocal(from)) {
  793
+      for (proc <- process(from)) {
  794
+        proc.handleExit(to, reason)
  795
+      }
  796
+    } else {
  797
+      getOrConnectAndSend(from.node, ExitMessage(to,from,reason))
  798
+    }
779 799
   }
780 800
 
781 801
   def process(pidOrProc : Any) : Option[ProcessAdapter] = pidOrProc match {
7  src/main/scala/scalang/node/ProcessAdapter.scala
@@ -143,7 +143,12 @@ trait ProcessAdapter extends ExitListenable with SendListenable with LinkListena
143 143
     for (listener <- linkListeners) {
144 144
       l.addLinkListener(listener)
145 145
     }
146  
-    links.add(l)
  146
+    synchronized {
  147
+      if (state != 'alive)
  148
+        l.break('noproc)
  149
+      else
  150
+        links.add(l)
  151
+    }
147 152
     l
148 153
   }
149 154
 

0 notes on commit c21248d

Please sign in to comment.
Something went wrong with that request. Please try again.