From ccbc3a36887e4ab7e442c649ddae53f6e964f40f Mon Sep 17 00:00:00 2001 From: Joe Shaw Date: Fri, 6 Jul 2001 04:11:27 +0000 Subject: Add locking to camel_nntp_get_grouplist_from_server(). 2001-07-06 Joe Shaw * providers/nntp/camel-nntp-grouplist.c: Add locking to camel_nntp_get_grouplist_from_server(). * providers/nntp/camel-nntp-resp-codes.h: Added NNTP_EXTENSIONS_SUPPORTED (202). * providers/nntp/camel-nntp-store.c (camel_nntp_store_get_extensions): Check for both NNTP_LIST_FOLLOWS and NNTP_EXTENSIONS_SUPPORTED from a LIST EXTENSIONS request. (Dunno if NNTP_LIST_FOLLOWS ever comes out of this, but that's what was already there...) Also, put some locking around it. (finalize): e_mutex_destroy() the command lock (camel_nntp_store_init): e_mutex_new() the command lock. * providers/nntp/camel-nntp-store.h: Add locking macros. svn path=/trunk/; revision=10838 --- camel/providers/nntp/camel-nntp-store.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'camel/providers/nntp/camel-nntp-store.c') diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index 084fbaa582..19510af334 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -63,9 +63,13 @@ static gboolean ensure_news_dir_exists (CamelNNTPStore *store); static void camel_nntp_store_get_extensions (CamelNNTPStore *store, CamelException *ex) { + int rc; + store->extensions = 0; - if (camel_nntp_command (store, ex, NULL, "LIST EXTENSIONS") == NNTP_LIST_FOLLOWS) { + CAMEL_NNTP_STORE_LOCK(store); + rc = camel_nntp_command(store, ex, NULL, "LIST EXTENSIONS"); + if (rc == NNTP_LIST_FOLLOWS || rc == NNTP_EXTENSIONS_SUPPORTED) { gboolean done = FALSE; CamelException ex; @@ -98,6 +102,7 @@ camel_nntp_store_get_extensions (CamelNNTPStore *store, CamelException *ex) g_free (line); } } + CAMEL_NNTP_STORE_UNLOCK(store); #ifdef DUMP_EXTENSIONS g_print ("NNTP Extensions:"); @@ -122,6 +127,7 @@ camel_nntp_store_get_overview_fmt (CamelNNTPStore *store, CamelException *ex) int i; gboolean done = FALSE; + CAMEL_NNTP_STORE_LOCK(store); status = camel_nntp_command (store, ex, NULL, "LIST OVERVIEW.FMT"); @@ -210,6 +216,7 @@ camel_nntp_store_get_overview_fmt (CamelNNTPStore *store, CamelException *ex) store->extensions &= ~CAMEL_NNTP_EXT_OVER; } } + CAMEL_NNTP_STORE_UNLOCK(store); } static gboolean @@ -574,6 +581,9 @@ finalize (CamelObject *object) CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (object); if (nntp_store->newsrc) camel_nntp_newsrc_write (nntp_store->newsrc); +#ifdef ENABLE_THREADS + e_mutex_destroy(nntp_store->command_lock); +#endif } static void @@ -608,11 +618,16 @@ static void camel_nntp_store_init (gpointer object, gpointer klass) { CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); + CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(object); CamelStore *store = CAMEL_STORE (object); remote_store->default_port = NNTP_PORT; store->flags = CAMEL_STORE_SUBSCRIPTIONS; + +#ifdef ENABLE_THREADS + nntp_store->command_lock = e_mutex_new(E_MUTEX_REC); +#endif } CamelType -- cgit v1.2.3