summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0 <NotZed@Ximian.com>2001-10-30 18:52:00 +0000
committerMichael Zucci <zucchi@src.gnome.org>2001-10-30 18:52:00 +0000
commitc663b934dee0ec07365e47afc6c82aa94ae5ff60 (patch)
treefc7b834348f19a621b11e46b8cad6e824fe12040
parent97ce9bee328c9d2f4a88f342c20c24e9ba0fc016 (diff)
downloadevolution-data-server-c663b934dee0ec07365e47afc6c82aa94ae5ff60.tar.gz
Dont setup cancel_fd. (camel_operation_cancel_fd): If cancel_fd notEVOLUTION_0_16_100
2001-10-30 <NotZed@Ximian.com> * camel-operation.c (camel_operation_new): Dont setup cancel_fd. (camel_operation_cancel_fd): If cancel_fd not created, set it up. (camel_operation_cancel): Set cancel flag before sending message. (cancel_thread): Same.
-rw-r--r--camel/ChangeLog5
-rw-r--r--camel/camel-operation.c21
2 files changed, 18 insertions, 8 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 3d7db779d..d8ba0bc96 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,10 @@
2001-10-30 <NotZed@Ximian.com>
+ * camel-operation.c (camel_operation_new): Dont setup cancel_fd.
+ (camel_operation_cancel_fd): If cancel_fd not created, set it up.
+ (camel_operation_cancel): Set cancel flag before sending message.
+ (cancel_thread): Same.
+
* camel-filter-driver.c (camel_filter_driver_filter_mbox): Make
sure we unref the mimeparse when we're done (successfully). This
was leaking an fd every get-mail! :(
diff --git a/camel/camel-operation.c b/camel/camel-operation.c
index 9f007d79f..6c490df73 100644
--- a/camel/camel-operation.c
+++ b/camel/camel-operation.c
@@ -95,7 +95,7 @@ CamelOperation *camel_operation_new(CamelOperationStatusFunc status, void *statu
#ifdef ENABLE_THREADS
cc->id = ~0;
cc->cancel_port = e_msgport_new();
- cc->cancel_fd = e_msgport_fd(cc->cancel_port);
+ cc->cancel_fd = -1;
#endif
return cc;
@@ -256,9 +256,9 @@ cancel_thread(void *key, CamelOperation *cc, void *data)
if (cc) {
d(printf("cancelling thread %d\n", cc->id));
+ cc->flags |= CAMEL_OPERATION_CANCELLED;
msg = g_malloc0(sizeof(*msg));
e_msgport_put(cc->cancel_port, (EMsg *)msg);
- cc->flags |= CAMEL_OPERATION_CANCELLED;
}
}
@@ -282,9 +282,9 @@ void camel_operation_cancel(CamelOperation *cc)
} else if ((cc->flags & CAMEL_OPERATION_CANCELLED) == 0) {
d(printf("cancelling thread %d\n", cc->id));
+ cc->flags |= CAMEL_OPERATION_CANCELLED;
msg = g_malloc0(sizeof(*msg));
e_msgport_put(cc->cancel_port, (EMsg *)msg);
- cc->flags |= CAMEL_OPERATION_CANCELLED;
}
CAMEL_ACTIVE_UNLOCK();
@@ -416,17 +416,22 @@ gboolean camel_operation_cancel_check(CamelOperation *cc)
**/
int camel_operation_cancel_fd(CamelOperation *cc)
{
+ CAMEL_ACTIVE_LOCK();
+
if (cc == NULL && operation_active) {
- CAMEL_ACTIVE_LOCK();
cc = g_hash_table_lookup(operation_active, (void *)pthread_self());
- CAMEL_ACTIVE_UNLOCK();
}
- if (cc == NULL)
+ if (cc == NULL
+ || cc->blocked) {
+ CAMEL_ACTIVE_UNLOCK();
return -1;
+ }
- if (cc->blocked)
- return -1;
+ if (cc->cancel_fd == -1)
+ cc->cancel_fd = e_msgport_fd(cc->cancel_port);
+
+ CAMEL_ACTIVE_UNLOCK();
return cc->cancel_fd;
}