aboutsummaryrefslogtreecommitdiffstats
path: root/src/vmime/net/imap/IMAPStore.cpp
diff options
context:
space:
mode:
authorJacek Piszczek <[email protected]>2021-03-24 15:08:40 +0000
committerJacek Piszczek <[email protected]>2021-03-24 15:08:40 +0000
commit68f8eb0d39f6902deca9fef4b1c72c0b86963726 (patch)
tree99925f6a493dac880cc4486874d953148d79c0e8 /src/vmime/net/imap/IMAPStore.cpp
parent#250 Fixed unquoted mailbox name (diff)
downloadvmime-68f8eb0d39f6902deca9fef4b1c72c0b86963726.tar.gz
vmime-68f8eb0d39f6902deca9fef4b1c72c0b86963726.zip
Ensure disconnect() method always disconnect the underlying sockets.
Added additional checks after weak pointer locks.
Diffstat (limited to '')
-rw-r--r--src/vmime/net/imap/IMAPStore.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/vmime/net/imap/IMAPStore.cpp b/src/vmime/net/imap/IMAPStore.cpp
index eafa4442..be5c4de7 100644
--- a/src/vmime/net/imap/IMAPStore.cpp
+++ b/src/vmime/net/imap/IMAPStore.cpp
@@ -179,9 +179,7 @@ shared_ptr <IMAPConnection> IMAPStore::getConnection() {
void IMAPStore::disconnect() {
- if (!isConnected()) {
- throw exceptions::not_connected();
- }
+ bool wasConnected = isConnected();
for (std::list <IMAPFolder*>::iterator it = m_folders.begin() ;
it != m_folders.end() ; ++it) {
@@ -191,10 +189,14 @@ void IMAPStore::disconnect() {
m_folders.clear();
+ if (m_connection) {
+ m_connection->disconnect();
+ m_connection = null;
+ }
- m_connection->disconnect();
-
- m_connection = null;
+ if (!wasConnected) {
+ throw exceptions::not_connected();
+ }
}