river: don't extend timeout on transaction preemption

This avoids locking up the compositor if a client is unresponsive and
the user continuously initiates new transactions through their actions.
This commit is contained in:
Isaac Freund 2021-06-08 15:18:45 +00:00
parent e90474657f
commit 68267a4cfe
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -282,6 +282,7 @@ pub fn startTransaction(self: *Self) void {
// If a new transaction is started while another is in progress, we need // If a new transaction is started while another is in progress, we need
// to reset the pending count to 0 and clear serials from the views // to reset the pending count to 0 and clear serials from the views
const preempting = self.pending_configures > 0;
self.pending_configures = 0; self.pending_configures = 0;
// Iterate over all views of all outputs // Iterate over all views of all outputs
@ -317,16 +318,18 @@ pub fn startTransaction(self: *Self) void {
} }
if (self.pending_configures > 0) { if (self.pending_configures > 0) {
std.log.scoped(.transaction).debug( std.log.scoped(.transaction).debug("started transaction with {} pending configure(s)", .{
"started transaction with {} pending configure(s)", self.pending_configures,
.{self.pending_configures}, });
);
// Set timeout to 200ms // Timeout the transaction after 200ms. If we are preempting an
self.transaction_timer.timerUpdate(200) catch { // already in progress transaction, don't extend the timeout.
std.log.scoped(.transaction).err("failed to update timer", .{}); if (!preempting) {
self.commitTransaction(); self.transaction_timer.timerUpdate(200) catch {
}; std.log.scoped(.transaction).err("failed to update timer", .{});
self.commitTransaction();
};
}
} else { } else {
// No views need configures, clear the current timer in case we are // No views need configures, clear the current timer in case we are
// interrupting another transaction and commit. // interrupting another transaction and commit.