diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-10-27 06:52:15 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-10-27 06:52:15 +0800 |
commit | 7ef153696bb448cce02a2f0b70799d0db663b3b6 (patch) | |
tree | 98cb3d9db606c951384a43f6dc74cc4c28726d89 /camel | |
parent | 013f8d56e85c162233e034f4eed7c5f050d3f68a (diff) | |
download | gsoc2013-evolution-7ef153696bb448cce02a2f0b70799d0db663b3b6.tar.gz gsoc2013-evolution-7ef153696bb448cce02a2f0b70799d0db663b3b6.tar.zst gsoc2013-evolution-7ef153696bb448cce02a2f0b70799d0db663b3b6.zip |
Check for EWOULDBLOCK too? (stream_read): Same.
2001-10-26 Jeffrey Stedfast <fejj@ximian.com>
* camel-tcp-stream-raw.c (stream_write): Check for EWOULDBLOCK too?
(stream_read): Same.
* providers/imap/camel-imap-message-cache.c
(camel_imap_message_cache_get): Lets try putting a
camel_stream_reset() here. Logic being that the stream may have
been read from since it was cached and thus our caller may try
reading from it and get no data from it since it is already at the
EOS. This may fix bug #12943.
svn path=/trunk/; revision=14179
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 3 | ||||
-rw-r--r-- | camel/camel-tcp-stream-raw.c | 34 |
2 files changed, 32 insertions, 5 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index c85a10811c..98315fcf8d 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,8 @@ 2001-10-26 Jeffrey Stedfast <fejj@ximian.com> + * camel-tcp-stream-raw.c (stream_write): Check for EWOULDBLOCK too? + (stream_read): Same. + * providers/imap/camel-imap-message-cache.c (camel_imap_message_cache_get): Lets try putting a camel_stream_reset() here. Logic being that the stream may have diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c index b320af32ab..d019b4c639 100644 --- a/camel/camel-tcp-stream-raw.c +++ b/camel/camel-tcp-stream-raw.c @@ -27,6 +27,7 @@ #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> +#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> @@ -113,25 +114,48 @@ static ssize_t tcp_write (int fd, const char *buffer, size_t buflen) { size_t len = buflen; + ssize_t nwritten; int val; + if (buflen == 0) + return 0; + val = 1 + (int) (10.0 * rand () / (RAND_MAX + 1.0)); switch (val) { case 1: + printf ("tcp_write (%d, ..., %d): (-1) EINTR\n", fd, buflen); errno = EINTR; return -1; +#if 0 + /* seems that if we set errno to either EAGAIN or + EWOULDBLOCK, libc's pthread crashes...wacky */ case 2: + printf ("tcp_write (%d, ..., %d): (-1) EAGAIN\n", fd, buflen); errno = EAGAIN; return -1; case 3: + printf ("tcp_write (%d, ..., %d): (-1) EWOULDBLOCK\n", fd, buflen); + errno = EWOULDBLOCK; + return -1; +#endif case 4: case 5: + case 6: len = 1 + (size_t) (buflen * rand () / (RAND_MAX + 1.0)); len = MIN (len, buflen); /* fall through... */ default: - return write (fd, buffer, len); + printf ("tcp_write (%d, ..., %d): (%d) '%.*s'", fd, buflen, len, (int) len, buffer); + nwritten = write (fd, buffer, len); + if (nwritten < 0) + printf (" errno => %s\n", g_strerror (errno)); + else if (nwritten < len) + printf (" only wrote %d bytes\n", nwritten); + else + printf ("\n"); + + return nwritten; } } @@ -172,7 +196,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n) if (cancel_fd == -1) { do { nread = read (tcp_stream_raw->sockfd, buffer, n); - } while (nread == -1 && (errno == EINTR || errno == EAGAIN)); + } while (nread == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); } else { int error, flags, fdmax; fd_set rdset; @@ -196,7 +220,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n) do { nread = read (tcp_stream_raw->sockfd, buffer, n); } while (nread == -1 && errno == EINTR); - } while (nread == -1 && errno == EAGAIN); + } while (nread == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)); error = errno; fcntl (tcp_stream_raw->sockfd, F_SETFL, flags); @@ -223,7 +247,7 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) do { do { w = write (tcp_stream_raw->sockfd, buffer + written, n - written); - } while (w == -1 && (errno == EINTR || errno == EAGAIN)); + } while (w == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); if (w > 0) written += w; @@ -254,7 +278,7 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) } while (w == -1 && errno == EINTR); if (w == -1) { - if (errno == EAGAIN) + if (errno == EAGAIN || errno == EWOULDBLOCK) continue; } else written += w; |