aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@src.gnome.org>2001-12-18 03:50:35 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-12-18 03:50:35 +0800
commit1b8e8b861ea517a296ff4980f3c988926dc41586 (patch)
treed5daaa4df4ef2b9f188b13c7ec9e77295f8ed20d /composer/e-msg-composer.c
parent9ed571f9de3e7f49e068071affb4c9204ba0527d (diff)
downloadgsoc2013-evolution-1b8e8b861ea517a296ff4980f3c988926dc41586.tar.gz
gsoc2013-evolution-1b8e8b861ea517a296ff4980f3c988926dc41586.tar.zst
gsoc2013-evolution-1b8e8b861ea517a296ff4980f3c988926dc41586.zip
ack, fix a small logic bug.
svn path=/trunk/; revision=15131
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c27
1 files 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;
}