mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Keep a spill without an acknowledgement asked, so a failed resume count still fails
This commit is contained in:
1 parent
48f587bb41
commit
fbf1788647
2 files changed
+32
-3
No files matched your search
@@ -346,9 +346,11 @@ internal class SessionSuspendController(
|
||||
}
|
||||
// A process that answered 0 paged out to zram instead and has no spill to release. One whose handler
|
||||
// started (its acknowledgement is there, still empty) may still be writing: it is waited for like a
|
||||
// spilled one, its acknowledgement kept. One with no acknowledgement at all has no handler and was never held.
|
||||
// spilled one, its acknowledgement kept. One with no acknowledgement may have no handler, or one that has
|
||||
// not got that far: it is not waited for, but stays asked, so a resume count that cannot be written still
|
||||
// fails (a late spill waits for any count other than the one it was asked with).
|
||||
val unanswered = targets.filter { (acks[it] ?: -1L) < 0L && ackFile(control, "ack", it).exists() && !isGone(it) }
|
||||
spillAsked = spillAsked.filterNot { it in targets && (acks[it] == 0L || !ackFile(control, "ack", it).exists()) }
|
||||
spillAsked = spillAsked.filterNot { acks[it] == 0L }
|
||||
spilledTargets = (spilledTargets + written + unanswered).distinct()
|
||||
pagedOutTargets = (pagedOutTargets + targets.filter { acks[it] == 0L }).distinct()
|
||||
targets.filterNot { it in unanswered }.forEach { ackFile(control, "ack", it).delete() }
|
||||
|
||||
@@ -210,11 +210,31 @@ class SessionSuspendControllerTest {
|
||||
fixture.control.writeText("0")
|
||||
fixture.handlerReplaced = true
|
||||
fixture.controller.freeze(pageOut = true, spill = true) { }
|
||||
File(fixture.control.parentFile, ".dd-zram.resume.new").mkdirs()
|
||||
fixture.controller.resume { assertTrue(it) }
|
||||
assertTrue(fixture.restores.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun aSpillThatStartsAfterTheWaitFailsAResumeCountThatCannotBeWritten() {
|
||||
val fixture = fixture(17)
|
||||
fixture.control.writeText("0")
|
||||
fixture.handlerReplaced = true
|
||||
fixture.controller.freeze(pageOut = true, spill = true) { }
|
||||
File(fixture.control.parentFile, ".dd-zram.resume.new").mkdirs()
|
||||
fixture.controller.resume { assertFalse(it) }
|
||||
}
|
||||
|
||||
@Test fun aSpillThatStartsAfterTheWaitIsReleasedByTheNextCount() {
|
||||
val fixture = fixture(17)
|
||||
fixture.control.writeText("0")
|
||||
fixture.handlerReplaced = true
|
||||
fixture.controller.freeze(pageOut = true, spill = true) { }
|
||||
fixture.startLateSpill()
|
||||
fixture.controller.resume { assertTrue(it) }
|
||||
fixture.advance(1_000L)
|
||||
assertTrue(File(fixture.control.parentFile, ".dd-zram.restored.$GAME").isFile)
|
||||
assertTrue(fixture.game.threads.none { it.state == 't' || it.state == 'T' })
|
||||
}
|
||||
|
||||
@Test fun aLateFallbackToZramIsReadBack() {
|
||||
val fixture = fixture(17)
|
||||
fixture.control.writeText("0")
|
||||
@@ -745,6 +765,13 @@ class SessionSuspendControllerTest {
|
||||
|
||||
fun advance(millis: Long) = sleep(millis)
|
||||
|
||||
// the handler takes the spill request only now, after the controller stopped waiting for it
|
||||
fun startLateSpill() {
|
||||
handlerReplaced = false
|
||||
spilling = true
|
||||
File(control.parentFile, "${control.name}.ack.$GAME").writeText("")
|
||||
}
|
||||
|
||||
private fun sleep(millis: Long) {
|
||||
now += millis
|
||||
if (spilling && !spillSilent) {
|
||||
|
||||
Reference in new issue
Block a user