diff options
author | Not Zed <NotZed@Ximian.com> | 2001-02-05 15:15:50 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-02-05 15:15:50 +0800 |
commit | 764b9e26b00bf10e474c2684f74c8c9497de30d9 (patch) | |
tree | fd63a1bdf0a6fc0e51da474a47dcf628d9325655 /camel/camel-stream-fs.c | |
parent | f1f97ce865d29370b45ce08380cd56ab24f26a78 (diff) | |
download | gsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.tar.gz gsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.tar.zst gsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.zip |
Revert jeff's earlier change, the change below is the more-correct fix.
2001-02-05 Not Zed <NotZed@Ximian.com>
* camel-stream-filter.c (do_write): Revert jeff's earlier change,
the change below is the more-correct fix. All his was doing was
ignoring the return code & looping actually :)
* camel-stream-fs.c (stream_write): Since we are non-blocking on
the outgoing fd, keep looping if writing out large blocks, so we
can keep checking for cancel, etc.
svn path=/trunk/; revision=7966
Diffstat (limited to 'camel/camel-stream-fs.c')
-rw-r--r-- | camel/camel-stream-fs.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index 599d06cf7a..69947b6cc8 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -273,7 +273,7 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) cancel_fd = camel_cancel_fd(NULL); if (cancel_fd == -1) { do { - v = write (stream_fs->fd, buffer, n); + v = write (stream_fs->fd, buffer+written, n-written); if (v > 0) written += v; } while (v == -1 && errno == EINTR); @@ -283,20 +283,22 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) flags = fcntl(stream_fs->fd, F_GETFL); fcntl(stream_fs->fd, F_SETFL, flags | O_NONBLOCK); - FD_ZERO(&rdset); - FD_ZERO(&wrset); - FD_SET(stream_fs->fd, &wrset); - FD_SET(cancel_fd, &rdset); - fdmax = MAX(stream_fs->fd, cancel_fd)+1; - select(fdmax, &rdset, &wrset, 0, NULL); - if (FD_ISSET(cancel_fd, &rdset)) { - fcntl(stream_fs->fd, F_SETFL, flags); - errno = EINTR; - return -1; - } - v = write(stream_fs->fd, buffer, n); - if (v>0) - written += v; + fdmax = MAX(stream_fs->fd, cancel_fd)+1; + do { + FD_ZERO(&rdset); + FD_ZERO(&wrset); + FD_SET(stream_fs->fd, &wrset); + FD_SET(cancel_fd, &rdset); + select(fdmax, &rdset, &wrset, 0, NULL); + if (FD_ISSET(cancel_fd, &rdset)) { + fcntl(stream_fs->fd, F_SETFL, flags); + errno = EINTR; + return -1; + } + v = write(stream_fs->fd, buffer+written, n-written); + if (v>0) + written += v; + } while (v != -1 && written < n); fcntl(stream_fs->fd, F_SETFL, flags); } |