diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-11-17 06:55:45 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-11-17 06:55:45 +0800 |
commit | 5701b20541935f11123f484babbeced3d8f1d385 (patch) | |
tree | 68a10b25048c22d4f0069db8e563fb8662f1d581 | |
parent | e0103cdf6eb30c6ff17797ea341fe24b9e2987a3 (diff) | |
download | gsoc2013-evolution-5701b20541935f11123f484babbeced3d8f1d385.tar gsoc2013-evolution-5701b20541935f11123f484babbeced3d8f1d385.tar.gz gsoc2013-evolution-5701b20541935f11123f484babbeced3d8f1d385.tar.bz2 gsoc2013-evolution-5701b20541935f11123f484babbeced3d8f1d385.tar.lz gsoc2013-evolution-5701b20541935f11123f484babbeced3d8f1d385.tar.xz gsoc2013-evolution-5701b20541935f11123f484babbeced3d8f1d385.tar.zst gsoc2013-evolution-5701b20541935f11123f484babbeced3d8f1d385.zip |
If we get a BYE response, call camel_service_disconnect() and set an
2001-11-14 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap/camel-imap-command.c
(camel_imap_command_response): If we get a BYE response, call
camel_service_disconnect() and set an exception. Also do the check
for "* BYE" first instead of passing it off imap_read_untagged()
since we'll just waste time in there mallocing left and right only
to arrive at the single response line "* BYE" again :-)
svn path=/trunk/; revision=14735
-rw-r--r-- | camel/ChangeLog | 9 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-command.c | 33 |
2 files changed, 29 insertions, 13 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 82eeb7e846..971f8b1c4a 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,12 @@ +2001-11-14 Jeffrey Stedfast <fejj@ximian.com> + + * providers/imap/camel-imap-command.c + (camel_imap_command_response): If we get a BYE response, call + camel_service_disconnect() and set an exception. Also do the check + for "* BYE" first instead of passing it off imap_read_untagged() + since we'll just waste time in there mallocing left and right only + to arrive at the single response line "* BYE" again :-) + 2001-11-13 <NotZed@Ximian.com> * camel-filter-search.c (get_source): If we have no source string, diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index 5639741a42..3afb9af82f 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -267,18 +267,25 @@ camel_imap_command_response (CamelImapStore *store, char **response, switch (*respbuf) { case '*': - type = CAMEL_IMAP_RESPONSE_UNTAGGED; - - /* Read the rest of the response if it is multi-line. */ - respbuf = imap_read_untagged (store, respbuf, ex); - if (!respbuf) - type = CAMEL_IMAP_RESPONSE_ERROR; - else if (!g_strncasecmp (respbuf, "* BYE", 5)) { + if (!g_strncasecmp (respbuf, "* BYE", 5)) { /* Connection was lost, no more data to fetch */ + camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, + _("Server unexpectedly disconnected: %s"), + _("Unknown error")); /* g_strerror (104)); FIXME after 1.0 is released */ store->connected = FALSE; g_free (respbuf); + respbuf = NULL; type = CAMEL_IMAP_RESPONSE_ERROR; + break; } + + /* Read the rest of the response. */ + type = CAMEL_IMAP_RESPONSE_UNTAGGED; + respbuf = imap_read_untagged (store, respbuf, ex); + if (!respbuf) + type = CAMEL_IMAP_RESPONSE_ERROR; + break; case '+': type = CAMEL_IMAP_RESPONSE_CONTINUATION; @@ -292,6 +299,7 @@ camel_imap_command_response (CamelImapStore *store, char **response, if (type == CAMEL_IMAP_RESPONSE_ERROR || type == CAMEL_IMAP_RESPONSE_TAGGED) CAMEL_IMAP_STORE_UNLOCK (store, command_lock); + return type; } @@ -398,17 +406,16 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) str->str + 1, length); if (nread == -1) { if (errno == EINTR) - camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled")); + camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled")); else - camel_exception_set(ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, strerror(errno)); + camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, g_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.")); - camel_service_disconnect (CAMEL_SERVICE (store), - FALSE, NULL); + camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, + _("Server response ended too soon.")); + camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); goto lose; } str->str[length + 1] = '\0'; |