[geary/wip/20-cert-pinning: 28/32] Don't update status for IMAP connection problems multiple times
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/20-cert-pinning: 28/32] Don't update status for IMAP connection problems multiple times
- Date: Tue, 8 Jan 2019 13:01:56 +0000 (UTC)
commit e6724151a943c9150dc5030f8be80a5e847f4767
Author: Michael Gratton <mike vee net>
Date: Tue Jan 8 23:49:21 2019 +1100
Don't update status for IMAP connection problems multiple times
This moves connection error notification in ImapClientService to one
place, so status updates and errors are only reported once, and the
correct status changes are made. This fixes TLS cert problems both
being reported as such, and as a service problem.
src/engine/imap/api/imap-client-service.vala | 46 +++++++++++++++-------------
1 file changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/src/engine/imap/api/imap-client-service.vala b/src/engine/imap/api/imap-client-service.vala
index ea18782b..ab26ad02 100644
--- a/src/engine/imap/api/imap-client-service.vala
+++ b/src/engine/imap/api/imap-client-service.vala
@@ -278,26 +278,37 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
}
private async void add_pool_session() {
+ ClientSession? new_session = null;
try {
- ClientSession free = yield this.create_new_authorized_session(
+ new_session = yield this.create_new_authorized_session(
this.pool_cancellable
);
- notify_connected();
- yield this.sessions_mutex.execute_locked(() => {
- this.all_sessions.add(free);
- });
- this.free_queue.send(free);
} catch (ImapError.UNAUTHENTICATED err) {
debug("[%s] Auth error adding new session to the pool: %s",
this.account.id, err.message);
notify_authentication_failed();
- this.close_pool.begin();
- } catch (Error err) {
- if (!(err is IOError.CANCELLED)) {
- debug("[%s] Error adding new session to the pool: %s",
- this.account.id, err.message);
- notify_connection_failed(new ErrorContext(err));
- }
+ } catch (GLib.TlsError.BAD_CERTIFICATE err) {
+ // Don't notify of an error here, since the untrusted host
+ // handler will be dealing with it already.
+ debug("[%s] TLS validation error adding new session to the pool: %s",
+ this.account.id, err.message);
+ } catch (GLib.IOError.CANCELLED err) {
+ // Nothing to do here
+ } catch (GLib.Error err) {
+ Geary.ErrorContext context = new Geary.ErrorContext(err);
+ debug("[%s] Error adding new session to the pool: %s",
+ this.account.id, context.format_full_error());
+ notify_connection_failed(new ErrorContext(err));
+ }
+
+ if (new_session != null) {
+ notify_connected();
+ yield this.sessions_mutex.execute_locked(() => {
+ this.all_sessions.add(new_session);
+ });
+ this.free_queue.send(new_session);
+ } else {
+ // An error was thrown, so close the pool
this.close_pool.begin();
}
}
@@ -366,14 +377,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
private async ClientSession create_new_authorized_session(Cancellable? cancellable) throws Error {
debug("[%s] Opening new session", this.account.id);
ClientSession new_session = new ClientSession(remote);
- try {
- yield new_session.connect_async(cancellable);
- } catch (GLib.Error err) {
- if (!(err is IOError.CANCELLED)) {
- notify_connection_failed(new ErrorContext(err));
- }
- throw err;
- }
+ yield new_session.connect_async(cancellable);
try {
yield new_session.initiate_session_async(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]