Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Socket not closed on binding fail, causing the ActorSystem to not shutdown #6

Closed
damienlevin opened this issue Jul 24, 2013 · 1 comment · Fixed by #7
Closed

Socket not closed on binding fail, causing the ActorSystem to not shutdown #6

damienlevin opened this issue Jul 24, 2013 · 1 comment · Fixed by #7

Comments

@damienlevin
Copy link
Contributor

package com.mdialog.test

import akka.dispatch._
import akka.actor._
import akka.pattern._
import akka.util._

import scala.concurrent.duration._
import scala.concurrent._
import ExecutionContext.Implicits.global

object Test extends App {

val system = ActorSystem("test")
system.registerOnTermination {
println("ActorSystem.registerOnTermination")
}

val account = system.actorOf(Props[TestActor])

account ! "pouf"

Thread.sleep(5000)

println("Shutdown")
system.shutdown()

}

class TestActor extends Actor {

val endpointA = "tcp://127.0.0.1:%s" format { val s = new java.net.ServerSocket(0); try s.getLocalPort finally s.close() }
val endpointB = "tcp://127.0.0.1:%s" format { val s = new java.net.ServerSocket(0); try s.getLocalPort finally s.close() }

def receive = {
case _ ⇒
val socketA = zeromq.ZeroMQExtension.get(context.system).newSocket(zeromq.SocketType.Pub, zeromq.Listener(self), zeromq.Linger(0), zeromq.Bind(endpointA))
val socketB = zeromq.ZeroMQExtension.get(context.system).newSocket(zeromq.SocketType.Pull, zeromq.Listener(self), zeromq.Linger(0), zeromq.Bind(endpointB))
val socketC = zeromq.ZeroMQExtension.get(context.system).newSocket(zeromq.SocketType.Pull, zeromq.Listener(self), zeromq.Linger(0), zeromq.Bind(endpointB))
}

override def postStop() {
println("Stopping TestActor...")
}
}

@chrisdinn
Copy link
Contributor

Fixed by 2f32205

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants