From e3a451cb33cad9dada930fd5111bcc6c341d5a2b Mon Sep 17 00:00:00 2001 From: Not Zed Date: Tue, 16 Jan 2001 03:54:45 +0000 Subject: Chganged len back to be unsigned. And do a simple range check on the 2001-01-16 Not Zed * camel-folder-summary.c (camel_folder_summary_decode_string): Chganged len back to be unsigned. And do a simple range check on the string value to try and detect corrupted summary files. * providers/imap/camel-imap-command.c (imap_read_untagged): Handle cancelled stream reads with an appropriate exception. * providers/imap/camel-imap-private.h: Fix the include-once macro. Doh, confliced with camel-private.h. * providers/imap/camel-imap-store.c (imap_store_refresh_folders): A copy of camel_remote_store_refresh_folders. We avoid locking each folder when we call it though. This should be removed when i can work out how to remove the folder lock from this function easily. * camel-stream-fs.c (stream_write): Fix n' argument of select. (stream_read): Likewise. * camel-remote-store.c (socket_connect): Bump the connect timeout upto 4 minutes. (socket_connect): Oops, fix the 'n' argument of select. * camel-session.c (camel_cancel_cancel): If we are given no cancellation node, then do it for all active ones. svn path=/trunk/; revision=7526 --- camel/providers/imap/camel-imap-command.c | 9 +++++++++ camel/providers/imap/camel-imap-private.h | 6 +++--- camel/providers/imap/camel-imap-store.c | 28 +++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 4 deletions(-) (limited to 'camel/providers') diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index af61ed0981..db8cdd29dd 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "camel-imap-command.h" #include "camel-imap-utils.h" @@ -283,6 +284,14 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) str->str[0] = '\n'; nread = camel_stream_read (CAMEL_REMOTE_STORE (store)->istream, str->str + 1, length); + if (nread == -1) { + if (errno == EINTR) + camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled")); + else + camel_exception_set(ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, strerror(errno)); + camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + goto lose; + } if (nread < length) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("Server response ended too soon.")); diff --git a/camel/providers/imap/camel-imap-private.h b/camel/providers/imap/camel-imap-private.h index 95ec3a5a0b..abcb3f8dd7 100644 --- a/camel/providers/imap/camel-imap-private.h +++ b/camel/providers/imap/camel-imap-private.h @@ -21,8 +21,8 @@ * USA */ -#ifndef CAMEL_PRIVATE_H -#define CAMEL_PRIVATE_H 1 +#ifndef CAMEL_IMAP_PRIVATE_H +#define CAMEL_IMAP_PRIVATE_H 1 #ifdef __cplusplus extern "C" { @@ -70,5 +70,5 @@ struct _CamelImapFolderPrivate { } #endif /* __cplusplus */ -#endif /* CAMEL_H */ +#endif /* CAMEL_IMAP_PRIVATE_H */ diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index ca4ca2e0d7..275270ecb6 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -48,6 +48,7 @@ #include "string-utils.h" #include "camel-imap-private.h" +#include "camel-private.h" #define d(x) x @@ -283,6 +284,31 @@ query_auth_types (CamelService *service, CamelException *ex) return g_list_prepend (types, &password_authtype); } +/* call refresh folder directly, bypassing the folder lock */ +static void +refresh_folder_info (gpointer key, gpointer value, gpointer data) +{ + CamelFolder *folder = CAMEL_FOLDER (value); + + CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(folder))->refresh_info(folder, data); +} + +/* This is a little 'hack' to avoid the deadlock conditions that would otherwise + ensue when calling camel_folder_refresh_info from inside a lock */ +/* NB: on second thougts this is probably not entirely safe, but it'll do for now */ +/* the alternative is to: + make the camel folder->lock recursive (which should probably be done) + or remove it from camel_folder_refresh_info, and use another locking mechanism */ +static void +imap_store_refresh_folders (CamelRemoteStore *store, CamelException *ex) +{ + CAMEL_STORE_LOCK(store, cache_lock); + + g_hash_table_foreach (CAMEL_STORE (store)->folders, refresh_folder_info, ex); + + CAMEL_STORE_UNLOCK(store, cache_lock); +} + static gboolean imap_connect (CamelService *service, CamelException *ex) { @@ -476,7 +502,7 @@ imap_connect (CamelService *service, CamelException *ex) return FALSE; } - camel_remote_store_refresh_folders (CAMEL_REMOTE_STORE (store), ex); + imap_store_refresh_folders (CAMEL_REMOTE_STORE (store), ex); return !camel_exception_is_set (ex); } -- cgit v1.2.3