Skip to content

Commit

Permalink
jcr: swapped some #defined functions into static function calls
Browse files Browse the repository at this point in the history
- added JobCanceled and JobTerminatedSuccessfully
  • Loading branch information
franku committed Jul 10, 2018
1 parent 91f4640 commit a84cbcb
Show file tree
Hide file tree
Showing 45 changed files with 151 additions and 155 deletions.
4 changes: 2 additions & 2 deletions core/src/cats/sql_create.cc
Expand Up @@ -823,7 +823,7 @@ bool BareosDb::WriteBatchFileRecords(JobControlRecord *jcr)
return true;
}

if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
goto bail_out;
}

Expand All @@ -837,7 +837,7 @@ bool BareosDb::WriteBatchFileRecords(JobControlRecord *jcr)
Jmsg1(jcr, M_FATAL, 0, "Batch end %s\n", errmsg);
goto bail_out;
}
if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
goto bail_out;
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/dird/backup.cc
Expand Up @@ -218,7 +218,7 @@ static int AccurateListHandler(void *ctx, int num_fields, char **row)
{
JobControlRecord *jcr = (JobControlRecord *)ctx;

if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
return 1;
}

Expand Down Expand Up @@ -726,7 +726,7 @@ int WaitForJobTermination(JobControlRecord *jcr, int timeout)
Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"),
fd->msg);
}
if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
break;
}
}
Expand Down Expand Up @@ -873,7 +873,7 @@ void UpdateBootstrapFile(JobControlRecord *jcr)
/*
* Now update the bootstrap file if any
*/
if (jcr->IsTerminatedOk() &&
if (jcr->JobTerminatedSuccessfully() &&
jcr->jr.JobBytes &&
jcr->res.job->WriteBootstrap) {
FILE *fd;
Expand Down Expand Up @@ -987,7 +987,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
* it is normal. Or look at it the other way, only for a
* normal exit should we complain about this error.
*/
if (jcr->IsTerminatedOk() && jcr->jr.JobBytes) {
if (jcr->JobTerminatedSuccessfully() && jcr->jr.JobBytes) {
Jmsg(jcr, M_ERROR, 0, "%s", jcr->db->strerror());
}
jcr->VolumeName[0] = 0; /* none */
Expand Down
12 changes: 6 additions & 6 deletions core/src/dird/catreq.cc
Expand Up @@ -658,7 +658,7 @@ void CatalogUpdate(JobControlRecord *jcr, BareosSocket *bs)
return; /* user disabled cataloging */
}

if (jcr->IsJobCanceled()) {
if (jcr->JobCanceled()) {
goto bail_out;
}

Expand All @@ -674,7 +674,7 @@ void CatalogUpdate(JobControlRecord *jcr, BareosSocket *bs)
UpdateAttribute(jcr, bs->msg, bs->message_length);

bail_out:
if (jcr->IsJobCanceled()) {
if (jcr->JobCanceled()) {
CancelStorageDaemonJob(jcr);
}
}
Expand All @@ -696,7 +696,7 @@ bool DespoolAttributesFromFile(JobControlRecord *jcr, const char *file)

Dmsg0(100, "Begin DespoolAttributesFromFile\n");

if (jcr->IsJobCanceled() || !jcr->res.pool->catalog_files || !jcr->db) {
if (jcr->JobCanceled() || !jcr->res.pool->catalog_files || !jcr->db) {
goto bail_out; /* user disabled cataloging */
}

Expand Down Expand Up @@ -733,9 +733,9 @@ bool DespoolAttributesFromFile(JobControlRecord *jcr, const char *file)
size += nbytes;
}

if (!jcr->IsJobCanceled()) {
if (!jcr->JobCanceled()) {
UpdateAttribute(jcr, msg, message_length);
if (jcr->IsJobCanceled()) {
if (jcr->JobCanceled()) {
goto bail_out;
}
}
Expand All @@ -748,7 +748,7 @@ bool DespoolAttributesFromFile(JobControlRecord *jcr, const char *file)
close(spool_fd);
}

if (jcr->IsJobCanceled()) {
if (jcr->JobCanceled()) {
CancelStorageDaemonJob(jcr);
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/dird/dir_plugins.cc
Expand Up @@ -252,7 +252,7 @@ bRC GeneratePluginEvent(JobControlRecord *jcr, bDirEventType eventType, void *va
}
}

if (jcr->IsJobCanceled()) {
if (jcr->JobCanceled()) {
Dmsg0(debuglevel, "Cancel return from GeneratePluginEvent\n");
rc = bRC_Cancel;
}
Expand Down Expand Up @@ -524,7 +524,7 @@ void NewPlugins(JobControlRecord *jcr)
Dmsg0(debuglevel, "No dir plugin list!\n");
return;
}
if (jcr->IsJobCanceled()) {
if (jcr->JobCanceled()) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/fd_cmds.cc
Expand Up @@ -779,7 +779,7 @@ static int RestoreObjectHandler(void *ctx, int num_fields, char **row)
JobControlRecord *jcr = octx->jcr;

fd = jcr->file_bsock;
if (jcr->IsJobCanceled()) {
if (jcr->JobCanceled()) {
return 1;
}

Expand Down
34 changes: 17 additions & 17 deletions core/src/dird/job.cc
Expand Up @@ -235,7 +235,7 @@ bool SetupJob(JobControlRecord *jcr, bool suppress_output)
DispatchNewPluginOptions(jcr);
GeneratePluginEvent(jcr, bDirEventJobStart);

if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
goto bail_out;
}

Expand Down Expand Up @@ -358,7 +358,7 @@ bool SetupJob(JobControlRecord *jcr, bool suppress_output)
* If there is nothing to do the DoMigrationInit() function will set
* the termination status to JS_Terminated.
*/
if (JobTerminatedSuccessfully(jcr)) {
if (JobControlRecord::JobTerminatedSuccessfully(jcr)) {
MigrationCleanup(jcr, jcr->getJobStatus());
goto bail_out;
}
Expand All @@ -373,7 +373,7 @@ bool SetupJob(JobControlRecord *jcr, bool suppress_output)
* If there is nothing to do the do_consolidation_init() function will set
* the termination status to JS_Terminated.
*/
if (JobTerminatedSuccessfully(jcr)) {
if (JobControlRecord::JobTerminatedSuccessfully(jcr)) {
ConsolidateCleanup(jcr, jcr->getJobStatus());
goto bail_out;
}
Expand Down Expand Up @@ -513,7 +513,7 @@ static void *job_thread(void *arg)
case JT_BACKUP:
switch (jcr->getJobProtocol()) {
case PT_NDMP_BAREOS:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoNdmpBackup(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -524,7 +524,7 @@ static void *job_thread(void *arg)
}
break;
case PT_NDMP_NATIVE:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoNdmpBackupNdmpNative(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -535,7 +535,7 @@ static void *job_thread(void *arg)
}
break;
default:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (jcr->is_JobLevel(L_VIRTUAL_FULL)) {
if (DoNativeVbackup(jcr)) {
DoAutoprune(jcr);
Expand All @@ -560,7 +560,7 @@ static void *job_thread(void *arg)
}
break;
case JT_VERIFY:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoVerify(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -573,7 +573,7 @@ static void *job_thread(void *arg)
case JT_RESTORE:
switch (jcr->getJobProtocol()) {
case PT_NDMP_BAREOS:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoNdmpRestore(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -584,7 +584,7 @@ static void *job_thread(void *arg)
}
break;
case PT_NDMP_NATIVE:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoNdmpRestoreNdmpNative(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -595,7 +595,7 @@ static void *job_thread(void *arg)
}
break;
default:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoNativeRestore(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -608,7 +608,7 @@ static void *job_thread(void *arg)
}
break;
case JT_ADMIN:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (do_admin(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -619,7 +619,7 @@ static void *job_thread(void *arg)
}
break;
case JT_ARCHIVE:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoArchive(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -631,7 +631,7 @@ static void *job_thread(void *arg)
break;
case JT_COPY:
case JT_MIGRATE:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoMigration(jcr)) {
DoAutoprune(jcr);
} else {
Expand All @@ -642,7 +642,7 @@ static void *job_thread(void *arg)
}
break;
case JT_CONSOLIDATE:
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
if (DoConsolidate(jcr)) {
DoAutoprune(jcr);
} else {
Expand Down Expand Up @@ -776,7 +776,7 @@ static void JobMonitorWatchdog(watchdog_t *self)
foreach_jcr(jcr) {
bool cancel = false;

if (jcr->JobId == 0 || JobCanceled(jcr) || jcr->no_maxtime) {
if (jcr->JobId == 0 || JobControlRecord::JobCanceled(jcr) || jcr->no_maxtime) {
Dmsg2(800, "Skipping JobControlRecord=%p Job=%s\n", jcr, jcr->Job);
continue;
}
Expand Down Expand Up @@ -850,7 +850,7 @@ static bool JobCheckMaxruntime(JobControlRecord *jcr)
JobResource *job = jcr->res.job;
utime_t run_time;

if (JobCanceled(jcr) || !jcr->job_started) {
if (JobControlRecord::JobCanceled(jcr) || !jcr->job_started) {
return false;
}
if (job->MaxRunTime == 0 && job->FullMaxRunTime == 0 &&
Expand Down Expand Up @@ -888,7 +888,7 @@ static bool JobCheckMaxruntime(JobControlRecord *jcr)
*/
static bool JobCheckMaxrunschedtime(JobControlRecord *jcr)
{
if (jcr->MaxRunSchedTime == 0 || JobCanceled(jcr)) {
if (jcr->MaxRunSchedTime == 0 || JobControlRecord::JobCanceled(jcr)) {
return false;
}
if ((watchdog_time - jcr->initial_sched_time) < jcr->MaxRunSchedTime) {
Expand Down
10 changes: 5 additions & 5 deletions core/src/dird/jobq.cc
Expand Up @@ -191,7 +191,7 @@ extern "C" void *sched_wait(void *arg)
wtime = 30;
}
Bmicrosleep(wtime, 0);
if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
break;
}
wtime = jcr->sched_time - time(NULL);
Expand Down Expand Up @@ -237,7 +237,7 @@ int JobqAdd(jobq_t *jq, JobControlRecord *jcr)

jcr->IncUseCount(); /* mark jcr in use by us */
Dmsg3(2300, "JobqAdd jobid=%d jcr=0x%x UseCount=%d\n", jcr->JobId, jcr, jcr->UseCount());
if (!JobCanceled(jcr) && wtime > 0) {
if (!JobControlRecord::JobCanceled(jcr) && wtime > 0) {
SetThreadConcurrency(jq->max_workers + 2);
sched_pkt = (wait_pkt *)malloc(sizeof(wait_pkt));
sched_pkt->jcr = jcr;
Expand All @@ -262,7 +262,7 @@ int JobqAdd(jobq_t *jq, JobControlRecord *jcr)
* While waiting in a queue this job is not attached to a thread
*/
SetJcrInTsd(INVALID_JCR);
if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
/*
* Add job to ready queue so that it is canceled quickly
*/
Expand Down Expand Up @@ -565,7 +565,7 @@ extern "C" void *jobq_server(void *arg)
/*
* If resource conflict, job is canceled
*/
if (!JobCanceled(jcr)) {
if (!JobControlRecord::JobCanceled(jcr)) {
je = jn; /* point to next waiting job */
continue;
}
Expand Down Expand Up @@ -670,7 +670,7 @@ static bool RescheduleJob(JobControlRecord *jcr, jobq_t *jq, jobq_item_t *je)
* Check for failed jobs
*/
(jcr->res.job->RescheduleOnError &&
!jcr->IsTerminatedOk() &&
!jcr->JobTerminatedSuccessfully() &&
!jcr->is_JobStatus(JS_Canceled) &&
jcr->is_JobType(JT_BACKUP));
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/dird/migrate.cc
Expand Up @@ -1834,7 +1834,7 @@ void MigrationCleanup(JobControlRecord *jcr, int TermCode)
new_jobid);
jcr->db->SqlQuery(query.c_str());

if (jcr->IsTerminatedOk()) {
if (jcr->JobTerminatedSuccessfully()) {
UaContext *ua;

switch (jcr->getJobType()) {
Expand Down Expand Up @@ -1943,7 +1943,7 @@ void MigrationCleanup(JobControlRecord *jcr, int TermCode)
* it is normal. Or look at it the other way, only for a
* normal exit should we complain about this error.
*/
if (jcr->IsTerminatedOk() && jcr->jr.JobBytes) {
if (jcr->JobTerminatedSuccessfully() && jcr->jr.JobBytes) {
Jmsg(jcr, M_ERROR, 0, "%s", mig_jcr->db->strerror());
}
mig_jcr->VolumeName[0] = 0; /* none */
Expand Down
4 changes: 2 additions & 2 deletions core/src/dird/msgchan.cc
Expand Up @@ -387,7 +387,7 @@ bool StartStorageDaemonMessageThread(JobControlRecord *jcr)
/* Wait for thread to start */
while (!jcr->SD_msg_chan_started) {
Bmicrosleep(0, 50);
if (JobCanceled(jcr) || jcr->sd_msg_thread_done) {
if (JobControlRecord::JobCanceled(jcr) || jcr->sd_msg_thread_done) {
return false;
}
}
Expand Down Expand Up @@ -438,7 +438,7 @@ extern "C" void *msg_thread(void *arg)
*/
Dmsg0(100, "Start msg_thread loop\n");
n = 0;
while (!JobCanceled(jcr) && (n=BgetDirmsg(sd)) >= 0) {
while (!JobControlRecord::JobCanceled(jcr) && (n=BgetDirmsg(sd)) >= 0) {
Dmsg1(400, "<stored: %s", sd->msg);
/*
* Check for "3000 OK Job Authorization="
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/ndmp_dma_restore_common.cc
Expand Up @@ -194,7 +194,7 @@ void NdmpRestoreCleanup(JobControlRecord *jcr, int TermCode)
jcr->unlink_bsr = false;
}

if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
CancelStorageDaemonJob(jcr);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/restore.cc
Expand Up @@ -474,7 +474,7 @@ void NativeRestoreCleanup(JobControlRecord *jcr, int TermCode)
jcr->unlink_bsr = false;
}

if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
CancelStorageDaemonJob(jcr);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/storage.cc
Expand Up @@ -494,7 +494,7 @@ bool SelectNextRstore(JobControlRecord *jcr, bootstrap_info &info)
return true;
}
Bmicrosleep(10, 0); /* Sleep 10 secs */
if (JobCanceled(jcr)) {
if (JobControlRecord::JobCanceled(jcr)) {
FreeRstorage(jcr);
return false;
}
Expand Down

0 comments on commit a84cbcb

Please sign in to comment.