aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/nntp
diff options
context:
space:
mode:
authorJoe Shaw <joe@ximian.com>2001-07-06 12:11:27 +0800
committerJoe Shaw <joeshaw@src.gnome.org>2001-07-06 12:11:27 +0800
commitccbc3a36887e4ab7e442c649ddae53f6e964f40f (patch)
tree08802644edeba3b8d14cc5096161ef3ef6e36039 /camel/providers/nntp
parent2583bd0d41a6ef0bcf91ebc8788157aad57a312e (diff)
downloadgsoc2013-evolution-ccbc3a36887e4ab7e442c649ddae53f6e964f40f.tar
gsoc2013-evolution-ccbc3a36887e4ab7e442c649ddae53f6e964f40f.tar.gz
gsoc2013-evolution-ccbc3a36887e4ab7e442c649ddae53f6e964f40f.tar.bz2
gsoc2013-evolution-ccbc3a36887e4ab7e442c649ddae53f6e964f40f.tar.lz
gsoc2013-evolution-ccbc3a36887e4ab7e442c649ddae53f6e964f40f.tar.xz
gsoc2013-evolution-ccbc3a36887e4ab7e442c649ddae53f6e964f40f.tar.zst
gsoc2013-evolution-ccbc3a36887e4ab7e442c649ddae53f6e964f40f.zip
Add locking to camel_nntp_get_grouplist_from_server().
2001-07-06 Joe Shaw <joe@ximian.com> * 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
Diffstat (limited to 'camel/providers/nntp')
-rw-r--r--camel/providers/nntp/camel-nntp-grouplist.c2
-rw-r--r--camel/providers/nntp/camel-nntp-resp-codes.h1
-rw-r--r--camel/providers/nntp/camel-nntp-store.c17
-rw-r--r--camel/providers/nntp/camel-nntp-store.h17
4 files changed, 35 insertions, 2 deletions
diff --git a/camel/providers/nntp/camel-nntp-grouplist.c b/camel/providers/nntp/camel-nntp-grouplist.c
index e77a28821c..8fdc513832 100644
--- a/camel/providers/nntp/camel-nntp-grouplist.c
+++ b/camel/providers/nntp/camel-nntp-grouplist.c
@@ -37,6 +37,7 @@ camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, CamelException *ex)
gboolean done = FALSE;
CamelNNTPGroupList *list;
+ CAMEL_NNTP_STORE_LOCK(store);
status = camel_nntp_command (store, ex, NULL,
"LIST");
@@ -73,6 +74,7 @@ camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, CamelException *ex)
list->group_list = g_list_prepend (list->group_list, entry);
}
}
+ CAMEL_NNTP_STORE_UNLOCK(store);
list->group_list = g_list_reverse(list->group_list);
return list;
diff --git a/camel/providers/nntp/camel-nntp-resp-codes.h b/camel/providers/nntp/camel-nntp-resp-codes.h
index 56aec79d3c..2f4d9ed540 100644
--- a/camel/providers/nntp/camel-nntp-resp-codes.h
+++ b/camel/providers/nntp/camel-nntp-resp-codes.h
@@ -31,6 +31,7 @@
#define NNTP_GREETING_POSTING_OK 200
#define NNTP_GREETING_NO_POSTING 201
+#define NNTP_EXTENSIONS_SUPPORTED 202
#define NNTP_GROUP_SELECTED 211
#define NNTP_LIST_FOLLOWS 215
#define NNTP_ARTICLE_FOLLOWS 220
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
diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h
index 225180dbcc..8841874e0c 100644
--- a/camel/providers/nntp/camel-nntp-store.h
+++ b/camel/providers/nntp/camel-nntp-store.h
@@ -35,12 +35,17 @@ extern "C" {
#include "camel-nntp-newsrc.h"
#include "camel-nntp-types.h"
+#include "config.h"
+
+#ifdef ENABLE_THREADS
+#include "e-util/e-msgport.h"
+#endif
+
#define CAMEL_NNTP_STORE_TYPE (camel_nntp_store_get_type ())
#define CAMEL_NNTP_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_NNTP_STORE_TYPE, CamelNNTPStore))
#define CAMEL_NNTP_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_NNTP_STORE_TYPE, CamelNNTPStoreClass))
#define CAMEL_IS_NNTP_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_NNTP_STORE_TYPE))
-
enum {
CAMEL_NNTP_OVER_FROM,
CAMEL_NNTP_OVER_SUBJECT,
@@ -79,6 +84,9 @@ struct CamelNNTPStore {
CamelNNTPNewsrc *newsrc;
CamelNNTPGroupList *group_list;
+#ifdef ENABLE_THREADS
+ EMutex *command_lock;
+#endif
};
struct CamelNNTPStoreClass {
@@ -86,6 +94,13 @@ struct CamelNNTPStoreClass {
};
+#ifdef ENABLE_THREADS
+#define CAMEL_NNTP_STORE_LOCK(f) (e_mutex_lock(((CamelNNTPStore *) f)->command_lock))
+#define CAMEL_NNTP_STORE_UNLOCK(f) (e_mutex_unlock(((CamelNNTPStore *) f)->command_lock))
+#else
+#define CAMEL_NNTP_STORE_LOCK(f)
+#define CAMEL_NNTP_STORE_UNLOCK(f)
+#endif
/* public methods */
void camel_nntp_store_open (CamelNNTPStore *store, CamelException *ex);