[gnome-video-arcade] Ensure we don't get stuck in the process_stdout_ready() loop.



commit 0fc6f0e819c471c4cbd2333d7495c56669a408f2
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Apr 11 16:33:03 2009 -0400

    Ensure we don't get stuck in the process_stdout_ready() loop.
    
    2009-04-11  Matthew Barnes  <mbarnes redhat com>
    
    	* src/gva-process.c (process_stdout_ready):
    	Break out of the loop immediately if the status is not
    	G_IO_STATUS_NORMAL.  Avoids potentially getting stuck in
    	the loop.
---
 ChangeLog         |    7 +++++++
 src/gva-process.c |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6573294..c4f7b49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-11  Matthew Barnes  <mbarnes redhat com>
+
+	* src/gva-process.c (process_stdout_ready):
+	Break out of the loop immediately if the status is not
+	G_IO_STATUS_NORMAL.  Avoids potentially getting stuck in
+	the loop.
+
 2009-04-11  Pierre Riteau  <pierre riteau gmail com>
 
 	The code reading the output of the SDLMAME child process was
diff --git a/src/gva-process.c b/src/gva-process.c
index 36197bc..328f3d7 100644
--- a/src/gva-process.c
+++ b/src/gva-process.c
@@ -181,6 +181,10 @@ process_stdout_ready (GIOChannel *channel,
                       GIOCondition condition,
                       GvaProcess *process)
 {
+        /* The logic here is tricky to get right across all operating
+         * systems due to the various ways poll() can report end-of-file.
+         * See http://www.greenend.org.uk/rjk/2001/06/poll.html. */
+
         GIOStatus status;
 
         if (condition & G_IO_IN)
@@ -198,6 +202,9 @@ process_stdout_ready (GIOChannel *channel,
                                 process->priv->stdout_lines,
                                 signals[STDOUT_READY]);
 
+                        if (status != G_IO_STATUS_NORMAL)
+                                break;
+
                         /* Continue reading as long as data is available
                          * in the internal buffer. */
                         condition =



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]