Hi,

Marcelo wrote:
Sorry, I need some rationale here...

The original code handled two different error conditions.  One is the
case where the read call was interrupted and the other one is "the
rest of them".  In the first case the original code simply tries
again.  In the second case the original code aborts and goes back to
select to wait for more data.  The new code doesn't retry on
interrupt.

I am assuming that the original code had to retry because it runs in a
context where it's feasable to be interrupted by a signal (because the
client code sets up a signal, for example).  So, why doesn't the new
code?

Marcelo

Maybe this one can be add.

MIchael
>From 3ff0a54a6db44a35f13cd62234dcd1496f6c533a Mon Sep 17 00:00:00 2001
From: Michael Trimarchi <[email protected]>
Date: Tue, 3 Mar 2009 17:41:14 +0100
Subject: [PATCH] While on the EINTR condition.

---
 gps_freerunner.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gps_freerunner.c b/gps_freerunner.c
index a907345..04cad99 100644
--- a/gps_freerunner.c
+++ b/gps_freerunner.c
@@ -993,8 +993,9 @@ gps_state_thread( void*  arg )
                 {
                     char  buff[512];
                     int  nn, ret;
-
-                    ret = read( fd, buff, sizeof(buff) );
+                    do {
+                        ret = read( fd, buff, sizeof(buff) );
+                    } while (ret < 0 && errno == EINTR);
                     if (ret > 0)
                         for (nn = 0; nn < ret; nn++)
                             nmea_reader_addc( reader, buff[nn] );
-- 
1.5.6.5

_______________________________________________
android-freerunner mailing list
[email protected]
http://android.koolu.org/listinfo.cgi/android-freerunner-koolu.org

Reply via email to