mirror of
https://github.com/chatmail/core.git
synced 2026-04-23 00:16:34 +03:00
fix some locking issues, start rust-imap impl
This commit is contained in:
committed by
Lars-Magnus Skog
parent
0b3a4b4c13
commit
e7d72dfdd4
@@ -150,7 +150,7 @@ unsafe extern "C" fn receive_event(
|
||||
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut tempFile: *mut libc::c_char = dc_get_fine_pathNfilename(
|
||||
context,
|
||||
(*context).blobdir,
|
||||
context.get_blobdir(),
|
||||
b"curl.result\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let mut cmd: *mut libc::c_char = if event == Event::HTTP_GET {
|
||||
@@ -279,12 +279,16 @@ unsafe fn start_threads(
|
||||
run_threads = 1;
|
||||
let context = c.clone();
|
||||
let h1 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
|
||||
println!("-- imap jobs");
|
||||
dc_perform_imap_jobs(&context);
|
||||
println!("-- imap fetch");
|
||||
dc_perform_imap_fetch(&context);
|
||||
if 0 != run_threads {
|
||||
println!("-- imap idle");
|
||||
dc_perform_imap_idle(&context);
|
||||
}
|
||||
}
|
||||
@@ -292,38 +296,38 @@ unsafe fn start_threads(
|
||||
|
||||
let context = c.clone();
|
||||
let h2 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
dc_perform_mvbox_fetch(&context);
|
||||
if 0 != run_threads {
|
||||
dc_perform_mvbox_idle(&context);
|
||||
}
|
||||
}
|
||||
// let ctx = context.clone();
|
||||
// let context = ctx.read().unwrap();
|
||||
// while 0 != run_threads {
|
||||
// dc_perform_mvbox_fetch(&context);
|
||||
// if 0 != run_threads {
|
||||
// dc_perform_mvbox_idle(&context);
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
let context = c.clone();
|
||||
let h3 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
dc_perform_sentbox_fetch(&context);
|
||||
if 0 != run_threads {
|
||||
dc_perform_sentbox_idle(&context);
|
||||
}
|
||||
}
|
||||
// let ctx = context.clone();
|
||||
// let context = ctx.read().unwrap();
|
||||
// while 0 != run_threads {
|
||||
// dc_perform_sentbox_fetch(&context);
|
||||
// if 0 != run_threads {
|
||||
// dc_perform_sentbox_idle(&context);
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
let context = c.clone();
|
||||
let h4 = std::thread::spawn(move || {
|
||||
let ctx = context.clone();
|
||||
let context = ctx.read().unwrap();
|
||||
while 0 != run_threads {
|
||||
dc_perform_smtp_jobs(&context);
|
||||
if 0 != run_threads {
|
||||
dc_perform_smtp_idle(&context);
|
||||
}
|
||||
}
|
||||
// let ctx = context.clone();
|
||||
// let context = ctx.read().unwrap();
|
||||
// while 0 != run_threads {
|
||||
// dc_perform_smtp_jobs(&context);
|
||||
// if 0 != run_threads {
|
||||
// dc_perform_smtp_idle(&context);
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
(h1, h2, h3, h4)
|
||||
@@ -391,8 +395,6 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
let ctx = Arc::new(RwLock::new(context));
|
||||
|
||||
loop {
|
||||
let ctx = ctx.clone();
|
||||
|
||||
/* read command */
|
||||
let cmdline = read_cmd();
|
||||
free(cmd as *mut libc::c_void);
|
||||
@@ -426,10 +428,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
dc_perform_imap_jobs(&ctx.read().unwrap());
|
||||
}
|
||||
} else if strcmp(cmd, b"configure\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
handles = {
|
||||
let ctx = ctx.clone();
|
||||
Some(start_threads(ctx))
|
||||
};
|
||||
handles = { Some(start_threads(ctx.clone())) };
|
||||
dc_configure(&ctx.read().unwrap());
|
||||
} else if strcmp(cmd, b"oauth2\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
let mut addr: *mut libc::c_char = dc_get_config(
|
||||
@@ -463,10 +462,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
} else if strcmp(cmd, b"getqr\x00" as *const u8 as *const libc::c_char) == 0i32
|
||||
|| strcmp(cmd, b"getbadqr\x00" as *const u8 as *const libc::c_char) == 0i32
|
||||
{
|
||||
handles = {
|
||||
let ctx = ctx.clone();
|
||||
Some(start_threads(ctx))
|
||||
};
|
||||
handles = Some(start_threads(ctx.clone()));
|
||||
let mut qrstr: *mut libc::c_char = dc_get_securejoin_qr(
|
||||
&ctx.read().unwrap(),
|
||||
(if !arg1.is_null() { atoi(arg1) } else { 0i32 }) as uint32_t,
|
||||
@@ -491,10 +487,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
|
||||
}
|
||||
free(qrstr as *mut libc::c_void);
|
||||
} else if strcmp(cmd, b"joinqr\x00" as *const u8 as *const libc::c_char) == 0i32 {
|
||||
handles = {
|
||||
let ctx = ctx.clone();
|
||||
Some(start_threads(ctx))
|
||||
};
|
||||
handles = Some(start_threads(ctx.clone()));
|
||||
if !arg1.is_null() {
|
||||
dc_join_securejoin(&ctx.read().unwrap(), arg1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user