text stringlengths 0 357 |
|---|
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.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); |
// some configuration jobs are "exclusive": |
// - they are always executed in the imap-thread and the smtp-thread is suspended during execution |
// - they may change the database handle change the database handle; we do not keep old pointers therefore |
// - they can be re-executed one time AT_ONCE, but they are not save in the database for later execution |
if (IS_EXCLUSIVE_JOB) { |
dc_job_kill_action(context, job.action); |
sqlite3_finalize(select_stmt); |
select_stmt = NULL; |
dc_jobthread_suspend(&context->sentbox_thread, 1); |
dc_jobthread_suspend(&context->mvbox_thread, 1); |
dc_suspend_smtp_thread(context, 1); |
} |
for (int tries = 0; tries <= 1; tries++) |
{ |
job.try_again = DC_DONT_TRY_AGAIN; // this can be modified by a job using dc_job_try_again_later() |
switch (job.action) { |
case DC_JOB_SEND_MSG_TO_SMTP: dc_job_do_DC_JOB_SEND (context, &job); break; |
case DC_JOB_DELETE_MSG_ON_IMAP: dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP (context, &job); break; |
case DC_JOB_MARKSEEN_MSG_ON_IMAP: dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP (context, &job); break; |
case DC_JOB_MARKSEEN_MDN_ON_IMAP: dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP (context, &job); break; |
case DC_JOB_MOVE_MSG: dc_job_do_DC_JOB_MOVE_MSG (context, &job); break; |
case DC_JOB_SEND_MDN: dc_job_do_DC_JOB_SEND (context, &job); break; |
case DC_JOB_CONFIGURE_IMAP: dc_job_do_DC_JOB_CONFIGURE_IMAP (context, &job); break; |
case DC_JOB_IMEX_IMAP: dc_job_do_DC_JOB_IMEX_IMAP (context, &job); break; |
case DC_JOB_MAYBE_SEND_LOCATIONS: dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS (context, &job); break; |
case DC_JOB_MAYBE_SEND_LOC_ENDED: dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED (context, &job); break; |
case DC_JOB_EMPTY_SERVER: dc_job_do_DC_JOB_EMPTY_SERVER (context, &job); break; |
case DC_JOB_HOUSEKEEPING: dc_housekeeping (context); break; |
} |
if (job.try_again!=DC_AT_ONCE) { |
break; |
} |
} |
if (IS_EXCLUSIVE_JOB) { |
dc_jobthread_suspend(&context->sentbox_thread, 0); |
dc_jobthread_suspend(&context->mvbox_thread, 0); |
dc_suspend_smtp_thread(context, 0); |
goto cleanup; |
} |
else if (job.try_again==DC_INCREATION_POLL) |
{ |
// just try over next loop unconditionally, the ui typically interrupts idle when the file (video) is ready |
dc_log_info(context, 0, "%s-job #%i not yet ready and will be delayed.", THREAD_STR, (int)job.job_id); |
} |
else if (job.try_again==DC_AT_ONCE || job.try_again==DC_STANDARD_DELAY) |
{ |
int tries = job.tries + 1; |
if( tries < JOB_RETRIES ) { |
job.tries = tries; |
time_t time_offset = get_backoff_time_offset(tries); |
job.desired_timestamp = job.added_timestamp + time_offset; |
dc_job_update(context, &job); |
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 && 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); |
} |
} |
else { |
if (job.action==DC_JOB_SEND_MSG_TO_SMTP) { // in all other cases, the messages is already sent |
dc_set_msg_failed(context, job.foreign_id, job.pending_error); |
} |
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 |
{ |
dc_job_delete(context, &job); |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.