text stringlengths 0 357 |
|---|
sqlite3_bind_int64(stmt, 6, timestamp+delay_seconds); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
if (thread==DC_IMAP_THREAD) { |
dc_interrupt_imap_idle(context); |
} |
else { |
dc_interrupt_smtp_idle(context); |
} |
} |
static void dc_job_update(dc_context_t* context, const dc_job_t* job) |
{ |
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); |
} |
static void dc_job_delete(dc_context_t* context, const dc_job_t* job) |
{ |
sqlite3_stmt* delete_stmt = dc_sqlite3_prepare(context->sql, |
"DELETE FROM jobs WHERE id=?;"); |
sqlite3_bind_int(delete_stmt, 1, job->job_id); |
sqlite3_step(delete_stmt); |
sqlite3_finalize(delete_stmt); |
} |
void dc_job_try_again_later(dc_job_t* job, int try_again, const char* pending_error) |
{ |
if (job==NULL) { |
return; |
} |
job->try_again = try_again; |
free(job->pending_error); |
job->pending_error = dc_strdup_keep_null(pending_error); |
} |
void dc_job_kill_action(dc_context_t* context, int action) |
{ |
if (context==NULL) { |
return; |
} |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, |
"DELETE FROM jobs WHERE action=?;"); |
sqlite3_bind_int(stmt, 1, action); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
static void dc_job_perform(dc_context_t* context, int thread, int probe_network) |
{ |
sqlite3_stmt* select_stmt = NULL; |
dc_job_t job; |
#define THREAD_STR (thread==DC_IMAP_THREAD? "INBOX" : "SMTP") |
#define IS_EXCLUSIVE_JOB (DC_JOB_CONFIGURE_IMAP==job.action || DC_JOB_IMEX_IMAP==job.action || DC_JOB_EMPTY_SERVER==job.action) |
memset(&job, 0, sizeof(dc_job_t)); |
job.param = dc_param_new(); |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
goto cleanup; |
} |
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); |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.