wip-commit which passes all tests with proper finalization

This commit is contained in:
holger krekel
2019-07-16 20:05:41 +02:00
parent 43936e7db7
commit 964fe466cc
2 changed files with 23 additions and 21 deletions

View File

@@ -393,19 +393,15 @@ class IOThreads:
def imap_thread_run(self): def imap_thread_run(self):
while not self._thread_quitflag: while not self._thread_quitflag:
lib.dc_perform_imap_jobs(self._dc_context) lib.dc_perform_imap_jobs(self._dc_context)
if self._thread_quitflag:
break
lib.dc_perform_imap_fetch(self._dc_context) lib.dc_perform_imap_fetch(self._dc_context)
if self._thread_quitflag:
break
lib.dc_perform_imap_idle(self._dc_context) lib.dc_perform_imap_idle(self._dc_context)
print("IMAP_THREAD finished")
def smtp_thread_run(self): def smtp_thread_run(self):
while not self._thread_quitflag: while not self._thread_quitflag:
lib.dc_perform_smtp_jobs(self._dc_context) lib.dc_perform_smtp_jobs(self._dc_context)
if self._thread_quitflag:
break
lib.dc_perform_smtp_idle(self._dc_context) lib.dc_perform_smtp_idle(self._dc_context)
print("SMTP_THREAD finished")
class EventLogger: class EventLogger:

View File

@@ -472,7 +472,10 @@ impl Imap {
fn unsetup_handle(&self, context: &Context) { fn unsetup_handle(&self, context: &Context) {
info!(context, 0, "IMAP unsetup_handle starts"); info!(context, 0, "IMAP unsetup_handle starts");
// self.interrupt_idle(); // self.interrupt_idle();
/*
{
let session = self.session.lock().unwrap().take(); let session = self.session.lock().unwrap().take();
info!(context, 0, "IMAP unsetup_handle step1");
if session.is_some() { if session.is_some() {
match session.unwrap().close() { match session.unwrap().close() {
Ok(_) => {} Ok(_) => {}
@@ -481,7 +484,9 @@ impl Imap {
} }
} }
} }
info!(context, 0, "IMAP unsetup_handle2."); }
*/
info!(context, 0, "IMAP unsetup_handle step 2.");
let stream = self.stream.write().unwrap().take(); let stream = self.stream.write().unwrap().take();
if stream.is_some() { if stream.is_some() {
match stream.unwrap().shutdown(net::Shutdown::Both) { match stream.unwrap().shutdown(net::Shutdown::Both) {
@@ -492,11 +497,13 @@ impl Imap {
} }
} }
info!(context, 0, "IMAP unsetup_handle3."); info!(context, 0, "IMAP unsetup_handle step 3.");
{
let mut cfg = self.config.write().unwrap(); let mut cfg = self.config.write().unwrap();
cfg.selected_folder = None; cfg.selected_folder = None;
cfg.selected_mailbox = None; cfg.selected_mailbox = None;
info!(context, 0, "IMAP disconnected.",); }
info!(context, 0, "IMAP unsetup_handle step 4 (disconnected).",);
} }
fn free_connect_params(&self) { fn free_connect_params(&self) {
@@ -581,9 +588,8 @@ impl Imap {
); );
info!(context, 0, "IMAP-capabilities:{}", caps_list); info!(context, 0, "IMAP-capabilities:{}", caps_list);
let mut config = self.config.write().unwrap(); self.config.write().unwrap().can_idle = can_idle;
config.can_idle = can_idle; self.config.write().unwrap().has_xlist = has_xlist;
config.has_xlist = has_xlist;
*self.connected.lock().unwrap() = true; *self.connected.lock().unwrap() = true;
teardown = false; teardown = false;
} }