From eaa2814a05c8c3a094a00400cc5651e408ee9e18 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 22 Nov 2002 22:29:56 +0000 Subject: Use the new camel_operation_cancel_prfd() function to get the cancellation 2002-11-21 Jeffrey Stedfast * camel-tcp-stream-ssl.c (stream_read): Use the new camel_operation_cancel_prfd() function to get the cancellation fd so we can poll on it for cancellation stuff. (stream_write): Same. 2002-11-22 Not Zed * camel-operation.c (camel_operation_cancel_prfd): Implement, gets a nspr pr filedesc to poll/wait on (struct _CamelOperation): include a pr filedesc. svn path=/trunk/; revision=18894 --- camel/camel-operation.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'camel/camel-operation.c') diff --git a/camel/camel-operation.c b/camel/camel-operation.c index 6c490df73f..8befacce19 100644 --- a/camel/camel-operation.c +++ b/camel/camel-operation.c @@ -5,6 +5,9 @@ #include #ifdef ENABLE_THREADS #include +#ifdef HAVE_NSS +#include +#endif #endif #include @@ -42,6 +45,9 @@ struct _CamelOperation { #ifdef ENABLE_THREADS EMsgPort *cancel_port; int cancel_fd; +#ifdef HAVE_NSS + PRFileDesc *cancel_prfd; +#endif #endif }; @@ -436,6 +442,40 @@ int camel_operation_cancel_fd(CamelOperation *cc) return cc->cancel_fd; } +#ifdef HAVE_NSS +/** + * camel_operation_cancel_prfd: + * @cc: + * + * Retrieve a file descriptor that can be waited on (select, or poll) + * for read, to asynchronously detect cancellation. + * + * Return value: The fd, or NULL if cancellation is not available + * (blocked, or has not been registered for this thread). + **/ +PRFileDesc *camel_operation_cancel_prfd(CamelOperation *cc) +{ + CAMEL_ACTIVE_LOCK(); + + if (cc == NULL && operation_active) { + cc = g_hash_table_lookup(operation_active, (void *)pthread_self()); + } + + if (cc == NULL + || cc->blocked) { + CAMEL_ACTIVE_UNLOCK(); + return NULL; + } + + if (cc->cancel_prfd == NULL) + cc->cancel_prfd = e_msgport_prfd(cc->cancel_port); + + CAMEL_ACTIVE_UNLOCK(); + + return cc->cancel_prfd; +} +#endif /* HAVE_NSS */ + /** * camel_operation_start: * @cc: -- cgit v1.2.3