aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-03-08 00:24:19 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-03-08 00:24:19 +0800
commit06ddc94963ff2c93605c00dd9304610295ee3e54 (patch)
tree465335c8f2e14ae3ff18c9df5c0b5ec6176a301d
parent69a4ca1fb2dea2171b87d57271c050c33c9553fa (diff)
downloadgsoc2013-evolution-06ddc94963ff2c93605c00dd9304610295ee3e54.tar
gsoc2013-evolution-06ddc94963ff2c93605c00dd9304610295ee3e54.tar.gz
gsoc2013-evolution-06ddc94963ff2c93605c00dd9304610295ee3e54.tar.bz2
gsoc2013-evolution-06ddc94963ff2c93605c00dd9304610295ee3e54.tar.lz
gsoc2013-evolution-06ddc94963ff2c93605c00dd9304610295ee3e54.tar.xz
gsoc2013-evolution-06ddc94963ff2c93605c00dd9304610295ee3e54.tar.zst
gsoc2013-evolution-06ddc94963ff2c93605c00dd9304610295ee3e54.zip
Add a timeout on the select. (stream_write): Same.
2002-03-07 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-openssl.c (stream_read): Add a timeout on the select. (stream_write): Same. svn path=/trunk/; revision=15963
-rw-r--r--camel/ChangeLog6
-rw-r--r--camel/camel-tcp-stream-openssl.c26
2 files changed, 24 insertions, 8 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 4f91d680ac..b11dd5310b 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,9 @@
+2002-03-07 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-tcp-stream-openssl.c (stream_read): Add a timeout on the
+ select.
+ (stream_write): Same.
+
2002-03-06 Jeffrey Stedfast <fejj@ximian.com>
* providers/smtp/camel-smtp-transport.c (connect_to_server): Fix
diff --git a/camel/camel-tcp-stream-openssl.c b/camel/camel-tcp-stream-openssl.c
index 69c2ca139c..2c3709fbd8 100644
--- a/camel/camel-tcp-stream-openssl.c
+++ b/camel/camel-tcp-stream-openssl.c
@@ -45,6 +45,10 @@
#include <pthread.h>
#endif
+#define d(x)
+
+#define TIMEOUT_USEC (10000)
+
static CamelTcpStreamClass *parent_class = NULL;
/* Returns the class for a CamelTcpStreamOpenSSL */
@@ -210,20 +214,20 @@ ssl_errno (SSL *ssl, int ret)
return 0;
case SSL_ERROR_ZERO_RETURN:
/* this one does not map well at all */
- printf ("ssl_errno: SSL_ERROR_ZERO_RETURN\n");
+ d(printf ("ssl_errno: SSL_ERROR_ZERO_RETURN\n"));
return EINVAL;
case SSL_ERROR_WANT_READ: /* non-fatal; retry */
case SSL_ERROR_WANT_WRITE: /* non-fatal; retry */
- printf ("ssl_errno: SSL_ERROR_WANT_[READ,WRITE]\n");
+ d(printf ("ssl_errno: SSL_ERROR_WANT_[READ,WRITE]\n"));
return EAGAIN;
case SSL_ERROR_SYSCALL:
- printf ("ssl_errno: SSL_ERROR_SYSCALL\n");
+ d(printf ("ssl_errno: SSL_ERROR_SYSCALL\n"));
return EINTR;
case SSL_ERROR_SSL:
- printf ("ssl_errno: SSL_ERROR_SSL <-- very useful error...riiiiight\n");
+ d(printf ("ssl_errno: SSL_ERROR_SSL <-- very useful error...riiiiight\n"));
return EINTR;
default:
- printf ("ssl_errno: default error\n");
+ d(printf ("ssl_errno: default error\n"));
return EINTR;
}
}
@@ -286,6 +290,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n)
} while (nread < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
} else {
int error, flags, fdmax;
+ struct timeval timeout;
fd_set rdset;
flags = fcntl (openssl->priv->sockfd, F_GETFL);
@@ -298,7 +303,9 @@ stream_read (CamelStream *stream, char *buffer, size_t n)
FD_SET (openssl->priv->sockfd, &rdset);
FD_SET (cancel_fd, &rdset);
- select (fdmax, &rdset, 0, 0, NULL);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = TIMEOUT_USEC;
+ select (fdmax, &rdset, 0, 0, &timeout);
if (FD_ISSET (cancel_fd, &rdset)) {
fcntl (openssl->priv->sockfd, F_SETFL, flags);
errno = EINTR;
@@ -354,8 +361,9 @@ stream_write (CamelStream *stream, const char *buffer, size_t n)
written += w;
} while (w != -1 && written < n);
} else {
- fd_set rdset, wrset;
int error, flags, fdmax;
+ struct timeval timeout;
+ fd_set rdset, wrset;
flags = fcntl (openssl->priv->sockfd, F_GETFL);
fcntl (openssl->priv->sockfd, F_SETFL, flags | O_NONBLOCK);
@@ -367,7 +375,9 @@ stream_write (CamelStream *stream, const char *buffer, size_t n)
FD_SET (openssl->priv->sockfd, &wrset);
FD_SET (cancel_fd, &rdset);
- select (fdmax, &rdset, &wrset, 0, NULL);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = TIMEOUT_USEC;
+ select (fdmax, &rdset, &wrset, 0, &timeout);
if (FD_ISSET (cancel_fd, &rdset)) {
fcntl (openssl->priv->sockfd, F_SETFL, flags);
errno = EINTR;