aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-02-05 15:15:50 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-02-05 15:15:50 +0800
commit764b9e26b00bf10e474c2684f74c8c9497de30d9 (patch)
treefd63a1bdf0a6fc0e51da474a47dcf628d9325655 /camel
parentf1f97ce865d29370b45ce08380cd56ab24f26a78 (diff)
downloadgsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.tar
gsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.tar.gz
gsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.tar.bz2
gsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.tar.lz
gsoc2013-evolution-764b9e26b00bf10e474c2684f74c8c9497de30d9.tar.xz
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')
-rw-r--r--camel/ChangeLog10
-rw-r--r--camel/camel-stream-filter.c12
-rw-r--r--camel/camel-stream-fs.c32
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);
}