summaryrefslogtreecommitdiff
path: root/src/input/pnm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/pnm.c')
-rw-r--r--src/input/pnm.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/input/pnm.c b/src/input/pnm.c
index d0a9b0c9e..48aac07da 100644
--- a/src/input/pnm.c
+++ b/src/input/pnm.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: pnm.c,v 1.11 2003/01/31 14:06:17 miguelfreitas Exp $
+ * $Id: pnm.c,v 1.12 2003/02/05 00:10:30 miguelfreitas Exp $
*
* pnm protocol implementation
* based upon code from joschka
@@ -265,26 +265,32 @@ static ssize_t rm_read(int fd, void *buf, size_t count) {
while (total < count) {
- fd_set rset;
- struct timeval timeout;
-
- FD_ZERO (&rset);
- FD_SET (fd, &rset);
-
- timeout.tv_sec = 3;
- timeout.tv_usec = 0;
-
- if (select (fd+1, &rset, NULL, NULL, &timeout) <= 0) {
- return -1;
- }
-
ret=read (fd, ((uint8_t*)buf)+total, count-total);
- if (ret<=0) {
+ if (ret<0) {
+ if(errno == EAGAIN) {
+ fd_set rset;
+ struct timeval timeout;
+
+ FD_ZERO (&rset);
+ FD_SET (fd, &rset);
+
+ timeout.tv_sec = 30;
+ timeout.tv_usec = 0;
+
+ if (select (fd+1, &rset, NULL, NULL, &timeout) <= 0) {
+ return -1;
+ }
+ continue;
+ }
+
printf ("input_pnm: read error.\n");
return ret;
} else
total += ret;
+
+ /* end of stream */
+ if (!ret) break;
}
return total;