[evolution-patches] 66509, nntp fixes
- From: Not Zed <notzed ximian com>
- To: asdf <evolution-patches lists ximian com>
- Subject: [evolution-patches] 66509, nntp fixes
- Date: Tue, 28 Sep 2004 10:34:12 +0800
Whilst working on 66509 i found a bunch of other issues.
This should fix the deadlocks and the assertion failure. Most of it is just a lock rename, the meat is in nntp_command where it was disconnecting on some io errors or user cancellations.
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2251.2.6
diff -u -p -r1.2251.2.6 ChangeLog
--- camel/ChangeLog 27 Sep 2004 05:21:17 -0000 1.2251.2.6
+++ camel/ChangeLog 28 Sep 2004 02:36:08 -0000
@@ -1,3 +1,25 @@
+2004-09-28 Not Zed <NotZed Ximian com>
+
+ ** See bug #66509.
+
+ * providers/nntp/camel-nntp-store.c (camel_nntp_command): if we
+ get an error selecting the folder, disconnect/include it in the
+ re-try loop.
+ (camel_nntp_command): don't set the exception based on errno,
+ exception processing is already done. don't clear it if we're on
+ the 3rd retry.
+
+2004-09-27 Not Zed <NotZed Ximian com>
+
+ * providers/nntp/camel-nntp-store.c (nntp_get_folder_info): don't
+ do any locking here.
+ (nntp_store_get_folder_info_all): move the locking here.
+ (nntp_store_get_subscribed_folder_info): and some here too.
+
+ * providers/nntp/camel-nntp-store.c:
+ * providers/nntp/camel-nntp-folder.c: Remove nntp command_lock and
+ just use the service connect lock for serialisation.
+
2004-09-21 Not Zed <NotZed Ximian com>
** See bug #63521.
Index: camel/providers/nntp/camel-nntp-folder.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-folder.c,v
retrieving revision 1.48
diff -u -p -r1.48 camel-nntp-folder.c
--- camel/providers/nntp/camel-nntp-folder.c 3 Jun 2004 09:29:08 -0000 1.48
+++ camel/providers/nntp/camel-nntp-folder.c 28 Sep 2004 02:36:09 -0000
@@ -21,7 +21,6 @@
* USA
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -50,6 +49,7 @@
#include "camel/camel-multipart.h"
#include "camel/camel-mime-part.h"
#include "camel/camel-stream-buffer.h"
+#include "camel/camel-private.h"
#include "camel-nntp-summary.h"
#include "camel-nntp-store.h"
@@ -84,7 +84,7 @@ nntp_folder_refresh_info_online (CamelFo
nntp_store = (CamelNNTPStore *) folder->parent_store;
nntp_folder = (CamelNNTPFolder *) folder;
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
camel_nntp_command(nntp_store, ex, nntp_folder, &line, NULL);
@@ -93,7 +93,7 @@ nntp_folder_refresh_info_online (CamelFo
nntp_folder->changes = camel_folder_change_info_new();
}
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
if (changes) {
camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
@@ -104,17 +104,17 @@ nntp_folder_refresh_info_online (CamelFo
static void
nntp_folder_sync_online (CamelFolder *folder, CamelException *ex)
{
- CAMEL_NNTP_STORE_LOCK(folder->parent_store, command_lock);
+ CAMEL_SERVICE_LOCK(folder->parent_store, connect_lock);
camel_folder_summary_save (folder->summary);
- CAMEL_NNTP_STORE_UNLOCK(folder->parent_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(folder->parent_store, connect_lock);
}
static void
nntp_folder_sync_offline (CamelFolder *folder, CamelException *ex)
{
- CAMEL_NNTP_STORE_LOCK(folder->parent_store, command_lock);
+ CAMEL_SERVICE_LOCK(folder->parent_store, connect_lock);
camel_folder_summary_save (folder->summary);
- CAMEL_NNTP_STORE_UNLOCK(folder->parent_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(folder->parent_store, connect_lock);
}
static gboolean
@@ -178,13 +178,13 @@ nntp_folder_cache_message (CamelDiscoFol
}
*msgid++ = 0;
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
stream = nntp_folder_download_message ((CamelNNTPFolder *) disco_folder, article, msgid, ex);
if (stream)
camel_object_unref (stream);
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
}
static CamelMimeMessage *
@@ -210,7 +210,7 @@ nntp_folder_get_message (CamelFolder *fo
}
*msgid++ = 0;
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
/* Lookup in cache, NEWS is global messageid's so use a global cache path */
stream = camel_data_cache_get (nntp_store->cache, "cache", msgid, NULL);
@@ -245,7 +245,7 @@ fail:
changes = NULL;
}
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
if (changes) {
camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
@@ -318,7 +318,7 @@ nntp_folder_append_message_online (Camel
struct _camel_header_raw *header, *savedhdrs, *n, *tail;
char *group, *line;
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
/* send 'POST' command */
ret = camel_nntp_command (nntp_store, ex, NULL, &line, "post");
@@ -329,7 +329,7 @@ nntp_folder_append_message_online (Camel
else if (ret != -1)
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Posting failed: %s"), line);
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
return;
}
@@ -379,7 +379,7 @@ nntp_folder_append_message_online (Camel
g_free(group);
header->next = savedhdrs;
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
return;
}
Index: camel/providers/nntp/camel-nntp-private.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-private.h,v
retrieving revision 1.2
diff -u -p -r1.2 camel-nntp-private.h
--- camel/providers/nntp/camel-nntp-private.h 9 Jul 2003 19:21:59 -0000 1.2
+++ camel/providers/nntp/camel-nntp-private.h 28 Sep 2004 02:36:09 -0000
@@ -38,7 +38,7 @@ extern "C" {
#include "e-util/e-msgport.h"
struct _CamelNNTPStorePrivate {
- EMutex *command_lock; /* for locking the command stream for a complete operation */
+ int dummy;
};
#define CAMEL_NNTP_STORE_LOCK(f, l) (e_mutex_lock(((CamelNNTPStore *)f)->priv->l))
Index: camel/providers/nntp/camel-nntp-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-store.c,v
retrieving revision 1.65.14.2
diff -u -p -r1.65.14.2 camel-nntp-store.c
--- camel/providers/nntp/camel-nntp-store.c 23 Sep 2004 04:12:29 -0000 1.65.14.2
+++ camel/providers/nntp/camel-nntp-store.c 28 Sep 2004 02:36:10 -0000
@@ -21,7 +21,6 @@
* USA
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -45,6 +44,7 @@
#include <camel/camel-disco-store.h>
#include <camel/camel-disco-diary.h>
+#include "camel/camel-private.h"
#include "camel-nntp-summary.h"
#include "camel-nntp-store.h"
@@ -167,7 +167,7 @@ connect_to_server (CamelService *service
struct addrinfo *ai, hints = { 0 };
char *serv;
- CAMEL_NNTP_STORE_LOCK(store, command_lock);
+ CAMEL_SERVICE_LOCK(store, connect_lock);
/* setup store-wide cache */
if (store->cache == NULL) {
@@ -273,7 +273,7 @@ connect_to_server (CamelService *service
store->current_folder = NULL;
fail:
- CAMEL_NNTP_STORE_UNLOCK(store, command_lock);
+ CAMEL_SERVICE_UNLOCK(store, connect_lock);
return retval;
}
@@ -366,7 +366,7 @@ nntp_disconnect_online (CamelService *se
CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
char *line;
- CAMEL_NNTP_STORE_LOCK(store, command_lock);
+ CAMEL_SERVICE_LOCK(store, connect_lock);
if (clean) {
camel_nntp_raw_command (store, ex, &line, "quit");
@@ -374,7 +374,7 @@ nntp_disconnect_online (CamelService *se
}
if (!service_class->disconnect (service, clean, ex)) {
- CAMEL_NNTP_STORE_UNLOCK(store, command_lock);
+ CAMEL_SERVICE_UNLOCK(store, connect_lock);
return FALSE;
}
@@ -383,7 +383,7 @@ nntp_disconnect_online (CamelService *se
g_free(store->current_folder);
store->current_folder = NULL;
- CAMEL_NNTP_STORE_UNLOCK(store, command_lock);
+ CAMEL_SERVICE_UNLOCK(store, connect_lock);
return TRUE;
}
@@ -428,11 +428,11 @@ nntp_get_folder(CamelStore *store, const
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
CamelFolder *folder;
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
folder = camel_nntp_folder_new(store, folder_name, ex);
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
return folder;
}
@@ -612,7 +612,9 @@ nntp_store_get_subscribed_folder_info (C
folder = (CamelNNTPFolder *)camel_store_get_folder((CamelStore *)store, si->path, 0, ex);
if (folder) {
+ CAMEL_SERVICE_LOCK(store, connect_lock);
camel_nntp_command(store, ex, folder, &line, NULL);
+ CAMEL_SERVICE_UNLOCK(store, connect_lock);
camel_object_unref(folder);
}
camel_exception_clear(ex);
@@ -742,6 +744,9 @@ nntp_store_get_folder_info_all(CamelNNTP
unsigned int len;
unsigned char *line;
int ret = -1;
+ CamelFolderInfo *fi = NULL;
+
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
if (top == NULL)
top = "";
@@ -756,11 +761,11 @@ nntp_store_get_folder_info_all(CamelNNTP
date[13] = '\0';
if (!nntp_get_date (nntp_store, ex))
- return NULL;
+ goto error;
ret = camel_nntp_command (nntp_store, ex, NULL, (char **) &line, "newgroups %s", date);
if (ret == -1)
- return NULL;
+ goto error;
else if (ret != 231) {
/* newgroups not supported :S so reload the complete list */
summary->last_newslist[0] = 0;
@@ -781,7 +786,7 @@ nntp_store_get_folder_info_all(CamelNNTP
ret = camel_nntp_command (nntp_store, ex, NULL, (char **)&line, "list");
if (ret == -1)
- return NULL;
+ goto error;
else if (ret != 215) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_INVALID,
_("Error retrieving newsgroups:\n\n%s"), line);
@@ -809,9 +814,11 @@ nntp_store_get_folder_info_all(CamelNNTP
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
}
- return nntp_store_get_cached_folder_info (nntp_store, top, flags, ex);
+ fi = nntp_store_get_cached_folder_info (nntp_store, top, flags, ex);
error:
- return NULL;
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+
+ return fi;
}
static CamelFolderInfo *
@@ -827,14 +834,11 @@ nntp_get_folder_info (CamelStore *store,
online,
top?top:""));
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
-
if (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)
first = nntp_store_get_subscribed_folder_info (nntp_store, top, flags, ex);
else
first = nntp_store_get_folder_info_all (nntp_store, top, flags, online, ex);
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
return first;
}
@@ -874,7 +878,7 @@ nntp_store_subscribe_folder (CamelStore
CamelStoreInfo *si;
CamelFolderInfo *fi;
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
si = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
if (!si) {
@@ -888,14 +892,14 @@ nntp_store_subscribe_folder (CamelStore
fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN;
camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
camel_object_trigger_event ((CamelObject *) nntp_store, "folder_subscribed", fi);
camel_folder_info_free (fi);
return;
}
}
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
}
static void
@@ -905,7 +909,7 @@ nntp_store_unsubscribe_folder (CamelStor
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
CamelFolderInfo *fi;
CamelStoreInfo *fitem;
- CAMEL_NNTP_STORE_LOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
fitem = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
@@ -919,14 +923,14 @@ nntp_store_unsubscribe_folder (CamelStor
fi = nntp_folder_info_from_store_info (nntp_store, nntp_store->do_short_folder_notation, fitem);
camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
camel_object_trigger_event ((CamelObject *) nntp_store, "folder_unsubscribed", fi);
camel_folder_info_free (fi);
return;
}
}
- CAMEL_NNTP_STORE_UNLOCK(nntp_store, command_lock);
+ CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
}
/* stubs for various folder operations we're not implementing */
@@ -988,8 +992,6 @@ nntp_store_finalize (CamelObject *object
xover = xn;
}
- e_mutex_destroy(p->command_lock);
-
g_free(p);
}
@@ -1092,7 +1094,6 @@ nntp_store_init (gpointer object, gpoint
nntp_store->mem = (CamelStreamMem *)camel_stream_mem_new();
p = nntp_store->priv = g_malloc0(sizeof(*p));
- p->command_lock = e_mutex_new(E_MUTEX_REC);
}
CamelType
@@ -1173,7 +1174,7 @@ camel_nntp_raw_commandv (CamelNNTPStore
int d;
unsigned int u, u2;
- e_mutex_assert_locked(store->priv->command_lock);
+ e_mutex_assert_locked(((CamelService *)store)->priv->connect_lock);
g_assert(store->stream->mode != CAMEL_NNTP_STREAM_DATA);
camel_nntp_stream_set_mode(store->stream, CAMEL_NNTP_STREAM_LINE);
@@ -1268,7 +1269,7 @@ camel_nntp_command (CamelNNTPStore *stor
int ret, retry;
unsigned int u;
- e_mutex_assert_locked(store->priv->command_lock);
+ e_mutex_assert_locked(((CamelService *)store)->priv->connect_lock);
if (((CamelDiscoStore *)store)->status == CAMEL_DISCO_STORE_OFFLINE) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
@@ -1299,8 +1300,10 @@ camel_nntp_command (CamelNNTPStore *stor
g_free(store->current_folder);
store->current_folder = g_strdup(((CamelFolder *)folder)->full_name);
camel_nntp_folder_selected(folder, *line, ex);
- if (camel_exception_is_set(ex))
- return -1;
+ if (camel_exception_is_set(ex)) {
+ ret = -1;
+ goto error;
+ }
} else {
goto error;
}
@@ -1330,19 +1333,12 @@ camel_nntp_command (CamelNNTPStore *stor
continue;
case -1: /* i/o error */
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
- if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL)
+ if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL || retry >= 3)
return -1;
camel_exception_clear(ex);
break;
}
} while (ret == -1 && retry < 3);
- if (ret == -1) {
- if (errno == EINTR)
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled."));
- else
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("NNTP Command failed: %s"), g_strerror(errno));
- }
-
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]