session-lock: fix assertion failure due to race
There's currently a potential race in the implementation that can be hit during unlocking. This is not a security vulnerability, but it does cause the compositor to crash due to a failed assertion. This commit simplifies the code and fixes the race as well as tightening up the assertions around this state/control flow even further.
This commit is contained in:
parent
df2fc30238
commit
f511a34ded
@ -530,7 +530,7 @@ fn handlePresent(
|
|||||||
const self = @fieldParentPtr(Self, "present", listener);
|
const self = @fieldParentPtr(Self, "present", listener);
|
||||||
|
|
||||||
switch (self.lock_render_state) {
|
switch (self.lock_render_state) {
|
||||||
.unlocked => return,
|
.unlocked => assert(server.lock_manager.state != .locked),
|
||||||
.pending_blank, .pending_lock_surface => {
|
.pending_blank, .pending_lock_surface => {
|
||||||
if (!event.presented) {
|
if (!event.presented) {
|
||||||
self.lock_render_state = .unlocked;
|
self.lock_render_state = .unlocked;
|
||||||
@ -548,7 +548,7 @@ fn handlePresent(
|
|||||||
server.lock_manager.maybeLock();
|
server.lock_manager.maybeLock();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.blanked, .lock_surface => unreachable,
|
.blanked, .lock_surface => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +98,18 @@ pub fn renderOutput(output: *Output) void {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (server.lock_manager.state == .locked) {
|
||||||
|
switch (output.lock_render_state) {
|
||||||
|
.unlocked, .pending_blank, .pending_lock_surface => unreachable,
|
||||||
|
.blanked, .lock_surface => {},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (output.lock_surface == null) {
|
if (output.lock_surface == null) {
|
||||||
output.lock_render_state = .pending_blank;
|
output.lock_render_state = .pending_blank;
|
||||||
} else {
|
} else {
|
||||||
output.lock_render_state = .pending_lock_surface;
|
output.lock_render_state = .pending_lock_surface;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user