From 1b8e8b861ea517a296ff4980f3c988926dc41586 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 17 Dec 2001 19:50:35 +0000 Subject: ack, fix a small logic bug. svn path=/trunk/; revision=15131 --- composer/e-msg-composer.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index f2112f67c2..35be879162 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -674,38 +674,33 @@ read_file_content (int fd) char *body, buf[4096]; struct timeval tv; fd_set rdset; + int retval; ssize_t n; - int flags; g_return_val_if_fail (fd > 0, NULL); contents = g_byte_array_new (); - flags = fcntl (fd, F_GETFL); - fcntl (fd, F_SETFL, flags | O_NONBLOCK); - FD_ZERO (&rdset); FD_SET (fd, &rdset); - do { - tv.tv_sec = 0; - tv.tv_usec = 10; - - n = -1; - select (fd + 1, &rdset, NULL, NULL, &tv); - if (FD_ISSET (fd, &rdset)) { - n = read (fd, buf, 4096); + tv.tv_sec = 0; + tv.tv_usec = 10; + + retval = select (fd + 1, &rdset, NULL, NULL, &tv); + if (retval) { + n = 0; + while (n >= 0 || errno == EINTR) { + n = read (fd, buf, sizeof (buf)); if (n > 0) g_byte_array_append (contents, buf, n); } - } while (n != -1); - - fcntl (fd, F_SETFL, flags); + } g_byte_array_append (contents, "", 1); body = (contents->len == 1) ? NULL : (char *) contents->data; - g_byte_array_free (contents, body != NULL); + g_byte_array_free (contents, body == NULL); return body; } -- cgit v1.2.3