aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-09-08 12:02:41 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-09-08 12:02:41 +0800
commitf28eb2be4e77d749ee72c69c2bdcfc510741fe9b (patch)
treecca3e7bfb8dd2cc4abc09eb28d86341ee37491b6 /camel
parent585a2ea55469ad698f2aecb47ca7e70751c46d9a (diff)
downloadgsoc2013-evolution-f28eb2be4e77d749ee72c69c2bdcfc510741fe9b.tar
gsoc2013-evolution-f28eb2be4e77d749ee72c69c2bdcfc510741fe9b.tar.gz
gsoc2013-evolution-f28eb2be4e77d749ee72c69c2bdcfc510741fe9b.tar.bz2
gsoc2013-evolution-f28eb2be4e77d749ee72c69c2bdcfc510741fe9b.tar.lz
gsoc2013-evolution-f28eb2be4e77d749ee72c69c2bdcfc510741fe9b.tar.xz
gsoc2013-evolution-f28eb2be4e77d749ee72c69c2bdcfc510741fe9b.tar.zst
gsoc2013-evolution-f28eb2be4e77d749ee72c69c2bdcfc510741fe9b.zip
make ssl connection async and cancellable, and minor api update to async
2004-09-03 Not Zed <NotZed@Ximian.com> * camel-tcp-stream-ssl.c (stream_connect): make ssl connection async and cancellable, and minor api update to async connection. svn path=/trunk/; revision=27180
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog5
-rw-r--r--camel/camel-tcp-stream-ssl.c33
2 files changed, 27 insertions, 11 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index d8a73bf3f6..f2e820ad58 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-03 Not Zed <NotZed@Ximian.com>
+
+ * camel-tcp-stream-ssl.c (stream_connect): make ssl connection
+ async and cancellable, and minor api update to async connection.
+
2004-08-27 Not Zed <NotZed@Ximian.com>
** See bug #64023.
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 820912ffa5..791083186c 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -1028,7 +1028,7 @@ stream_connect (CamelTcpStream *stream, struct hostent *host, int port)
{
CamelTcpStreamSSL *ssl = CAMEL_TCP_STREAM_SSL (stream);
PRNetAddr netaddr;
- PRFileDesc *fd;
+ PRFileDesc *fd, *cancel_fd;
g_return_val_if_fail (host != NULL, -1);
@@ -1070,26 +1070,37 @@ stream_connect (CamelTcpStream *stream, struct hostent *host, int port)
fd = ssl_fd;
}
-
- if (PR_Connect (fd, &netaddr, CONNECT_TIMEOUT) == PR_FAILURE) {
+
+ cancel_fd = camel_operation_cancel_prfd(NULL);
+
+ if (PR_Connect (fd, &netaddr, cancel_fd?0:CONNECT_TIMEOUT) == PR_FAILURE) {
int errnosave;
set_errno (PR_GetError ());
- if (errno == EINPROGRESS) {
+ if (errno == EINPROGRESS || (cancel_fd && errno == ETIMEDOUT)) {
gboolean connected = FALSE;
- PRPollDesc poll;
+ PRPollDesc poll[2];
+
+ poll[0].fd = fd;
+ poll[0].in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;
+ poll[1].fd = cancel_fd;
+ poll[1].in_flags = PR_POLL_READ;
do {
- poll.fd = fd;
- poll.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;
- poll.out_flags = 0;
-
- if (PR_Poll (&poll, 1, CONNECT_TIMEOUT) == PR_FAILURE) {
+ poll[0].out_flags = 0;
+ poll[1].out_flags = 0;
+
+ if (PR_Poll (poll, cancel_fd?2:1, CONNECT_TIMEOUT) == PR_FAILURE) {
set_errno (PR_GetError ());
goto exception;
}
- if (PR_GetConnectStatus (&poll) == PR_FAILURE) {
+ if (poll[1].out_flags == PR_POLL_READ) {
+ errno = EINTR;
+ goto exception;
+ }
+
+ if (PR_ConnectContinue(fd, poll[0].out_flags) == PR_FAILURE) {
set_errno (PR_GetError ());
if (errno != EINPROGRESS)
goto exception;