diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/camel-tcp-stream-openssl.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/camel/camel-tcp-stream-openssl.c b/camel/camel-tcp-stream-openssl.c index 17d5ab0961..e7dab0aaf7 100644 --- a/camel/camel-tcp-stream-openssl.c +++ b/camel/camel-tcp-stream-openssl.c @@ -176,7 +176,8 @@ errlib_error_to_errno (int ret) if (error == 0) { if (ret == 0) errno = EINVAL; /* unexpected EOF */ - errno = 0; + else + errno = 0; } else if (!errno) { /* ok, we get the shaft now. */ errno = EINTR; @@ -231,7 +232,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n) ssl_error_to_errno (ssl, nread); } while (nread < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); } else { - int flags, fdmax; + int error, flags, fdmax; fd_set rdset; flags = fcntl (tcp_stream_openssl->priv->sockfd, F_GETFL); @@ -257,7 +258,9 @@ stream_read (CamelStream *stream, char *buffer, size_t n) } while (nread < 0 && errno == EINTR); } while (nread < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)); + error = errno; fcntl (tcp_stream_openssl->priv->sockfd, F_SETFL, flags); + errno = error; } return nread; @@ -290,7 +293,7 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) } while (w != -1 && written < n); } else { fd_set rdset, wrset; - int flags, fdmax; + int error, flags, fdmax; flags = fcntl (tcp_stream_openssl->priv->sockfd, F_GETFL); fcntl (tcp_stream_openssl->priv->sockfd, F_SETFL, flags | O_NONBLOCK); |