mirror of https://github.com/sbt/sbt.git
Merge pull request #3932 from dwijnand/max-socket-length
Handle very long socket file paths on UNIX
This commit is contained in:
commit
8546fc7ea6
|
|
@ -60,9 +60,16 @@ private[sbt] object Server {
|
||||||
// Named pipe already has an exclusive lock.
|
// Named pipe already has an exclusive lock.
|
||||||
addServerError(new Win32NamedPipeServerSocket(pipeName))
|
addServerError(new Win32NamedPipeServerSocket(pipeName))
|
||||||
case ConnectionType.Local =>
|
case ConnectionType.Local =>
|
||||||
tryClient(new UnixDomainSocket(socketfile.getAbsolutePath))
|
val maxSocketLength = new UnixDomainSocketLibrary.SockaddrUn().sunPath.length - 1
|
||||||
|
val path = socketfile.getAbsolutePath
|
||||||
|
if (path.length > maxSocketLength)
|
||||||
|
sys.error("socket file absolute path too long; " +
|
||||||
|
"either switch to another connection type " +
|
||||||
|
"or define a short \"SBT_GLOBAL_SERVER_DIR\" value. " +
|
||||||
|
s"Current path: ${path}")
|
||||||
|
tryClient(new UnixDomainSocket(path))
|
||||||
prepareSocketfile()
|
prepareSocketfile()
|
||||||
addServerError(new UnixDomainServerSocket(socketfile.getAbsolutePath))
|
addServerError(new UnixDomainServerSocket(path))
|
||||||
case ConnectionType.Tcp =>
|
case ConnectionType.Tcp =>
|
||||||
tryClient(new Socket(InetAddress.getByName(host), port))
|
tryClient(new Socket(InetAddress.getByName(host), port))
|
||||||
addServerError(new ServerSocket(port, 50, InetAddress.getByName(host)))
|
addServerError(new ServerSocket(port, 50, InetAddress.getByName(host)))
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,10 @@ private[sbt] final class CommandExchange {
|
||||||
if (server.isEmpty && firstInstance.get) {
|
if (server.isEmpty && firstInstance.get) {
|
||||||
val portfile = s.baseDir / "project" / "target" / "active.json"
|
val portfile = s.baseDir / "project" / "target" / "active.json"
|
||||||
val h = Hash.halfHashString(IO.toURI(portfile).toString)
|
val h = Hash.halfHashString(IO.toURI(portfile).toString)
|
||||||
val tokenfile = BuildPaths.getGlobalBase(s) / "server" / h / "token.json"
|
val serverDir =
|
||||||
val socketfile = BuildPaths.getGlobalBase(s) / "server" / h / "sock"
|
sys.env get "SBT_GLOBAL_SERVER_DIR" map file getOrElse BuildPaths.getGlobalBase(s) / "server"
|
||||||
|
val tokenfile = serverDir / h / "token.json"
|
||||||
|
val socketfile = serverDir / h / "sock"
|
||||||
val pipeName = "sbt-server-" + h
|
val pipeName = "sbt-server-" + h
|
||||||
val connection = ServerConnection(
|
val connection = ServerConnection(
|
||||||
connectionType,
|
connectionType,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue