[gnome-chess/gnome-3-8] Fix massive CPU usage after starting a new game
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/gnome-3-8] Fix massive CPU usage after starting a new game
- Date: Sat, 25 May 2013 19:29:21 +0000 (UTC)
commit b7cf27919f1dc2c5130e6598ada72ff5da787c3c
Author: Michael Catanzaro <mike catanzaro gmail com>
Date: Sat May 25 13:41:11 2013 -0500
Fix massive CPU usage after starting a new game
After ending a game against a chess engine, CPU usage would skyrocket
since the IOWatch on the engine's stdout wasn't removed from the main
loop. Remedy this.
https://bugzilla.gnome.org/show_bug.cgi?id=578130#c7
(cherry picked from commit f770ab7e90b1952a6b92e3be14d21a81a08bae5b)
src/chess-engine.vala | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/chess-engine.vala b/src/chess-engine.vala
index c1f07a5..1283313 100644
--- a/src/chess-engine.vala
+++ b/src/chess-engine.vala
@@ -7,6 +7,7 @@ public class ChessEngine : Object
private int stdin_fd;
private int stderr_fd;
private IOChannel stdout_channel;
+ private uint stdout_watch_id;
protected virtual void process_input (char[] data) {}
@@ -58,7 +59,7 @@ public class ChessEngine : Object
{
stderr.printf ("Failed to set input from chess engine to non-blocking: %s", e.message);
}
- stdout_channel.add_watch (IOCondition.IN, read_cb);
+ stdout_watch_id = stdout_channel.add_watch (IOCondition.IN, read_cb);
starting ();
@@ -88,6 +89,9 @@ public class ChessEngine : Object
public void stop ()
{
+ if (stdout_watch_id > 0)
+ Source.remove (stdout_watch_id);
+
if (pid != 0)
Posix.kill (pid, Posix.SIGTERM);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]