From 83a474a94ccf4fefc584abae4f3f59688cf1c209 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Thu, 1 Nov 2018 15:48:21 +0100 Subject: [PATCH 01/11] load desired_timestamp, added_timestamp, tries to dc_job_t structure --- src/dc_job.c | 34 ++++++++++++++++++++++------------ src/dc_job.h | 3 +++ src/dc_param.h | 1 - src/dc_sqlite3.c | 9 +++++++++ 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/dc_job.c b/src/dc_job.c index 55518756..e820f86e 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -432,7 +432,7 @@ void dc_job_add(dc_context_t* context, int action, int foreign_id, const char* p sqlite3_bind_int (stmt, 3, action); sqlite3_bind_int (stmt, 4, foreign_id); sqlite3_bind_text (stmt, 5, param? param : "", -1, SQLITE_STATIC); - sqlite3_bind_int64(stmt, 6, delay_seconds>0? (timestamp+delay_seconds) : 0); + sqlite3_bind_int64(stmt, 6, timestamp+delay_seconds); sqlite3_step(stmt); sqlite3_finalize(stmt); @@ -447,12 +447,16 @@ void dc_job_add(dc_context_t* context, int action, int foreign_id, const char* p static void dc_job_update(dc_context_t* context, const dc_job_t* job) { - sqlite3_stmt* update_stmt = dc_sqlite3_prepare(context->sql, - "UPDATE jobs SET desired_timestamp=0, param=? WHERE id=?;"); - sqlite3_bind_text (update_stmt, 1, job->param->packed, -1, SQLITE_STATIC); - sqlite3_bind_int (update_stmt, 2, job->job_id); - sqlite3_step(update_stmt); - sqlite3_finalize(update_stmt); + sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, + "UPDATE jobs" + " SET desired_timestamp=?, tries=?, param=?" + " WHERE id=?;"); + sqlite3_bind_int64(stmt, 1, job->desired_timestamp); + sqlite3_bind_int64(stmt, 2, job->tries); + sqlite3_bind_text (stmt, 3, job->param->packed, -1, SQLITE_STATIC); + sqlite3_bind_int (stmt, 4, job->job_id); + sqlite3_step(stmt); + sqlite3_finalize(stmt); } @@ -509,15 +513,21 @@ static void dc_job_perform(dc_context_t* context, int thread) } select_stmt = dc_sqlite3_prepare(context->sql, - "SELECT id, action, foreign_id, param FROM jobs WHERE thread=? AND desired_timestamp<=? ORDER BY action DESC, added_timestamp;"); + "SELECT id, action, foreign_id, param, added_timestamp, desired_timestamp, tries" + " FROM jobs" + " WHERE thread=? AND desired_timestamp<=?" + " ORDER BY action DESC, added_timestamp DESC;"); sqlite3_bind_int64(select_stmt, 1, thread); sqlite3_bind_int64(select_stmt, 2, time(NULL)); while (sqlite3_step(select_stmt)==SQLITE_ROW) { - job.job_id = sqlite3_column_int (select_stmt, 0); - job.action = sqlite3_column_int (select_stmt, 1); - job.foreign_id = sqlite3_column_int (select_stmt, 2); - dc_param_set_packed(job.param, (char*)sqlite3_column_text(select_stmt, 3)); + job.job_id = sqlite3_column_int (select_stmt, 0); + job.action = sqlite3_column_int (select_stmt, 1); + job.foreign_id = sqlite3_column_int (select_stmt, 2); + dc_param_set_packed(job.param, (char*)sqlite3_column_text (select_stmt, 3)); + job.added_timestamp = sqlite3_column_int64(select_stmt, 4); + job.desired_timestamp = sqlite3_column_int64(select_stmt, 5); + job.tries = sqlite3_column_int (select_stmt, 6); dc_log_info(context, 0, "%s-job #%i, action %i started...", THREAD_STR, (int)job.job_id, (int)job.action); diff --git a/src/dc_job.h b/src/dc_job.h index dfc57568..fa9162b3 100644 --- a/src/dc_job.h +++ b/src/dc_job.h @@ -46,6 +46,9 @@ typedef struct dc_job_t uint32_t job_id; int action; uint32_t foreign_id; + time_t desired_timestamp; + time_t added_timestamp; + int tries; dc_param_t* param; int try_again; diff --git a/src/dc_param.h b/src/dc_param.h index 9d9f6b14..54ce9a65 100644 --- a/src/dc_param.h +++ b/src/dc_param.h @@ -40,7 +40,6 @@ typedef struct dc_param_t #define DC_PARAM_SERVER_FOLDER 'Z' /* for jobs */ #define DC_PARAM_SERVER_UID 'z' /* for jobs */ -#define DC_PARAM_TIMES 't' /* for jobs: times a job was tried */ #define DC_PARAM_UNPROMOTED 'U' /* for groups */ #define DC_PARAM_PROFILE_IMAGE 'i' /* for groups and contacts */ diff --git a/src/dc_sqlite3.c b/src/dc_sqlite3.c index 6c4eba1c..76fe2a41 100644 --- a/src/dc_sqlite3.c +++ b/src/dc_sqlite3.c @@ -484,6 +484,15 @@ int dc_sqlite3_open(dc_sqlite3_t* sql, const char* dbfile, int flags) } #undef NEW_DB_VERSION + #define NEW_DB_VERSION 47 + if (dbversion < NEW_DB_VERSION) + { + dc_sqlite3_execute(sql, "ALTER TABLE jobs ADD COLUMN tries INTEGER DEFAULT 0;"); + + dbversion = NEW_DB_VERSION; + dc_sqlite3_set_config_int(sql, "dbversion", NEW_DB_VERSION); + } + #undef NEW_DB_VERSION // (2) updates that require high-level objects // (the structure is complete now and all objects are usable) From 7e466e5008ef75ce0dfa0056f67e0ae4bedc279d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Thu, 1 Nov 2018 23:19:49 +0100 Subject: [PATCH 02/11] use exponential backoff times --- src/dc_job.c | 64 +++++++++++++++++++++++++++++++++++++++++++--------- src/dc_job.h | 6 ----- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/dc_job.c b/src/dc_job.c index e820f86e..69ef5a8b 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -1,5 +1,6 @@ #include #include +#include #include "dc_context.h" #include "dc_loginparam.h" #include "dc_job.h" @@ -409,6 +410,48 @@ static void dc_suspend_smtp_thread(dc_context_t* context, int suspend) ******************************************************************************/ +static time_t get_backoff_time_offset(int c_tries) +{ + #define MULTIPLY 5.0 + #define JOB_RETRIES 16 // results in max. 17 hours + + int N = (int)pow((double)2, c_tries) - 1; + + int r = rand() % (N+1); + + time_t seconds = r * MULTIPLY; + + if (seconds<1) { + seconds = 1; + } + + return seconds; +} + + +static time_t get_next_wakeup_time(dc_context_t* context, int thread) +{ + time_t wakeup_time = 0; + sqlite3_stmt* stmt = NULL; + + stmt = dc_sqlite3_prepare(context->sql, + "SELECT MIN(desired_timestamp)" + " FROM jobs" + " WHERE thread=?;"); + sqlite3_bind_int(stmt, 1, thread); + if (sqlite3_step(stmt)==SQLITE_ROW) { + wakeup_time = sqlite3_column_int(stmt, 0); + } + + if (wakeup_time==0) { + wakeup_time = time(NULL) + 10*60; + } + + sqlite3_finalize(stmt); + return wakeup_time; +} + + void dc_job_add(dc_context_t* context, int action, int foreign_id, const char* param, int delay_seconds) { time_t timestamp = time(NULL); @@ -572,20 +615,19 @@ static void dc_job_perform(dc_context_t* context, int thread) } else if (job.try_again==DC_AT_ONCE || job.try_again==DC_STANDARD_DELAY) { - // Define the number of job-retries, each retry may result in 2 tries (for fast network-failure-recover). - // The first job-retries are done asap, the last retry is delayed about a minute. - // Network errors do not count as failed tries. - #define JOB_RETRIES 3 + int tries = job.tries + 1; - int is_online = dc_is_online(context)? 1 : 0; - int tries_while_online = dc_param_get_int(job.param, DC_PARAM_TIMES, 0) + is_online; + if( tries < JOB_RETRIES ) { + job.tries = tries; + + time_t time_offset = get_backoff_time_offset(tries); + job.desired_timestamp = job.added_timestamp + time_offset; - if( tries_while_online < JOB_RETRIES ) { - dc_param_set_int(job.param, DC_PARAM_TIMES, tries_while_online); dc_job_update(context, &job); - dc_log_info(context, 0, "%s-job #%i not succeeded on try #%i.", THREAD_STR, (int)job.job_id, tries_while_online); + dc_log_info(context, 0, "%s-job #%i not succeeded on try #%i, retry in ADD_TIME+%i (in %i seconds).", THREAD_STR, (int)job.job_id, + tries, time_offset, (job.added_timestamp+time_offset)-time(NULL)); - if (thread==DC_SMTP_THREAD && is_online && tries_while_online<(JOB_RETRIES-1)) { + if (thread==DC_SMTP_THREAD && tries<(JOB_RETRIES-1)) { pthread_mutex_lock(&context->smtpidle_condmutex); context->perform_smtp_jobs_needed = DC_JOBS_NEEDED_AVOID_DOS; pthread_mutex_unlock(&context->smtpidle_condmutex); @@ -839,7 +881,7 @@ void dc_perform_smtp_idle(dc_context_t* context) int r = 0; struct timespec wakeup_at; memset(&wakeup_at, 0, sizeof(wakeup_at)); - wakeup_at.tv_sec = time(NULL) + ((context->perform_smtp_jobs_needed==DC_JOBS_NEEDED_AVOID_DOS)? 2 : DC_SMTP_IDLE_SEC); + wakeup_at.tv_sec = get_next_wakeup_time(context, DC_SMTP_THREAD)+1; while (context->smtpidle_condflag==0 && r==0) { r = pthread_cond_timedwait(&context->smtpidle_cond, &context->smtpidle_condmutex, &wakeup_at); // unlock mutex -> wait -> lock mutex } diff --git a/src/dc_job.h b/src/dc_job.h index fa9162b3..4daf4b07 100644 --- a/src/dc_job.h +++ b/src/dc_job.h @@ -30,12 +30,6 @@ extern "C" { #define DC_SMTP_TIMEOUT_SEC 10 -// this is the timeout after which dc_perform_smtp_idle() returns at latest. -// this timeout should not be too large as this might be the only option to perform -// jobs that failed on the first execution. -#define DC_SMTP_IDLE_SEC 60 - - /** * Library-internal. */ From a9ac2dcbce0296347db1c4b00d6adcb6c93a8f8e Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 9 Nov 2018 00:31:16 +0100 Subject: [PATCH 03/11] prototype a maybe-network-function --- src/dc_job.c | 20 ++++++++++++++++++++ src/deltachat.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/dc_job.c b/src/dc_job.c index 69ef5a8b..5cf4340e 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -951,3 +951,23 @@ void dc_interrupt_smtp_idle(dc_context_t* context) pthread_mutex_unlock(&context->smtpidle_condmutex); } + + + +/** + * This function can be called whenever there is a hint + * that the network is available again. + * The library will try to send pending messages out. + * + * @memberof dc_context_t + * @param context The context as created by dc_context_new(). + * @return None. + */ +void dc_maybe_network(dc_context_t* context) +{ + // TODO: make sure, sending is tried independingly of retry-count or timeouts. + // if the first messages comes through, the others should be retried as well. + + dc_interrupt_smtp_idle(context); + dc_interrupt_imap_idle(context); +} diff --git a/src/deltachat.h b/src/deltachat.h index c847fec1..08cb993a 100644 --- a/src/deltachat.h +++ b/src/deltachat.h @@ -227,6 +227,8 @@ void dc_perform_smtp_jobs (dc_context_t*); void dc_perform_smtp_idle (dc_context_t*); void dc_interrupt_smtp_idle (dc_context_t*); +void dc_maybe_network (dc_context_t*); + // handle chatlists #define DC_GCL_ARCHIVED_ONLY 0x01 From 4c32e4e7a535b24f5eafba58fc38b169cbaec27d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 9 Nov 2018 00:54:48 +0100 Subject: [PATCH 04/11] when maybe_network() is called, a probe-flag is forwarded to the next all of dc_job_perform() --- src/dc_context.h | 2 ++ src/dc_job.c | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/dc_context.h b/src/dc_context.h index e20e4410..34395d74 100644 --- a/src/dc_context.h +++ b/src/dc_context.h @@ -50,6 +50,7 @@ struct _dc_context dc_imap_t* imap; /**< Internal IMAP object, never NULL */ pthread_mutex_t imapidle_condmutex; int perform_imap_jobs_needed; + int probe_imap_network; /**< if this flag is set, the imap-job timeouts are bypassed and messages are sent until they fail */ dc_smtp_t* smtp; /**< Internal SMTP object, never NULL */ pthread_cond_t smtpidle_cond; @@ -60,6 +61,7 @@ struct _dc_context #define DC_JOBS_NEEDED_AT_ONCE 1 #define DC_JOBS_NEEDED_AVOID_DOS 2 int perform_smtp_jobs_needed; + int probe_smtp_network; /**< if this flag is set, the smtp-job timeouts are bypassed and messages are sent until they fail */ dc_callback_t cb; /**< Internal */ diff --git a/src/dc_job.c b/src/dc_job.c index 5cf4340e..64047810 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -541,7 +541,7 @@ void dc_job_kill_actions(dc_context_t* context, int action1, int action2) } -static void dc_job_perform(dc_context_t* context, int thread) +static void dc_job_perform(dc_context_t* context, int thread, int probe_network) { sqlite3_stmt* select_stmt = NULL; dc_job_t job; @@ -555,6 +555,9 @@ static void dc_job_perform(dc_context_t* context, int thread) goto cleanup; } + // TODO: if probe_network ist set, + // send out _all_ pending messages in the order of their backoff-times. + select_stmt = dc_sqlite3_prepare(context->sql, "SELECT id, action, foreign_id, param, added_timestamp, desired_timestamp, tries" " FROM jobs" @@ -677,7 +680,9 @@ void dc_perform_imap_jobs(dc_context_t* context) context->perform_imap_jobs_needed = 0; pthread_mutex_unlock(&context->imapidle_condmutex); - dc_job_perform(context, DC_IMAP_THREAD); + dc_job_perform(context, DC_IMAP_THREAD, context->probe_imap_network); + context->probe_imap_network = 0; + dc_log_info(context, 0, "IMAP-jobs ended."); } @@ -841,7 +846,8 @@ void dc_perform_smtp_jobs(dc_context_t* context) pthread_mutex_unlock(&context->smtpidle_condmutex); dc_log_info(context, 0, "SMTP-jobs started..."); - dc_job_perform(context, DC_SMTP_THREAD); + dc_job_perform(context, DC_SMTP_THREAD, context->probe_smtp_network); + context->probe_smtp_network = 0; dc_log_info(context, 0, "SMTP-jobs ended."); pthread_mutex_lock(&context->smtpidle_condmutex); @@ -965,8 +971,11 @@ void dc_interrupt_smtp_idle(dc_context_t* context) */ void dc_maybe_network(dc_context_t* context) { - // TODO: make sure, sending is tried independingly of retry-count or timeouts. - // if the first messages comes through, the others should be retried as well. + // the following flags are forwarded to dc_job_perform() and make sure, + // sending is tried independingly of retry-count or timeouts. + // if the first messages comes through, the others are be retried as well. + context->probe_smtp_network = 1; + context->probe_imap_network = 1; dc_interrupt_smtp_idle(context); dc_interrupt_imap_idle(context); From 445a80f814badc3f050861af6858731c1b982a7d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 9 Nov 2018 16:06:49 +0100 Subject: [PATCH 05/11] add cmdline-command 'maybenetwork' --- cmdline/cmdline.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmdline/cmdline.c b/cmdline/cmdline.c index dbad850c..35b8fd60 100644 --- a/cmdline/cmdline.c +++ b/cmdline/cmdline.c @@ -411,7 +411,7 @@ char* dc_cmdline(dc_context_t* context, const char* cmdline) "configure\n" "connect\n" "disconnect\n" - "poll\n" + "maybenetwork\n" "help imex (Import/Export)\n" "==============================Chat commands==\n" "listchats []\n" @@ -639,6 +639,11 @@ char* dc_cmdline(dc_context_t* context, const char* cmdline) ret = COMMAND_FAILED; } } + else if (strcmp(cmd, "maybenetwork")==0) + { + dc_maybe_network(context); + ret = COMMAND_SUCCEEDED; + } /******************************************************************************* * Chat commands From 22cf9dda1a01b5dbde152d09a1475cad453e02d8 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 9 Nov 2018 16:07:23 +0100 Subject: [PATCH 06/11] adapt job-processing for probing, probe only until first failure --- src/dc_job.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/dc_job.c b/src/dc_job.c index 64047810..c3bfb5cc 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -555,16 +555,28 @@ static void dc_job_perform(dc_context_t* context, int thread, int probe_network) goto cleanup; } - // TODO: if probe_network ist set, - // send out _all_ pending messages in the order of their backoff-times. + if (probe_network==0) { + // processing for first-try and after backoff-timeouts: + // process jobs in the order they were added. + #define FIELDS "id, action, foreign_id, param, added_timestamp, desired_timestamp, tries" + select_stmt = dc_sqlite3_prepare(context->sql, + "SELECT " FIELDS " FROM jobs" + " WHERE thread=? AND desired_timestamp<=?" + " ORDER BY action DESC, added_timestamp;"); + sqlite3_bind_int64(select_stmt, 1, thread); + sqlite3_bind_int64(select_stmt, 2, time(NULL)); + } + else { + // processing after call to dc_maybe_network(): + // process _all_ pending jobs that failed before + // in the order of their backoff-times. + select_stmt = dc_sqlite3_prepare(context->sql, + "SELECT " FIELDS " FROM jobs" + " WHERE thread=? AND tries>0" + " ORDER BY desired_timestamp, action DESC;"); + sqlite3_bind_int64(select_stmt, 1, thread); + } - select_stmt = dc_sqlite3_prepare(context->sql, - "SELECT id, action, foreign_id, param, added_timestamp, desired_timestamp, tries" - " FROM jobs" - " WHERE thread=? AND desired_timestamp<=?" - " ORDER BY action DESC, added_timestamp DESC;"); - sqlite3_bind_int64(select_stmt, 1, thread); - sqlite3_bind_int64(select_stmt, 2, time(NULL)); while (sqlite3_step(select_stmt)==SQLITE_ROW) { job.job_id = sqlite3_column_int (select_stmt, 0); @@ -642,6 +654,14 @@ static void dc_job_perform(dc_context_t* context, int thread, int probe_network) } dc_job_delete(context, &job); } + + if (probe_network) { + // on dc_maybe_network() we stop trying here; + // these jobs are already tried once. + // otherwise, we just continue with the next job + // to give other jobs a chance being tried at least once. + goto cleanup; + } } else { From 8adc27c5c02c83c6ef15bc5b64d9751c06111967 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 9 Nov 2018 16:49:36 +0100 Subject: [PATCH 07/11] remove unneeded floating point --- src/dc_job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dc_job.c b/src/dc_job.c index c3bfb5cc..6e7c7654 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -412,7 +412,7 @@ static void dc_suspend_smtp_thread(dc_context_t* context, int suspend) static time_t get_backoff_time_offset(int c_tries) { - #define MULTIPLY 5.0 + #define MULTIPLY 5 #define JOB_RETRIES 16 // results in max. 17 hours int N = (int)pow((double)2, c_tries) - 1; From 590f02acb7a6a790ec3be07b14174702718967e8 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 9 Nov 2018 22:05:48 +0100 Subject: [PATCH 08/11] avoid race condition that suppresses the network-probe when dc_maybe_network() is called while jobs are actually performed --- src/dc_job.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/dc_job.c b/src/dc_job.c index 6e7c7654..6a95f15e 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -697,12 +697,13 @@ void dc_perform_imap_jobs(dc_context_t* context) dc_log_info(context, 0, "IMAP-jobs started..."); pthread_mutex_lock(&context->imapidle_condmutex); + int probe_imap_network = context->probe_imap_network; + context->probe_imap_network = 0; + context->perform_imap_jobs_needed = 0; pthread_mutex_unlock(&context->imapidle_condmutex); - dc_job_perform(context, DC_IMAP_THREAD, context->probe_imap_network); - context->probe_imap_network = 0; - + dc_job_perform(context, DC_IMAP_THREAD, probe_imap_network); dc_log_info(context, 0, "IMAP-jobs ended."); } @@ -856,6 +857,9 @@ void dc_interrupt_imap_idle(dc_context_t* context) void dc_perform_smtp_jobs(dc_context_t* context) { pthread_mutex_lock(&context->smtpidle_condmutex); + int probe_smtp_network = context->probe_smtp_network; + context->probe_smtp_network = 0; + context->perform_smtp_jobs_needed = 0; if (context->smtp_suspended) { dc_log_info(context, 0, "SMTP-jobs suspended."); @@ -866,8 +870,7 @@ void dc_perform_smtp_jobs(dc_context_t* context) pthread_mutex_unlock(&context->smtpidle_condmutex); dc_log_info(context, 0, "SMTP-jobs started..."); - dc_job_perform(context, DC_SMTP_THREAD, context->probe_smtp_network); - context->probe_smtp_network = 0; + dc_job_perform(context, DC_SMTP_THREAD, probe_smtp_network); dc_log_info(context, 0, "SMTP-jobs ended."); pthread_mutex_lock(&context->smtpidle_condmutex); @@ -994,8 +997,13 @@ void dc_maybe_network(dc_context_t* context) // the following flags are forwarded to dc_job_perform() and make sure, // sending is tried independingly of retry-count or timeouts. // if the first messages comes through, the others are be retried as well. - context->probe_smtp_network = 1; - context->probe_imap_network = 1; + pthread_mutex_lock(&context->smtpidle_condmutex); + context->probe_smtp_network = 1; + pthread_mutex_unlock(&context->smtpidle_condmutex); + + pthread_mutex_lock(&context->imapidle_condmutex); + context->probe_imap_network = 1; + pthread_mutex_unlock(&context->imapidle_condmutex); dc_interrupt_smtp_idle(context); dc_interrupt_imap_idle(context); From 786a496909ee954254df8cac7305c3f471ed9e76 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 12 Nov 2018 13:50:57 +0100 Subject: [PATCH 09/11] add linker flag -lm to link against the math library; required on some systems --- meson.build | 3 +++ src/meson.build | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 293fdbb4..44eff95e 100644 --- a/meson.build +++ b/meson.build @@ -35,6 +35,9 @@ endif # pthreads is not a real dependency pthreads = dependency('threads') +# declare option to link against libm +math = declare_dependency(link_args: ['-lm']) + # zlib should move grow static-pic-lib support and be handled like # this as well. zlib = dependency('zlib', fallback: ['zlib', 'zlib_dep']) diff --git a/src/meson.build b/src/meson.build index 8166c65e..8b71ca1d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -39,7 +39,7 @@ lib_src = [ 'dc_tools.c', ] -lib_deps = [pthreads, zlib, openssl, sasl, sqlite, etpan, netpgp] +lib_deps = [pthreads, zlib, openssl, sasl, sqlite, etpan, netpgp, math] lib_inc = include_directories('.') lib = library( 'deltachat', lib_src, From 972a3a146286b4e0a17435058e3e541978618b1e Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 12 Nov 2018 14:04:15 +0100 Subject: [PATCH 10/11] improve finding the math library with meson; targets comments of @flub --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 44eff95e..82c94fbd 100644 --- a/meson.build +++ b/meson.build @@ -36,7 +36,8 @@ endif pthreads = dependency('threads') # declare option to link against libm -math = declare_dependency(link_args: ['-lm']) +cc = meson.get_compiler('c') +math = cc.find_library('m') # zlib should move grow static-pic-lib support and be handled like # this as well. From 20c12929d30b8709d68577a674683c679dfef5bc Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 12 Nov 2018 21:39:46 +0100 Subject: [PATCH 11/11] adjust backoff MULTIPLY --- src/dc_job.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dc_job.c b/src/dc_job.c index 6a95f15e..9aff1e79 100644 --- a/src/dc_job.c +++ b/src/dc_job.c @@ -412,8 +412,8 @@ static void dc_suspend_smtp_thread(dc_context_t* context, int suspend) static time_t get_backoff_time_offset(int c_tries) { - #define MULTIPLY 5 - #define JOB_RETRIES 16 // results in max. 17 hours + #define MULTIPLY 60 + #define JOB_RETRIES 16 // results in ~3 weeks for the last backoff timespan int N = (int)pow((double)2, c_tries) - 1;