mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-09 23:38:04 -04:00
fix #3013
This commit is contained in:
parent
9335ba9a72
commit
1b070f4e2a
@ -1,6 +1,7 @@
|
|||||||
## Fixes/improvements
|
## Fixes/improvements
|
||||||
|
|
||||||
* [#3620] Fixed OC 1.8.0+ regression involving API arguments and numbers.
|
* [#3620] Fixed OC 1.8.0+ regression involving API arguments and numbers.
|
||||||
|
* [#3013] Fixed rare server-side deadlock when sending disk activity update packets.
|
||||||
|
|
||||||
## OpenOS fixes/improvements
|
## OpenOS fixes/improvements
|
||||||
|
|
||||||
@ -9,4 +10,4 @@
|
|||||||
|
|
||||||
## List of contributors
|
## List of contributors
|
||||||
|
|
||||||
asie, Possseidon
|
asie, ds84182, Possseidon
|
||||||
|
@ -1401,6 +1401,10 @@ opencomputers {
|
|||||||
# operation, it will block the computer for a duration matching the
|
# operation, it will block the computer for a duration matching the
|
||||||
# limit set in this config option.
|
# limit set in this config option.
|
||||||
transposerFluidTransferRate=4000
|
transposerFluidTransferRate=4000
|
||||||
|
|
||||||
|
# Disk activity update packet delay specified in milliseconds.
|
||||||
|
# If set to -1, no disk activity update packets are sent.
|
||||||
|
diskActivityPacketDelay=500
|
||||||
}
|
}
|
||||||
|
|
||||||
# Settings for mod integration (the mod previously known as OpenComponents).
|
# Settings for mod integration (the mod previously known as OpenComponents).
|
||||||
|
@ -478,6 +478,9 @@ class Settings(val config: Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val bitbltCost: Double = if (config.hasPath("gpu.bitbltCost")) config.getDouble("gpu.bitbltCost") else 0.5
|
val bitbltCost: Double = if (config.hasPath("gpu.bitbltCost")) config.getDouble("gpu.bitbltCost") else 0.5
|
||||||
|
|
||||||
|
// >= 1.8.2
|
||||||
|
val diskActivityPacketDelay: Int = config.getInt("misc.diskActivityPacketDelay") max -1
|
||||||
}
|
}
|
||||||
|
|
||||||
object Settings {
|
object Settings {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package li.cil.oc.server
|
package li.cil.oc.server
|
||||||
|
|
||||||
import li.cil.oc.api
|
import li.cil.oc.{Settings, api}
|
||||||
import li.cil.oc.api.event.{NetworkActivityEvent, FileSystemAccessEvent}
|
import li.cil.oc.api.event.{FileSystemAccessEvent, NetworkActivityEvent}
|
||||||
import li.cil.oc.api.network.EnvironmentHost
|
import li.cil.oc.api.network.EnvironmentHost
|
||||||
import li.cil.oc.api.network.Node
|
import li.cil.oc.api.network.Node
|
||||||
import li.cil.oc.common._
|
import li.cil.oc.common._
|
||||||
@ -20,6 +20,7 @@ import net.minecraft.world.World
|
|||||||
import net.minecraftforge.common.MinecraftForge
|
import net.minecraftforge.common.MinecraftForge
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
||||||
object PacketSender {
|
object PacketSender {
|
||||||
@ -125,19 +126,22 @@ object PacketSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Avoid spamming the network with disk activity notices.
|
// Avoid spamming the network with disk activity notices.
|
||||||
val fileSystemAccessTimeouts = mutable.WeakHashMap.empty[Node, mutable.Map[String, Long]]
|
private val fileSystemAccessTimeouts = mutable.WeakHashMap.empty[Node, ConcurrentHashMap[String, Long]]
|
||||||
|
|
||||||
def sendFileSystemActivity(node: Node, host: EnvironmentHost, name: String) = fileSystemAccessTimeouts.synchronized {
|
def sendFileSystemActivity(node: Node, host: EnvironmentHost, name: String) = {
|
||||||
fileSystemAccessTimeouts.get(node) match {
|
val diskActivityPacketDelay = Settings.get.diskActivityPacketDelay
|
||||||
case Some(hostTimeouts) if hostTimeouts.getOrElse(name, 0L) > System.currentTimeMillis() => // Cooldown.
|
if (diskActivityPacketDelay >= 0) {
|
||||||
case _ =>
|
val hostTimeouts = fileSystemAccessTimeouts.synchronized {
|
||||||
|
fileSystemAccessTimeouts.getOrElseUpdate(node, new ConcurrentHashMap[String, Long](16, 0.75f, Settings.get.threads))
|
||||||
|
}
|
||||||
|
if (hostTimeouts.getOrDefault(name, 0L) <= System.currentTimeMillis()) {
|
||||||
val event = host match {
|
val event = host match {
|
||||||
case t: net.minecraft.tileentity.TileEntity => new FileSystemAccessEvent.Server(name, t, node)
|
case t: net.minecraft.tileentity.TileEntity => new FileSystemAccessEvent.Server(name, t, node)
|
||||||
case _ => new FileSystemAccessEvent.Server(name, host.world, host.xPosition, host.yPosition, host.zPosition, node)
|
case _ => new FileSystemAccessEvent.Server(name, host.world, host.xPosition, host.yPosition, host.zPosition, node)
|
||||||
}
|
}
|
||||||
MinecraftForge.EVENT_BUS.post(event)
|
MinecraftForge.EVENT_BUS.post(event)
|
||||||
if (!event.isCanceled) {
|
if (!event.isCanceled) {
|
||||||
fileSystemAccessTimeouts.getOrElseUpdate(node, mutable.Map.empty) += name -> (System.currentTimeMillis() + 500)
|
hostTimeouts.put(name, System.currentTimeMillis() + diskActivityPacketDelay)
|
||||||
|
|
||||||
val pb = new SimplePacketBuilder(PacketType.FileSystemActivity)
|
val pb = new SimplePacketBuilder(PacketType.FileSystemActivity)
|
||||||
|
|
||||||
@ -157,8 +161,9 @@ object PacketSender {
|
|||||||
|
|
||||||
pb.sendToPlayersNearHost(host, Option(64))
|
pb.sendToPlayersNearHost(host, Option(64))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def sendNetworkActivity(node: Node, host: EnvironmentHost) = {
|
def sendNetworkActivity(node: Node, host: EnvironmentHost) = {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user