aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-tcp-stream-ssl.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-03-14 12:31:58 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-03-14 12:31:58 +0800
commit24bb645439520575907f9e1ec49126608f26c19c (patch)
tree71ee560ccf0de269b28775a08d9de4b5c98877ba /camel/camel-tcp-stream-ssl.c
parentbf5c7e12fcb41d013b5bdb194946075a0589ea9e (diff)
downloadgsoc2013-evolution-24bb645439520575907f9e1ec49126608f26c19c.tar.gz
gsoc2013-evolution-24bb645439520575907f9e1ec49126608f26c19c.tar.zst
gsoc2013-evolution-24bb645439520575907f9e1ec49126608f26c19c.zip
Made cancellable. (stream_write): Same. (stream_connect): Removed checks
2001-03-13 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-raw.c (stream_read): Made cancellable. (stream_write): Same. (stream_connect): Removed checks for DIVINE_INTERVENTION as the code worked fine. * camel-tcp-stream-ssl.c (stream_write): get rid of 'w' as it wasn't really needed. (set_errno): New function to set errno based on the NSPR error code. (stream_read): If an error occured, call set_errno(). (stream_write): Same. svn path=/trunk/; revision=8701
Diffstat (limited to 'camel/camel-tcp-stream-ssl.c')
-rw-r--r--camel/camel-tcp-stream-ssl.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 15b907845a..8d4ac47746 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -142,6 +142,23 @@ camel_tcp_stream_ssl_new (CamelSession *session, const char *expected_host)
return CAMEL_STREAM (stream);
}
+static void
+set_errno (int code)
+{
+ /* FIXME: this should handle more. */
+ switch (code) {
+ case PR_IO_TIMEOUT_ERROR:
+ errno = EAGAIN;
+ break;
+ case PR_IO_ERROR:
+ errno = EIO;
+ break;
+ default:
+ /* what to set by default?? */
+ errno = EINTR;
+ }
+}
+
static ssize_t
stream_read (CamelStream *stream, char *buffer, size_t n)
{
@@ -152,6 +169,9 @@ stream_read (CamelStream *stream, char *buffer, size_t n)
nread = PR_Read (tcp_stream_ssl->sockfd, buffer, n);
} while (nread == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
+ if (nread == -1)
+ set_errno (PR_GetError ());
+
return nread;
}
@@ -159,18 +179,16 @@ static ssize_t
stream_write (CamelStream *stream, const char *buffer, size_t n)
{
CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
- ssize_t w, written = 0;
+ ssize_t written;
do {
- w = PR_Write (tcp_stream_ssl->sockfd, buffer, n);
- if (w > 0)
- written += w;
- } while (w == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
+ written = PR_Write (tcp_stream_ssl->sockfd, buffer, n);
+ } while (written == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
- if (w == -1)
- return -1;
- else
- return written;
+ if (written == -1)
+ set_errno (PR_GetError ());
+
+ return written;
}
static int