From 7e41c072778d961f58308395ef4b440aa1e31fbc Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 19 May 2006 15:25:08 +0000 Subject: [PATCH] Get rid of the search_lock and simply reuse the connect_lock. 2006-05-19 Jeffrey Stedfast * camel-imap-folder.c (imap_search_by_expression) (imap_search_by_uids, imap_search_free): Get rid of the search_lock and simply reuse the connect_lock. 2006-05-18 Jeffrey Stedfast * camel-imap-folder.c (camel_imap_folder_selected, imap_rename) (imap_append_offline, imap_append_online, imap_append_resyncing) (imap_transfer_offline, imap_transfer_online) (imap_transfer_resyncing, camel_imap_folder_changed): Get rid of the cache_lock and use the service connect_lock instead. Fixes some possible deadlock conditions. --- camel/providers/imap/ChangeLog | 26 +++- camel/providers/imap/Makefile.am | 3 +- camel/providers/imap/camel-imap-command.c | 1 - camel/providers/imap/camel-imap-folder.c | 212 +++++++++++++----------------- camel/providers/imap/camel-imap-folder.h | 4 +- camel/providers/imap/camel-imap-private.h | 76 ----------- camel/providers/imap/camel-imap-search.c | 1 - camel/providers/imap/camel-imap-store.c | 1 - camel/providers/imap/camel-imap-wrapper.c | 19 ++- 9 files changed, 127 insertions(+), 216 deletions(-) delete mode 100644 camel/providers/imap/camel-imap-private.h diff --git a/camel/providers/imap/ChangeLog b/camel/providers/imap/ChangeLog index e8aa2cf..94cf36b 100644 --- a/camel/providers/imap/ChangeLog +++ b/camel/providers/imap/ChangeLog @@ -1,10 +1,24 @@ +2006-05-19 Jeffrey Stedfast + + * camel-imap-folder.c (imap_search_by_expression) + (imap_search_by_uids, imap_search_free): Get rid of the + search_lock and simply reuse the connect_lock. + +2006-05-18 Jeffrey Stedfast + + * camel-imap-folder.c (camel_imap_folder_selected, imap_rename) + (imap_append_offline, imap_append_online, imap_append_resyncing) + (imap_transfer_offline, imap_transfer_online) + (imap_transfer_resyncing, camel_imap_folder_changed): Get rid of + the cache_lock and use the service connect_lock instead. Fixes + some possible deadlock conditions. + 2006-05-10 Parthasarathi Susarla - - * camel-imap-folder.c: - Add space at the end of CAMEL_MESSAGE_INFO_HEADERS. The content-type - header wont be fetched otherwise(it mergers with the - MESSAGE_LIST_HEADER). - This fix shows the attachment icon in the message list + + * camel-imap-folder.c: Add space at the end of + CAMEL_MESSAGE_INFO_HEADERS. The content-type header wont be + fetched otherwise(it mergers with the MESSAGE_LIST_HEADER). This + fix shows the attachment icon in the message list 2006-05-01 Jeffrey Stedfast diff --git a/camel/providers/imap/Makefile.am b/camel/providers/imap/Makefile.am index 2480222..0a02715 100644 --- a/camel/providers/imap/Makefile.am +++ b/camel/providers/imap/Makefile.am @@ -37,8 +37,7 @@ noinst_HEADERS = \ camel-imap-summary.h \ camel-imap-types.h \ camel-imap-utils.h \ - camel-imap-wrapper.h \ - camel-imap-private.h + camel-imap-wrapper.h libcamelimap_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED) diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index a5550b8..cc4f1ad 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -38,7 +38,6 @@ #include "camel-imap-folder.h" #include "camel-imap-store.h" #include "camel-imap-store-summary.h" -#include "camel-imap-private.h" #include #include #include diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 47924db..c5aec03 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -37,11 +37,11 @@ /*#include "libedataserver/e-path.h"*/ #include "libedataserver/e-time-utils.h" #include "libedataserver/e-data-server-util.h" +#include "libedataserver/e-msgport.h" #include "camel-imap-folder.h" #include "camel-imap-command.h" #include "camel-imap-message-cache.h" -#include "camel-imap-private.h" #include "camel-imap-search.h" #include "camel-imap-store.h" #include "camel-imap-summary.h" @@ -70,6 +70,7 @@ #include "camel-i18n.h" #include "camel/camel-store-summary.h" + #define d(x) /* set to -1 for infinite size (suggested max command-line length is @@ -189,12 +190,6 @@ camel_imap_folder_init (gpointer object, gpointer klass) folder->folder_flags |= (CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY | CAMEL_FOLDER_HAS_SEARCH_CAPABILITY); - imap_folder->priv = g_malloc0(sizeof(*imap_folder->priv)); -#ifdef ENABLE_THREADS - imap_folder->priv->search_lock = e_mutex_new(E_MUTEX_SIMPLE); - imap_folder->priv->cache_lock = e_mutex_new(E_MUTEX_REC); -#endif - imap_folder->need_rescan = TRUE; } @@ -347,9 +342,7 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response, else if (validity != imap_summary->validity) { imap_summary->validity = validity; camel_folder_summary_clear (folder->summary); - CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); camel_imap_message_cache_clear (imap_folder->cache); - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); imap_folder->need_rescan = FALSE; camel_imap_folder_changed (folder, exists, NULL, ex); return; @@ -423,12 +416,6 @@ imap_finalize (CamelObject *object) camel_object_unref (CAMEL_OBJECT (imap_folder->search)); if (imap_folder->cache) camel_object_unref (CAMEL_OBJECT (imap_folder->cache)); - -#ifdef ENABLE_THREADS - e_mutex_destroy(imap_folder->priv->search_lock); - e_mutex_destroy(imap_folder->priv->cache_lock); -#endif - g_free(imap_folder->priv); } static int @@ -475,26 +462,28 @@ imap_rename (CamelFolder *folder, const char *new) CamelImapStore *imap_store = (CamelImapStore *)folder->parent_store; char *folder_dir, *summary_path, *state_file; char *folders; - + + CAMEL_SERVICE_LOCK (imap_store, connect_lock); + folders = g_strconcat (imap_store->storage_path, "/folders", NULL); folder_dir = imap_path_to_physical (folders, new); g_free (folders); summary_path = g_strdup_printf("%s/summary", folder_dir); - - CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock); + camel_imap_message_cache_set_path(imap_folder->cache, folder_dir); - CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); - + camel_folder_summary_set_filename(folder->summary, summary_path); - + state_file = g_strdup_printf ("%s/cmeta", folder_dir); camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state_file, NULL); g_free(state_file); - + g_free(summary_path); g_free(folder_dir); - + ((CamelFolderClass *)disco_folder_class)->rename(folder, new); + + CAMEL_SERVICE_UNLOCK (imap_store, connect_lock); } static void @@ -1202,21 +1191,23 @@ imap_append_offline (CamelFolder *folder, CamelMimeMessage *message, char *uid; uid = get_temp_uid (); - + + CAMEL_SERVICE_LOCK (imap_store, connect_lock); + camel_imap_summary_add_offline (folder->summary, uid, message, info); - CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock); camel_imap_message_cache_insert_wrapper (cache, uid, "", CAMEL_DATA_WRAPPER (message), ex); - CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); - + changes = camel_folder_change_info_new (); camel_folder_change_info_add_uid (changes, uid); - camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", - changes); + camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes); camel_folder_change_info_free (changes); camel_disco_diary_log (CAMEL_DISCO_STORE (imap_store)->diary, CAMEL_DISCO_DIARY_FOLDER_APPEND, folder, uid); + + CAMEL_SERVICE_UNLOCK (imap_store, connect_lock); + if (appended_uid) *appended_uid = uid; else @@ -1327,21 +1318,22 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, CamelImapResponse *response; char *uid; int count; - + + CAMEL_SERVICE_LOCK (store, connect_lock); + count = camel_folder_summary_count (folder->summary); - response = do_append (folder, message, info, &uid, ex); - if (!response) + if (!(response = do_append (folder, message, info, &uid, ex))) { + CAMEL_SERVICE_UNLOCK (store, connect_lock); return; + } if (uid) { /* Cache first, since freeing response may trigger a * summary update that will want this information. */ - CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock); camel_imap_message_cache_insert_wrapper ( CAMEL_IMAP_FOLDER (folder)->cache, uid, "", CAMEL_DATA_WRAPPER (message), ex); - CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); if (appended_uid) *appended_uid = uid; else @@ -1352,10 +1344,10 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, camel_imap_response_free (store, response); /* Make sure a "folder_changed" is emitted. */ - CAMEL_SERVICE_LOCK (store, connect_lock); if (store->current_folder != folder || camel_folder_summary_count (folder->summary) == count) imap_refresh_info (folder, ex); + CAMEL_SERVICE_UNLOCK (store, connect_lock); } @@ -1368,19 +1360,20 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message, CamelImapResponse *response; char *uid; - response = do_append (folder, message, info, &uid, ex); - if (!response) + CAMEL_SERVICE_LOCK (store, connect_lock); + + if (!(response = do_append (folder, message, info, &uid, ex))) { + CAMEL_SERVICE_UNLOCK (store, connect_lock); return; + } if (uid) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); const char *olduid = camel_message_info_uid (info); - CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); camel_imap_message_cache_copy (imap_folder->cache, olduid, imap_folder->cache, uid, ex); - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); - + if (appended_uid) *appended_uid = uid; else @@ -1389,6 +1382,8 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message, *appended_uid = NULL; camel_imap_response_free (store, response); + + CAMEL_SERVICE_UNLOCK (store, connect_lock); } @@ -1405,17 +1400,9 @@ imap_transfer_offline (CamelFolder *source, GPtrArray *uids, CamelMessageInfo *mi; char *uid, *destuid; int i; - - /* We grab the store's command lock first, and then grab the - * source and destination cache_locks. This way we can't - * deadlock in the case where we're simultaneously also trying - * to copy messages in the other direction from another thread. - */ + CAMEL_SERVICE_LOCK (store, connect_lock); - CAMEL_IMAP_FOLDER_LOCK (source, cache_lock); - CAMEL_IMAP_FOLDER_LOCK (dest, cache_lock); - CAMEL_SERVICE_UNLOCK (store, connect_lock); - + if (transferred_uids) { *transferred_uids = g_ptr_array_new (); g_ptr_array_set_size (*transferred_uids, uids->len); @@ -1451,16 +1438,15 @@ imap_transfer_offline (CamelFolder *source, GPtrArray *uids, if (delete_originals) camel_folder_delete_message (source, uid); } - - CAMEL_IMAP_FOLDER_UNLOCK (dest, cache_lock); - CAMEL_IMAP_FOLDER_UNLOCK (source, cache_lock); - + camel_object_trigger_event (CAMEL_OBJECT (dest), "folder_changed", changes); camel_folder_change_info_free (changes); camel_disco_diary_log (CAMEL_DISCO_STORE (store)->diary, CAMEL_DISCO_DIARY_FOLDER_TRANSFER, source, dest, uids, delete_originals); + + CAMEL_SERVICE_UNLOCK (store, connect_lock); } static void @@ -1490,22 +1476,14 @@ handle_copyuid (CamelImapResponse *response, CamelFolder *source, src = imap_uid_set_to_array (source->summary, srcset); dest = imap_uid_set_to_array (destination->summary, destset); - + if (src && dest && src->len == dest->len) { - /* We don't have to worry about deadlocking on the - * cache locks here, because we've got the store's - * command lock too, so no one else could be here. - */ - CAMEL_IMAP_FOLDER_LOCK (source, cache_lock); - CAMEL_IMAP_FOLDER_LOCK (destination, cache_lock); for (i = 0; i < src->len; i++) { camel_imap_message_cache_copy (scache, src->pdata[i], dcache, dest->pdata[i], NULL); } - CAMEL_IMAP_FOLDER_UNLOCK (source, cache_lock); - CAMEL_IMAP_FOLDER_UNLOCK (destination, cache_lock); - + imap_uid_array_free (src); imap_uid_array_free (dest); return; @@ -1567,7 +1545,9 @@ imap_transfer_online (CamelFolder *source, GPtrArray *uids, qsort (uids->pdata, uids->len, sizeof (void *), uid_compar); /* Now copy the messages */ + CAMEL_SERVICE_LOCK (store, connect_lock); do_copy(source, uids, dest, delete_originals, ex); + CAMEL_SERVICE_UNLOCK (store, connect_lock); if (camel_exception_is_set (ex)) return; @@ -1587,12 +1567,15 @@ imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids, gboolean delete_originals, CamelException *ex) { CamelDiscoDiary *diary = CAMEL_DISCO_STORE (source->parent_store)->diary; + CamelStore *store = source->parent_store; GPtrArray *realuids; int first, i; const char *uid; CamelMimeMessage *message; CamelMessageInfo *info; + CAMEL_SERVICE_LOCK (store, connect_lock); + qsort (uids->pdata, uids->len, sizeof (void *), uid_compar); /* This is trickier than append_resyncing, because some of @@ -1649,10 +1632,12 @@ imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids, } g_ptr_array_free (realuids, FALSE); - + /* FIXME */ if (transferred_uids) *transferred_uids = NULL; + + CAMEL_SERVICE_UNLOCK (store, connect_lock); } static GPtrArray * @@ -1660,36 +1645,36 @@ imap_search_by_expression (CamelFolder *folder, const char *expression, CamelExc { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); GPtrArray *matches; - + /* we could get around this by creating a new search object each time, but i doubt its worth it since any long operation would lock the command channel too */ - CAMEL_IMAP_FOLDER_LOCK(folder, search_lock); - + CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); + camel_folder_search_set_folder (imap_folder->search, folder); matches = camel_folder_search_search(imap_folder->search, expression, NULL, ex); - - CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock); - + + CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock); + return matches; } static GPtrArray * -imap_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, CamelException *ex) +imap_search_by_uids (CamelFolder *folder, const char *expression, GPtrArray *uids, CamelException *ex) { - CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER(folder); + CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); GPtrArray *matches; - + if (uids->len == 0) - return g_ptr_array_new(); - - CAMEL_IMAP_FOLDER_LOCK(folder, search_lock); - + return g_ptr_array_new (); + + CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); + camel_folder_search_set_folder(imap_folder->search, folder); matches = camel_folder_search_search(imap_folder->search, expression, uids, ex); - - CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock); - + + CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock); + return matches; } @@ -1697,14 +1682,14 @@ static void imap_search_free (CamelFolder *folder, GPtrArray *uids) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); - + g_return_if_fail (imap_folder->search); - - CAMEL_IMAP_FOLDER_LOCK(folder, search_lock); - + + CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); + camel_folder_search_free_result (imap_folder->search, uids); - - CAMEL_IMAP_FOLDER_UNLOCK(folder, search_lock); + + CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock); } static CamelMimeMessage *get_message (CamelImapFolder *imap_folder, @@ -2056,7 +2041,7 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) CamelMimeMessage *msg = NULL; CamelStream *stream = NULL; int retry; - + mi = (CamelImapMessageInfo *)camel_folder_summary_uid (folder->summary, uid); if (mi == NULL) { camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, @@ -2066,7 +2051,7 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) /* If its cached in full, just get it as is, this is only a shortcut, since we get stuff from the cache anyway. It affects a busted connection though. */ - if ( (stream = camel_imap_folder_fetch_data(imap_folder, uid, "", TRUE, NULL)) + if ((stream = camel_imap_folder_fetch_data(imap_folder, uid, "", TRUE, NULL)) && (msg = get_message_simple(imap_folder, uid, stream, ex))) goto done; @@ -2095,7 +2080,7 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) char *body, *found_uid; int i; - CAMEL_SERVICE_LOCK(store, connect_lock); + CAMEL_SERVICE_LOCK (store, connect_lock); if (!camel_imap_store_connected(store, ex)) { CAMEL_SERVICE_UNLOCK(store, connect_lock); camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, @@ -2104,8 +2089,7 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) } response = camel_imap_command (store, folder, ex, "UID FETCH %s BODY", uid); - CAMEL_SERVICE_UNLOCK(store, connect_lock); - + if (response) { for (i = 0, body = NULL; i < response->untagged->len; i++) { fetch_data = parse_fetch_response (imap_folder, response->untagged->pdata[i]); @@ -2125,7 +2109,7 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) imap_parse_body ((const char **) &body, folder, mi->info.content); camel_folder_summary_touch (folder->summary); } - + if (fetch_data) g_datalist_clear (&fetch_data); @@ -2133,6 +2117,8 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) } else { camel_exception_clear(ex); } + + CAMEL_SERVICE_UNLOCK (store, connect_lock); } if (camel_debug_start("imap:folder")) { @@ -2637,9 +2623,7 @@ camel_imap_folder_changed (CamelFolder *folder, int exists, } camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info)); - CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); camel_imap_message_cache_remove (imap_folder->cache, camel_message_info_uid (info)); - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); camel_folder_summary_remove (folder->summary, info); camel_message_info_free(info); } @@ -2686,36 +2670,23 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, char *found_uid; int i; - /* EXPUNGE responses have to modify the cache, which means - * they have to grab the cache_lock while holding the - * connect_lock. - - * Because getting the service lock may cause MUCH unecessary - * delay when we already have the data locally, we do the - * locking separately. This could cause a race - * getting the same data from the cache, but that is only - * an inefficiency, and bad luck. - */ - CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); + CAMEL_SERVICE_LOCK (store, connect_lock); stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text, ex); if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) { camel_exception_clear (ex); stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", ex); } - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); - if (stream || cache_only) + if (stream || cache_only) { + CAMEL_SERVICE_UNLOCK (store, connect_lock); return stream; - + } + camel_exception_clear(ex); - - CAMEL_SERVICE_LOCK (store, connect_lock); - CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); - + if (!camel_imap_store_connected(store, ex)) { camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("This message is not currently available")); - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); CAMEL_SERVICE_UNLOCK (store, connect_lock); return NULL; } @@ -2730,11 +2701,9 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, "UID FETCH %s BODY.PEEK[%s]", uid, section_text); } - /* We won't need the connect_lock again after this. */ - CAMEL_SERVICE_UNLOCK (store, connect_lock); if (!response) { - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); + CAMEL_SERVICE_UNLOCK (store, connect_lock); return NULL; } @@ -2748,8 +2717,9 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, g_datalist_clear (&fetch_data); stream = NULL; } + camel_imap_response_free (store, response); - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); + if (!stream) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("Could not find message body in FETCH response.")); @@ -2758,6 +2728,8 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid, g_datalist_clear (&fetch_data); } + CAMEL_SERVICE_UNLOCK (store, connect_lock); + return stream; } @@ -2769,6 +2741,8 @@ parse_fetch_response (CamelImapFolder *imap_folder, char *response) gboolean cache_header = TRUE, header = FALSE; size_t body_len = 0; + CAMEL_SERVICE_ASSERT_LOCKED (((CamelFolder *) imap_folder)->parent_store, connect_lock); + if (*response != '(') { long seq; @@ -2887,11 +2861,9 @@ parse_fetch_response (CamelImapFolder *imap_folder, char *response) if (header && !cache_header) { stream = camel_stream_mem_new_with_buffer (body, body_len); } else { - CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); stream = camel_imap_message_cache_insert (imap_folder->cache, uid, part_spec, body, body_len, NULL); - CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); if (stream == NULL) stream = camel_stream_mem_new_with_buffer (body, body_len); } diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h index 033ad30..e949386 100644 --- a/camel/providers/imap/camel-imap-folder.h +++ b/camel/providers/imap/camel-imap-folder.h @@ -44,9 +44,7 @@ extern "C" { struct _CamelImapFolder { CamelDiscoFolder parent_object; - - struct _CamelImapFolderPrivate *priv; - + CamelFolderSearch *search; CamelImapMessageCache *cache; diff --git a/camel/providers/imap/camel-imap-private.h b/camel/providers/imap/camel-imap-private.h deleted file mode 100644 index 966a90c..0000000 --- a/camel/providers/imap/camel-imap-private.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * camel-imap-private.h: Private info for imap. - * - * Authors: Michael Zucchi - * - * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU Lesser General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef CAMEL_IMAP_PRIVATE_H -#define CAMEL_IMAP_PRIVATE_H 1 - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* need a way to configure and save this data, if this header is to - be installed. For now, dont install it */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef ENABLE_THREADS -#include "libedataserver/e-msgport.h" -#endif - -struct _CamelImapFolderPrivate { -#ifdef ENABLE_THREADS - EMutex *search_lock; /* for locking the search object */ - EMutex *cache_lock; /* for locking the cache object */ -#endif -}; - -#ifdef ENABLE_THREADS -#define CAMEL_IMAP_FOLDER_LOCK(f, l) (e_mutex_lock(((CamelImapFolder *)f)->priv->l)) -#define CAMEL_IMAP_FOLDER_UNLOCK(f, l) (e_mutex_unlock(((CamelImapFolder *)f)->priv->l)) -#else -#define CAMEL_IMAP_FOLDER_LOCK(f, l) -#define CAMEL_IMAP_FOLDER_UNLOCK(f, l) -#endif - -struct _CamelImapWrapperPrivate { -#ifdef ENABLE_THREADS - GMutex *lock; -#endif -}; - -#ifdef ENABLE_THREADS -#define CAMEL_IMAP_WRAPPER_LOCK(f, l) (g_mutex_lock(((CamelImapWrapper *)f)->priv->l)) -#define CAMEL_IMAP_WRAPPER_UNLOCK(f, l) (g_mutex_unlock(((CamelImapWrapper *)f)->priv->l)) -#else -#define CAMEL_IMAP_WRAPPER_LOCK(f, l) -#define CAMEL_IMAP_WRAPPER_UNLOCK(f, l) -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_IMAP_PRIVATE_H */ - diff --git a/camel/providers/imap/camel-imap-search.c b/camel/providers/imap/camel-imap-search.c index f04cf8f..04e1875 100644 --- a/camel/providers/imap/camel-imap-search.c +++ b/camel/providers/imap/camel-imap-search.c @@ -34,7 +34,6 @@ #include "camel-imap-folder.h" #include "camel-imap-store.h" #include "camel-imap-search.h" -#include "camel-imap-private.h" #include "camel-imap-utils.h" #include "camel-imap-summary.h" diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index d5b72d5..8612a84 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -58,7 +58,6 @@ #include "camel-imap-command.h" #include "camel-imap-folder.h" #include "camel-imap-message-cache.h" -#include "camel-imap-private.h" #include "camel-imap-store-summary.h" #include "camel-imap-store.h" #include "camel-imap-summary.h" diff --git a/camel/providers/imap/camel-imap-wrapper.c b/camel/providers/imap/camel-imap-wrapper.c index e08a89f..a895408 100644 --- a/camel/providers/imap/camel-imap-wrapper.c +++ b/camel/providers/imap/camel-imap-wrapper.c @@ -30,7 +30,6 @@ #include "camel-imap-folder.h" #include "camel-imap-wrapper.h" -#include "camel-imap-private.h" #include "camel-exception.h" #include "camel-stream-filter.h" #include "camel-mime-filter-basic.h" @@ -38,6 +37,17 @@ #include "camel-mime-filter-charset.h" #include "camel-mime-part.h" +#include "libedataserver/e-msgport.h" + + +struct _CamelImapWrapperPrivate { + GMutex *lock; +}; + +#define CAMEL_IMAP_WRAPPER_LOCK(f, l) (g_mutex_lock(((CamelImapWrapper *)f)->priv->l)) +#define CAMEL_IMAP_WRAPPER_UNLOCK(f, l) (g_mutex_unlock(((CamelImapWrapper *)f)->priv->l)) + + static CamelDataWrapperClass *parent_class = NULL; /* Returns the class for a CamelDataWrapper */ @@ -68,10 +78,9 @@ camel_imap_wrapper_finalize (CamelObject *object) g_free (imap_wrapper->uid); if (imap_wrapper->part) g_free (imap_wrapper->part_spec); - -#ifdef ENABLE_THREADS + g_mutex_free (imap_wrapper->priv->lock); -#endif + g_free (imap_wrapper->priv); } @@ -81,9 +90,7 @@ camel_imap_wrapper_init (gpointer object, gpointer klass) CamelImapWrapper *imap_wrapper = CAMEL_IMAP_WRAPPER (object); imap_wrapper->priv = g_new0 (struct _CamelImapWrapperPrivate, 1); -#ifdef ENABLE_THREADS imap_wrapper->priv->lock = g_mutex_new (); -#endif } CamelType -- 2.7.4