diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 10 | ||||
-rw-r--r-- | camel/camel-stream-filter.c | 12 | ||||
-rw-r--r-- | camel/camel-stream-fs.c | 32 |
3 files changed, 31 insertions, 23 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index a7da8cda01..82a5445bcb 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,13 @@ +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. + 2001-02-02 Not Zed <NotZed@Ximian.com> * camel-folder-thread.c (camel_folder_thread_messages_new): When diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c index 1189262ddc..866c8d2416 100644 --- a/camel/camel-stream-filter.c +++ b/camel/camel-stream-filter.c @@ -269,7 +269,6 @@ do_write (CamelStream *stream, const char *buf, size_t n) CamelStreamFilter *filter = (CamelStreamFilter *)stream; struct _CamelStreamFilterPrivate *p = _PRIVATE(filter); struct _filter *f; - ssize_t w, written = 0; int presize; char *buffer = (char *)buf; size_t len = n; @@ -292,13 +291,10 @@ do_write (CamelStream *stream, const char *buf, size_t n) f = f->next; } - - do { - w = camel_stream_write (filter->source, buffer + written, len - written); - if (w > 0) - written += w; - } while (written < len); - + + if (camel_stream_write(filter->source, buffer, len) != len) + return -1; + return n; } 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); } |