From f74417fca812a029732742fcffa433997f91e362 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 15 Oct 2001 22:10:19 +0000 Subject: Save the errno before calling fcntl so fcntl doesn't overwrite errno in 2001-10-15 Jeffrey Stedfast * camel-stream-fs.c (stream_read): Save the errno before calling fcntl so fcntl doesn't overwrite errno in case of a previous error. (stream_write): Same. svn path=/trunk/; revision=13687 --- camel/ChangeLog | 7 +++++++ camel/camel-stream-fs.c | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 91f1d02e5e..d8fd6eaaeb 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,10 @@ +2001-10-15 Jeffrey Stedfast + + * camel-stream-fs.c (stream_read): Save the errno before calling + fcntl so fcntl doesn't overwrite errno in case of a previous + error. + (stream_write): Same. + 2001-10-13 Jeffrey Stedfast * providers/smtp/camel-smtp-transport.c (smtp_data): Replace the diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index f7c5900325..64e4912785 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -232,7 +232,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n) } while (nread == -1 && errno == EINTR); } else { fd_set rdset; - int flags, fdmax; + int error, flags, fdmax; flags = fcntl(stream_fs->fd, F_GETFL); fcntl(stream_fs->fd, F_SETFL, flags | O_NONBLOCK); @@ -247,7 +247,9 @@ stream_read (CamelStream *stream, char *buffer, size_t n) return -1; } nread = read(stream_fs->fd, buffer, n); + error = errno; fcntl(stream_fs->fd, F_SETFL, flags); + errno = error; } if (nread > 0) @@ -283,7 +285,7 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) } while (v == -1 && errno == EINTR); } else { fd_set rdset, wrset; - int flags, fdmax; + int error, flags, fdmax; flags = fcntl(stream_fs->fd, F_GETFL); fcntl(stream_fs->fd, F_SETFL, flags | O_NONBLOCK); @@ -303,7 +305,9 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) if (v>0) written += v; } while (v != -1 && written < n); + error = errno; fcntl(stream_fs->fd, F_SETFL, flags); + errno = error; } if (written > 0) -- cgit v1.2.3