mirror of https://github.com/sbt/sbt.git
Restore named pipe fallback
This commit is contained in:
parent
1f6d19258f
commit
9369e159c1
|
|
@ -300,6 +300,10 @@ public class BootServerSocket implements AutoCloseable {
|
|||
return locationForSocket.resolve("sbt-load.sock").toString();
|
||||
}
|
||||
|
||||
public static String namedPipeLocation(final long farmHash) {
|
||||
return "\\\\.\\pipe\\sbt-load" + farmHash;
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyCatchBlock")
|
||||
@Override
|
||||
public void close() {
|
||||
|
|
|
|||
|
|
@ -337,11 +337,11 @@ class NetworkClient(
|
|||
conn
|
||||
}
|
||||
|
||||
private def bootSocketOpt(bootSocketName: String): Option[Socket] =
|
||||
private def bootSocketOpt(bootSocketName: String, namedPipeName: String): Option[Socket] =
|
||||
Try(ClientSocket.bootSocket(bootSocketName)).toOption match
|
||||
case Some(x) => Some(x)
|
||||
case None if Util.isWindows =>
|
||||
Try(ClientSocket.localSocket(bootSocketName, useJNI)).toOption
|
||||
Try(ClientSocket.localSocket(namedPipeName, useJNI)).toOption
|
||||
case _ => None
|
||||
|
||||
/**
|
||||
|
|
@ -353,12 +353,13 @@ class NetworkClient(
|
|||
val target = base.resolve("project").resolve("target")
|
||||
val hash = HashUtil.farmHash(target.toString().getBytes("UTF-8"))
|
||||
val bootSocketName = BootServerSocket.socketLocation(base, hash)
|
||||
val namedPipeName = BootServerSocket.namedPipeLocation(hash)
|
||||
|
||||
/*
|
||||
* For unknown reasons, linux sometimes struggles to connect to the socket in some
|
||||
* scenarios.
|
||||
*/
|
||||
var socket: Option[Socket] = bootSocketOpt(bootSocketName)
|
||||
var socket: Option[Socket] = bootSocketOpt(bootSocketName, namedPipeName)
|
||||
val term = Terminal.console
|
||||
term.exitRawMode()
|
||||
var serverStderrFile: Option[File] = None
|
||||
|
|
@ -441,7 +442,7 @@ class NetworkClient(
|
|||
if (!startServer) {
|
||||
val deadline = 5.seconds.fromNow
|
||||
while (socket.isEmpty && !deadline.isOverdue()) {
|
||||
socket = bootSocketOpt(bootSocketName)
|
||||
socket = bootSocketOpt(bootSocketName, namedPipeName)
|
||||
if (socket.isEmpty) Thread.sleep(20)
|
||||
}
|
||||
}
|
||||
|
|
@ -462,7 +463,7 @@ class NetworkClient(
|
|||
val buffer = mutable.ArrayBuffer.empty[Byte]
|
||||
while (readThreadAlive.get) {
|
||||
if (socket.isEmpty) {
|
||||
socket = bootSocketOpt(bootSocketName)
|
||||
socket = bootSocketOpt(bootSocketName, namedPipeName)
|
||||
}
|
||||
socket.foreach { s =>
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue