From b26fe2240f76b9ca8dc6a3a05e26bd55d3be4a86 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Sat, 20 Feb 2010 18:16:45 +0000 Subject: [PATCH] 2010-02-20 [colin] 3.7.5cvs22 * src/imap.c * src/imap.h * src/main.c * src/mainwindow.c * src/etpan/imap-thread.c * src/etpan/imap-thread.h * src/etpan/nntp-thread.c * src/etpan/nntp-thread.h When going offline from NetworkManager, just delete IMAP connections. That'll avoid timeouts when coming back online in certain cases when the TCP socket will have timed out. --- ChangeLog | 15 +++++++++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/etpan/imap-thread.c | 6 +++--- src/etpan/imap-thread.h | 2 +- src/etpan/nntp-thread.c | 4 ++-- src/etpan/nntp-thread.h | 2 +- src/imap.c | 7 ++++--- src/imap.h | 2 +- src/main.c | 10 ++++++++-- src/mainwindow.c | 3 +-- 11 files changed, 38 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 176629c96..7eaab246d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-02-20 [colin] 3.7.5cvs22 + + * src/imap.c + * src/imap.h + * src/main.c + * src/mainwindow.c + * src/etpan/imap-thread.c + * src/etpan/imap-thread.h + * src/etpan/nntp-thread.c + * src/etpan/nntp-thread.h + When going offline from NetworkManager, just + delete IMAP connections. That'll avoid timeouts + when coming back online in certain cases when + the TCP socket will have timed out. + 2010-02-20 [holger] 3.7.5cvs21 * .cvsignore diff --git a/PATCHSETS b/PATCHSETS index 23d2c8f90..1d2c7d83b 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -3962,3 +3962,4 @@ ( cvs diff -u -r 1.395.2.417 -r 1.395.2.418 src/summaryview.c; cvs diff -u -r 1.68.2.53 -r 1.68.2.54 src/summaryview.h; cvs diff -u -r 1.43.2.113 -r 1.43.2.114 src/toolbar.c; ) > 3.7.5cvs19.patchset ( cvs diff -u -r 1.395.2.418 -r 1.395.2.419 src/summaryview.c; cvs diff -u -r 1.68.2.54 -r 1.68.2.55 src/summaryview.h; cvs diff -u -r 1.43.2.114 -r 1.43.2.115 src/toolbar.c; ) > 3.7.5cvs20.patchset ( cvs diff -u -r 1.8.2.7 -r 1.8.2.8 .cvsignore; ) > 3.7.5cvs21.patchset +( cvs diff -u -r 1.179.2.249 -r 1.179.2.250 src/imap.c; cvs diff -u -r 1.34.2.21 -r 1.34.2.22 src/imap.h; cvs diff -u -r 1.115.2.224 -r 1.115.2.225 src/main.c; cvs diff -u -r 1.274.2.306 -r 1.274.2.307 src/mainwindow.c; cvs diff -u -r 1.1.4.110 -r 1.1.4.111 src/etpan/imap-thread.c; cvs diff -u -r 1.1.4.26 -r 1.1.4.27 src/etpan/imap-thread.h; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/etpan/nntp-thread.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/etpan/nntp-thread.h; ) > 3.7.5cvs22.patchset diff --git a/configure.ac b/configure.ac index 3df7c647c..82be81f95 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ MINOR_VERSION=7 MICRO_VERSION=5 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=21 +EXTRA_VERSION=22 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c index ab2125216..8cb700d0a 100644 --- a/src/etpan/imap-thread.c +++ b/src/etpan/imap-thread.c @@ -296,9 +296,9 @@ void imap_main_set_timeout(int sec) mailstream_network_delay.tv_usec = 0; } -void imap_main_done(void) +void imap_main_done(gboolean have_connectivity) { - imap_disconnect_all(); + imap_disconnect_all(have_connectivity); etpan_thread_manager_stop(thread_manager); #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) return; @@ -3398,7 +3398,7 @@ void imap_threaded_cancel(Folder * folder) void imap_main_init(void) { } -void imap_main_done(void) +void imap_main_done(gboolean have_connectivity) { } void imap_main_set_timeout(int sec) diff --git a/src/etpan/imap-thread.h b/src/etpan/imap-thread.h index 868bfe282..37eaf349d 100644 --- a/src/etpan/imap-thread.h +++ b/src/etpan/imap-thread.h @@ -40,7 +40,7 @@ typedef enum void imap_main_set_timeout(int sec); void imap_main_init(gboolean skip_ssl_cert_check); -void imap_main_done(void); +void imap_main_done(gboolean have_connectivity); void imap_init(Folder * folder); void imap_done(Folder * folder); diff --git a/src/etpan/nntp-thread.c b/src/etpan/nntp-thread.c index eb6e393e8..47a59a389 100644 --- a/src/etpan/nntp-thread.c +++ b/src/etpan/nntp-thread.c @@ -156,7 +156,7 @@ void nntp_main_init(gboolean skip_ssl_cert_check) NULL); } -void nntp_main_done(void) +void nntp_main_done(gboolean have_connectivity) { etpan_thread_manager_stop(thread_manager); #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) @@ -1005,7 +1005,7 @@ int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32 void nntp_main_init(void) { } -void nntp_main_done(void) +void nntp_main_done(gboolean have_connectivity) { } void nntp_main_set_timeout(int sec) diff --git a/src/etpan/nntp-thread.h b/src/etpan/nntp-thread.h index cab2eca03..0a09ddca6 100644 --- a/src/etpan/nntp-thread.h +++ b/src/etpan/nntp-thread.h @@ -26,7 +26,7 @@ void nntp_main_set_timeout(int sec); void nntp_main_init(gboolean skip_ssl_cert_check); -void nntp_main_done(void); +void nntp_main_done(gboolean have_connectivity); void nntp_init(Folder * folder); void nntp_done(Folder * folder); diff --git a/src/imap.c b/src/imap.c index 828133de3..4498f5de3 100644 --- a/src/imap.c +++ b/src/imap.c @@ -5398,7 +5398,7 @@ void imap_folder_ref(Folder *folder) ((IMAPFolder *)folder)->refcnt++; } -void imap_disconnect_all(void) +void imap_disconnect_all(gboolean have_connectivity) { GList *list; gboolean short_timeout; @@ -5426,7 +5426,8 @@ void imap_disconnect_all(void) RemoteFolder *folder = (RemoteFolder *)account->folder; if (folder && folder->session) { IMAPSession *session = (IMAPSession *)folder->session; - imap_threaded_disconnect(FOLDER(folder)); + if (have_connectivity) + imap_threaded_disconnect(FOLDER(folder)); SESSION(session)->state = SESSION_DISCONNECTED; SESSION(session)->sock = NULL; session_destroy(SESSION(session)); @@ -5571,7 +5572,7 @@ FolderClass *imap_get_class(void) return &imap_class; } -void imap_disconnect_all(void) +void imap_disconnect_all(gboolean have_connectivity) { } diff --git a/src/imap.h b/src/imap.h index 2dc9a12df..80ccbdf8d 100644 --- a/src/imap.h +++ b/src/imap.h @@ -36,7 +36,7 @@ guint imap_folder_get_refcnt(Folder *folder); void imap_folder_ref(Folder *folder); void imap_folder_unref(Folder *folder); gchar imap_get_path_separator_for_item (FolderItem *item); -void imap_disconnect_all(void); +void imap_disconnect_all(gboolean have_connectivity); gint imap_subscribe(Folder *folder, FolderItem *item, gchar *rpath, gboolean sub); GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only, gboolean recursive); void imap_cache_msg(FolderItem *item, gint msgnum); diff --git a/src/main.c b/src/main.c index 3398f2514..854caa94b 100644 --- a/src/main.c +++ b/src/main.c @@ -1696,6 +1696,7 @@ static void save_all_caches(FolderItem *item, gpointer data) static void exit_claws(MainWindow *mainwin) { gchar *filename; + gboolean have_connectivity; sc_exiting = TRUE; @@ -1738,9 +1739,14 @@ static void exit_claws(MainWindow *mainwin) close_log_file(LOG_PROTOCOL); close_log_file(LOG_DEBUG_FILTERING); +#ifdef HAVE_NETWORKMANAGER_SUPPORT + have_connectivity = networkmanager_is_online(NULL); +#else + have_connectivity = TRUE; +#endif #ifdef HAVE_LIBETPAN - imap_main_done(); - nntp_main_done(); + imap_main_done(have_connectivity); + nntp_main_done(have_connectivity); #endif /* delete crashfile */ if (!cmd.crash) diff --git a/src/mainwindow.c b/src/mainwindow.c index 7da44308e..919ea8df7 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -4230,8 +4230,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data) if(have_connectivity) mainwindow_check_synchronise(mainwin, TRUE); prefs_common.work_offline = TRUE; - if(have_connectivity) - imap_disconnect_all(); + imap_disconnect_all(have_connectivity); hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL); } else { /*go online */ -- 2.25.1