changeset 13285:c17e4f8ddc81

liblib: io_loop_context_remove_callbacks() now requires also callbacks.
author Timo Sirainen <tss@iki.fi>
date Thu, 25 Aug 2011 00:27:10 +0300
parents a5edd3fe466b
children b6b16c9eb3d5
files src/lib-storage/mail-storage-service.c src/lib/ioloop.c src/lib/ioloop.h
diffstat 3 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-storage-service.c	Wed Aug 24 21:37:15 2011 +0300
+++ b/src/lib-storage/mail-storage-service.c	Thu Aug 25 00:27:10 2011 +0300
@@ -1075,7 +1075,9 @@
 	*_user = NULL;
 
 	if (user->ioloop_ctx != NULL) {
-		io_loop_context_remove_callbacks(user->ioloop_ctx, user);
+		io_loop_context_remove_callbacks(user->ioloop_ctx,
+			mail_storage_service_io_activate,
+			mail_storage_service_io_deactivate, user);
 		io_loop_context_unref(&user->ioloop_ctx);
 	}
 	settings_parser_deinit(&user->set_parser);
--- a/src/lib/ioloop.c	Wed Aug 24 21:37:15 2011 +0300
+++ b/src/lib/ioloop.c	Thu Aug 25 00:27:10 2011 +0300
@@ -539,12 +539,14 @@
 }
 
 void io_loop_context_remove_callbacks(struct ioloop_context *ctx,
-				      void *context)
+				      io_callback_t *activate,
+				      io_callback_t *deactivate, void *context)
 {
 	struct ioloop_context_callback *cb;
 
 	array_foreach_modifiable(&ctx->callbacks, cb) {
-		if (cb->context == context) {
+		if (cb->context == context &&
+		    cb->activate == activate && cb->deactivate == deactivate) {
 			/* simply mark it as deleted, since we could get
 			   here from activate/deactivate loop */
 			cb->activate = NULL;
--- a/src/lib/ioloop.h	Wed Aug 24 21:37:15 2011 +0300
+++ b/src/lib/ioloop.h	Thu Aug 25 00:27:10 2011 +0300
@@ -112,9 +112,10 @@
 void io_loop_context_add_callbacks(struct ioloop_context *ctx,
 				   io_callback_t *activate,
 				   io_callback_t *deactivate, void *context);
-/* Remove callbacks with the given context. */
+/* Remove callbacks with the given callbacks and context. */
 void io_loop_context_remove_callbacks(struct ioloop_context *ctx,
-				      void *context);
+				      io_callback_t *activate,
+				      io_callback_t *deactivate, void *context);
 
 /* Move the given I/O into the current I/O loop if it's not already
    there. New I/O is returned, while the old one is freed. */