Permalink
Browse files

fixing bug that caused clients to fail connection completion on Windows

  • Loading branch information...
1 parent fce89de commit d87382a99cb17c9951398a0ca5679c64d12f9f0a @DanSimon DanSimon committed Dec 17, 2016
@@ -89,7 +89,7 @@ class ConnectionHandlerSpec extends ColossusSpec {
}
}
- "automatically unbind on manual disconnect" in {
+ "automatically unbind on manual disconnect" in {
val probe = TestProbe()
class MyHandler(context: Context) extends BasicSyncHandler(context) with ClientConnectionHandler{
override def onUnbind() {
@@ -110,7 +110,7 @@ class ConnectionHandlerSpec extends ColossusSpec {
}
}
- "automatically unbind on disrupted connection" taggedAs(org.scalatest.Tag("test")) in {
+ "automatically unbind on disrupted connection" in {
val probe = TestProbe()
withIOSystem{ implicit io =>
val server = Service.basic[Raw]("test", TEST_PORT){case x => x}
@@ -127,14 +127,14 @@ class ConnectionHandlerSpec extends ColossusSpec {
}
- "automatically unbind on failure to connect" in {
+ "automatically unbind on failure to connect" taggedAs(org.scalatest.Tag("test")) in {
val probe = TestProbe()
withIOSystem{ implicit io =>
io ! IOCommand.BindAndConnectWorkerItem(
new InetSocketAddress("localhost", TEST_PORT), c => new MyHandler(c, probe.ref, true, true)
)
probe.expectMsg(250.milliseconds, "BOUND")
- probe.expectMsg(250.milliseconds, "UNBOUND")
+ probe.expectMsg(10.seconds, "UNBOUND")
}
}
@@ -476,7 +476,7 @@ class ServiceClientSpec extends ColossusSpec with MockFactory {
//beware, a java TimeoutException is NOT what we want, that is simply
//the future timing out, which it shouldn't here
intercept[RequestTimeoutException] {
- Await.result(f, 100.milliseconds)
+ Await.result(f, 10.seconds)
}
}
}
@@ -324,7 +324,13 @@ private[colossus] class Worker(config: WorkerConfig) extends Actor with ActorLog
case _ =>{}
}
try {
- newChannel.connect(address)
+ if (newChannel.connect(address)) {
+ //if this returns true it means the connection is already connected (can
+ //happen on Windows and maybe other OS's when connecting to localhost),
+ //so finish the connect process immediately. The connection will
+ //properly set the key interest ops
+ connection.handleConnected()
+ }
} catch {
case t: Throwable => {
log.error(t, s"Failed to establish connection to $address: $t")

0 comments on commit d87382a

Please sign in to comment.