Merge pull request #445 from deltachat/smtp_error

Avoid panic on SMTP error
This commit is contained in:
Alexander Krotov
2019-09-05 20:22:24 +00:00
committed by GitHub
2 changed files with 6 additions and 5 deletions

View File

@@ -156,7 +156,7 @@ impl Job {
let mut sock = context.smtp.lock().unwrap();
if 0 == sock.send(context, recipients_list, body) {
sock.disconnect();
self.try_again_later(-1i32, Some(as_str(sock.error)));
self.try_again_later(-1i32, sock.error.clone());
} else {
dc_delete_file(context, filename);
if 0 != self.foreign_id {
@@ -189,9 +189,9 @@ impl Job {
}
// this value does not increase the number of tries
fn try_again_later(&mut self, try_again: libc::c_int, pending_error: Option<&str>) {
fn try_again_later(&mut self, try_again: libc::c_int, pending_error: Option<String>) {
self.try_again = try_again;
self.pending_error = pending_error.map(|s| s.to_string());
self.pending_error = pending_error;
}
#[allow(non_snake_case)]

View File

@@ -12,7 +12,7 @@ pub struct Smtp {
transport_connected: bool,
/// Email address we are sending from.
from: Option<EmailAddress>,
pub error: *mut libc::c_char,
pub error: Option<String>,
}
impl Smtp {
@@ -22,7 +22,7 @@ impl Smtp {
transport: None,
transport_connected: false,
from: None,
error: std::ptr::null_mut(),
error: None,
}
}
@@ -152,6 +152,7 @@ impl Smtp {
}
Err(err) => {
warn!(context, 0, "SMTP failed to send message: {}", err);
self.error = Some(format!("{}", err));
0
}
}