mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Fixed pseudo-racing condition in package relay of switches and co. that could increase the time it took to resend a packet. Closes #327.
This commit is contained in:
parent
8f1cac9f9a
commit
7d62262984
@ -39,14 +39,19 @@ trait Hub extends traits.Environment with SidedEnvironment {
|
||||
else if (queue.nonEmpty) queue.synchronized {
|
||||
val (sourceSide, packet) = queue.dequeue()
|
||||
relayPacket(sourceSide, packet)
|
||||
relayCooldown = relayDelay
|
||||
if (queue.nonEmpty) {
|
||||
relayCooldown = relayDelay
|
||||
}
|
||||
else {
|
||||
relayCooldown = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected def tryEnqueuePacket(sourceSide: ForgeDirection, packet: Packet) = queue.synchronized {
|
||||
if (packet.ttl > 0 && queue.size < maxQueueSize) {
|
||||
queue += sourceSide -> packet.hop()
|
||||
if (relayCooldown <= 0) {
|
||||
if (relayCooldown < 0) {
|
||||
relayCooldown = relayDelay
|
||||
}
|
||||
true
|
||||
|
Loading…
x
Reference in New Issue
Block a user