From: Kern Sibbald Date: Wed, 23 Feb 2011 12:39:18 +0000 (+0100) Subject: Use jcr->setJobStatus() in favor of set_jcr_job_status(jcr...) X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8ac65fd2da02f0014cf7807025c592e39e861047;p=bacula%2Fbacula Use jcr->setJobStatus() in favor of set_jcr_job_status(jcr...) --- diff --git a/bacula/src/dird/admin.c b/bacula/src/dird/admin.c index 155a78ab6e..fc41f78fac 100644 --- a/bacula/src/dird/admin.c +++ b/bacula/src/dird/admin.c @@ -66,7 +66,7 @@ bool do_admin(JCR *jcr) Jmsg(jcr, M_INFO, 0, _("Start Admin JobId %d, Job=%s\n"), jcr->JobId, jcr->Job); - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); admin_cleanup(jcr, JS_Terminated); return true; } @@ -91,7 +91,7 @@ void admin_cleanup(JCR *jcr, int TermCode) if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), db_strerror(jcr->db)); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } msg_type = M_INFO; /* by default INFO message */ diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index ff14469a85..4bb304102d 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -103,7 +103,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, } if (fd == NULL) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return 0; } Dmsg0(10, "Opened connection with File daemon\n"); @@ -112,10 +112,10 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, } fd->res = (RES *)jcr->client; /* save resource in BSOCK */ jcr->file_bsock = fd; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); if (!authenticate_file_daemon(jcr)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return 0; } @@ -136,7 +136,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, if (strncmp(fd->msg, OKjob, strlen(OKjob)) != 0) { Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"), jcr->client->hdr.name, fd->msg); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return 0; } else if (jcr->db) { CLIENT_DBR cr; @@ -154,7 +154,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, } else { Jmsg(jcr, M_FATAL, 0, _("FD gave bad response to JobId command: %s\n"), bnet_strerror(fd)); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return 0; } return 1; @@ -471,7 +471,7 @@ static bool send_fileset(JCR *jcr) return true; bail_out: - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return false; } @@ -790,7 +790,7 @@ int get_attributes_and_put_in_catalog(JCR *jcr) if ((len = sscanf(fd->msg, "%ld %d %s", &file_index, &stream, Digest)) != 3) { Jmsg(jcr, M_FATAL, 0, _("msglen, fd->msg); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return 0; } p = fd->msg; @@ -869,6 +869,6 @@ int get_attributes_and_put_in_catalog(JCR *jcr) } jcr->cached_attribute = false; } - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); return 1; } diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 3aa1d6ce59..7c19ac69a8 100644 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -174,7 +174,7 @@ void *sched_wait(void *arg) Dmsg0(2300, "Enter sched_wait.\n"); free(arg); time_t wtime = jcr->sched_time - time(NULL); - set_jcr_job_status(jcr, JS_WaitStartTime); + jcr->setJobStatus(JS_WaitStartTime); /* Wait until scheduled time arrives */ if (wtime > 0) { Jmsg(jcr, M_INFO, 0, _("Job %s waiting %d seconds for scheduled start time.\n"), @@ -533,7 +533,7 @@ void *jobq_server(void *arg) if (!(jcr->JobPriority == Priority || (jcr->JobPriority < Priority && jcr->job->allow_mixed_priority && running_allow_mix))) { - set_jcr_job_status(jcr, JS_WaitPriority); + jcr->setJobStatus(JS_WaitPriority); break; } @@ -649,7 +649,7 @@ static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je) jcr->Job, dt, (int)jcr->job->RescheduleInterval, dt2); dird_free_jcr_pointers(jcr); /* partial cleanup old stuff */ jcr->JobStatus = -1; - set_jcr_job_status(jcr, JS_WaitStartTime); + jcr->setJobStatus(JS_WaitStartTime); jcr->SDJobStatus = 0; jcr->JobErrors = 0; if (!allow_duplicate_job(jcr)) { @@ -684,7 +684,7 @@ static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je) njcr->run_inc_pool_override = jcr->run_inc_pool_override; njcr->diff_pool = jcr->diff_pool; njcr->JobStatus = -1; - set_jcr_job_status(njcr, jcr->JobStatus); + njcr->setJobStatus(jcr->JobStatus); if (jcr->rstore) { copy_rstorage(njcr, jcr->rstorage, _("previous Job")); } else { @@ -731,7 +731,7 @@ static bool acquire_resources(JCR *jcr) Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n" " Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"), jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source); - set_jcr_job_status(jcr, JS_Canceled); + jcr->setJobStatus(JS_Canceled); return false; } #endif @@ -739,7 +739,7 @@ static bool acquire_resources(JCR *jcr) Dmsg1(200, "Rstore=%s\n", jcr->rstore->name()); if (!inc_read_store(jcr)) { Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->NumConcurrentJobs); - set_jcr_job_status(jcr, JS_WaitStoreRes); + jcr->setJobStatus(JS_WaitStoreRes); return false; } } @@ -758,7 +758,7 @@ static bool acquire_resources(JCR *jcr) } } if (skip_this_jcr) { - set_jcr_job_status(jcr, JS_WaitStoreRes); + jcr->setJobStatus(JS_WaitStoreRes); return false; } @@ -768,7 +768,7 @@ static bool acquire_resources(JCR *jcr) /* Back out previous locks */ dec_write_store(jcr); dec_read_store(jcr); - set_jcr_job_status(jcr, JS_WaitClientRes); + jcr->setJobStatus(JS_WaitClientRes); return false; } if (jcr->job->NumConcurrentJobs < jcr->job->MaxConcurrentJobs) { @@ -778,7 +778,7 @@ static bool acquire_resources(JCR *jcr) dec_write_store(jcr); dec_read_store(jcr); jcr->client->NumConcurrentJobs--; - set_jcr_job_status(jcr, JS_WaitJobRes); + jcr->setJobStatus(JS_WaitJobRes); return false; } diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 2104b4deb2..9b29c61902 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -157,7 +157,7 @@ bool do_migration_init(JCR *jcr) } if (jcr->previous_jr.JobId == 0 || jcr->ExpectedFiles == 0) { - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); Dmsg1(dbglevel, "JobId=%d expected files == 0\n", (int)jcr->JobId); if (jcr->previous_jr.JobId == 0) { Jmsg(jcr, M_INFO, 0, _("No previous Job found to %s.\n"), jcr->get_ActionName(0)); @@ -301,7 +301,7 @@ bool do_migration(JCR *jcr) * so set a normal status, cleanup and return OK. */ if (!mig_jcr) { - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); migration_cleanup(jcr, jcr->JobStatus); return true; } @@ -311,7 +311,7 @@ bool do_migration(JCR *jcr) edit_int64(jcr->previous_jr.JobId, ed1), jcr->get_ActionName(0), db_strerror(jcr->db)); - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); migration_cleanup(jcr, jcr->JobStatus); return true; } @@ -322,7 +322,7 @@ bool do_migration(JCR *jcr) edit_int64(jcr->previous_jr.JobId, ed1), jcr->get_ActionName(1), jcr->get_OperationName()); - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); migration_cleanup(jcr, jcr->JobStatus); return true; } @@ -338,8 +338,8 @@ bool do_migration(JCR *jcr) * */ Dmsg0(110, "Open connection with storage daemon\n"); - set_jcr_job_status(jcr, JS_WaitSD); - set_jcr_job_status(mig_jcr, JS_WaitSD); + jcr->setJobStatus(JS_WaitSD); + mig_jcr->setJobStatus(JS_WaitSD); /* * Start conversation with Storage daemon */ @@ -373,7 +373,7 @@ bool do_migration(JCR *jcr) jcr->start_time = time(NULL); jcr->jr.StartTime = jcr->start_time; jcr->jr.JobTDate = jcr->start_time; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); /* Update job start record for this migration control job */ if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) { @@ -385,7 +385,7 @@ bool do_migration(JCR *jcr) mig_jcr->start_time = time(NULL); mig_jcr->jr.StartTime = mig_jcr->start_time; mig_jcr->jr.JobTDate = mig_jcr->start_time; - set_jcr_job_status(mig_jcr, JS_Running); + mig_jcr->setJobStatus(JS_Running); /* Update job start record for the real migration backup job */ if (!db_update_job_start_record(mig_jcr, mig_jcr->db, &mig_jcr->jr)) { @@ -415,13 +415,13 @@ bool do_migration(JCR *jcr) } - set_jcr_job_status(jcr, JS_Running); - set_jcr_job_status(mig_jcr, JS_Running); + jcr->setJobStatus(JS_Running); + mig_jcr->setJobStatus(JS_Running); /* Pickup Job termination data */ /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/JobErrors */ wait_for_storage_daemon_termination(jcr); - set_jcr_job_status(jcr, jcr->SDJobStatus); + jcr->setJobStatus(jcr->SDJobStatus); db_write_batch_file_records(jcr); /* used by bulk batch file insert */ if (jcr->JobStatus != JS_Terminated) { return false; @@ -1210,7 +1210,7 @@ void migration_cleanup(JCR *jcr, int TermCode) if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), db_strerror(jcr->db)); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } update_bootstrap_file(mig_jcr); diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 9f2e96a469..2b1d3f573e 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -439,7 +439,7 @@ void wait_for_storage_daemon_termination(JCR *jcr) break; } } - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); } /* @@ -462,7 +462,7 @@ bool send_bootstrap_file(JCR *jcr, BSOCK *sd) berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), jcr->RestoreBootstrap, be.bstrerror()); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return false; } sd->fsend(bootstrap); diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index a5cce8511d..741f73b9af 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -136,7 +136,7 @@ static bool open_bootstrap_file(JCR *jcr, bootstrap_info &info) berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), jcr->RestoreBootstrap, be.bstrerror()); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return false; } @@ -183,7 +183,7 @@ static bool is_on_same_storage(JCR *jcr, char *new_one) if (!new_store) { Jmsg(jcr, M_FATAL, 0, _("Could not get storage resource '%s'.\n"), new_one); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return false; } /* if Port and Hostname/IP are same, we are talking to the same @@ -275,7 +275,7 @@ static bool select_rstore(JCR *jcr, bootstrap_info &info) if (!(ustore.store = (STORE *)GetResWithName(R_STORAGE,info.storage))) { Jmsg(jcr, M_FATAL, 0, _("Could not get storage resource '%s'.\n"), info.storage); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return false; } @@ -293,14 +293,14 @@ static bool select_rstore(JCR *jcr, bootstrap_info &info) dec_read_store(jcr); free_rstorage(jcr); set_rstorage(jcr, &ustore); - set_jcr_job_status(jcr, JS_WaitSD); + jcr->setJobStatus(JS_WaitSD); /* * Wait for up to 6 hours to increment read stoage counter */ for (i=0; i < MAX_TRIES; i++) { /* try to get read storage counter incremented */ if (inc_read_store(jcr)) { - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); return true; } bmicrosleep(10, 0); /* sleep 10 secs */ @@ -368,7 +368,7 @@ bool restore_bootstrap(JCR *jcr) * */ Dmsg0(10, "Open connection with storage daemon\n"); - set_jcr_job_status(jcr, JS_WaitSD); + jcr->setJobStatus(JS_WaitSD); /* * Start conversation with Storage daemon */ @@ -387,7 +387,7 @@ bool restore_bootstrap(JCR *jcr) /* * Start conversation with File daemon */ - set_jcr_job_status(jcr, JS_WaitFD); + jcr->setJobStatus(JS_WaitFD); jcr->keep_sd_auth_key = true; /* don't clear the sd_auth_key now */ if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) { goto bail_out; @@ -395,7 +395,7 @@ bool restore_bootstrap(JCR *jcr) fd = jcr->file_bsock; } - set_jcr_job_status(jcr, JS_WaitSD); + jcr->setJobStatus(JS_WaitSD); /* * Send the bootstrap file -- what Volumes/files to restore diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index 03c8c5b3fa..b602e0a1e0 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -105,7 +105,7 @@ JCR *new_control_jcr(const char *base_name, int job_type) jcr->sched_time = jcr->start_time; jcr->setJobType(job_type); jcr->setJobLevel(L_NONE); - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); jcr->JobId = 0; return jcr; } diff --git a/bacula/src/dird/vbackup.c b/bacula/src/dird/vbackup.c index 5745e8702c..0375a0d0ad 100644 --- a/bacula/src/dird/vbackup.c +++ b/bacula/src/dird/vbackup.c @@ -193,7 +193,7 @@ _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n") * */ Dmsg0(110, "Open connection with storage daemon\n"); - set_jcr_job_status(jcr, JS_WaitSD); + jcr->setJobStatus(JS_WaitSD); /* * Start conversation with Storage daemon */ @@ -223,7 +223,7 @@ _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n") jcr->start_time = time(NULL); jcr->jr.StartTime = jcr->start_time; jcr->jr.JobTDate = jcr->start_time; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); /* Update job start record */ if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) { @@ -247,12 +247,12 @@ _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n") return false; } - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); /* Pickup Job termination data */ /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/JobErrors */ wait_for_storage_daemon_termination(jcr); - set_jcr_job_status(jcr, jcr->SDJobStatus); + jcr->setJobStatus(jcr->SDJobStatus); db_write_batch_file_records(jcr); /* used by bulk batch file insert */ if (jcr->JobStatus != JS_Terminated) { return false; @@ -302,7 +302,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode) if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), db_strerror(jcr->db)); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } bstrncpy(cr.Name, jcr->client->name(), sizeof(cr.Name)); @@ -315,7 +315,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode) if (!db_get_media_record(jcr, jcr->db, &mr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), mr.VolumeName, db_strerror(jcr->db)); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } update_bootstrap_file(jcr); diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 2e4ecbc450..41cb9019cf 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -224,7 +224,7 @@ bool do_verify(JCR *jcr) /* * Start conversation with Storage daemon */ - set_jcr_job_status(jcr, JS_Blocked); + jcr->setJobStatus(JS_Blocked); if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) { return false; } @@ -258,12 +258,12 @@ bool do_verify(JCR *jcr) * OK, now connect to the File daemon * and ask him for the files. */ - set_jcr_job_status(jcr, JS_Blocked); + jcr->setJobStatus(JS_Blocked); if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) { goto bail_out; } - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); fd = jcr->file_bsock; @@ -614,7 +614,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) &jcr->previous_jr, &fdbr)) { Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname); Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); continue; } else { /* @@ -640,7 +640,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) Jmsg(jcr, M_INFO, 0, _(" st_ino differ. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_ino, ed1), edit_uint64((uint64_t)statf.st_ino, ed2)); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'p': /* permissions bits */ @@ -648,7 +648,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" st_mode differ. Cat: %x File: %x\n"), (uint32_t)statc.st_mode, (uint32_t)statf.st_mode); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'n': /* number of links */ @@ -656,7 +656,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" st_nlink differ. Cat: %d File: %d\n"), (uint32_t)statc.st_nlink, (uint32_t)statf.st_nlink); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'u': /* user id */ @@ -664,7 +664,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" st_uid differ. Cat: %u File: %u\n"), (uint32_t)statc.st_uid, (uint32_t)statf.st_uid); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'g': /* group id */ @@ -672,7 +672,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" st_gid differ. Cat: %u File: %u\n"), (uint32_t)statc.st_gid, (uint32_t)statf.st_gid); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 's': /* size */ @@ -681,28 +681,28 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) Jmsg(jcr, M_INFO, 0, _(" st_size differ. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_size, ed1), edit_uint64((uint64_t)statf.st_size, ed2)); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'a': /* access time */ if (statc.st_atime != statf.st_atime) { prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" st_atime differs\n")); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'm': if (statc.st_mtime != statf.st_mtime) { prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" st_mtime differs\n")); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'c': /* ctime */ if (statc.st_ctime != statf.st_ctime) { prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" st_ctime differs\n")); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case 'd': /* file size decrease */ @@ -711,7 +711,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) Jmsg(jcr, M_INFO, 0, _(" st_size decrease. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_size, ed1), edit_uint64((uint64_t)statf.st_size, ed2)); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } break; case '5': /* compare MD5 */ @@ -748,7 +748,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) prt_fname(jcr); Jmsg(jcr, M_INFO, 0, _(" %s differs. File=%s Cat=%s\n"), stream_to_ascii(stream), buf, fdbr.Digest); - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } do_Digest = CRYPTO_DIGEST_NONE; } @@ -775,7 +775,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) /* missing_handler is called for each file found */ db_sql_query(jcr->db, buf, missing_handler, (void *)jcr); if (jcr->fn_printed) { - set_jcr_job_status(jcr, JS_Differences); + jcr->setJobStatus(JS_Differences); } free_pool_memory(fname); } diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 7330fde878..562621d4d3 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -83,7 +83,7 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) sd = jcr->store_bsock; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); Dmsg1(300, "bfiled: opened data connection %d to stored\n", sd->m_fd); @@ -97,7 +97,7 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) buf_size = 0; /* use default */ } if (!sd->set_buffer_size(buf_size, BNET_SETBUF_WRITE)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); Jmsg(jcr, M_FATAL, 0, _("Cannot set buffer size FD->SD.\n")); return false; } @@ -161,7 +161,7 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) /** Subroutine save_file() is called for each file */ if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, plugin_save)) { ok = false; /* error */ - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } if (have_acl && jcr->acl_data->nr_errors > 0) { @@ -831,7 +831,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, if ((zstat=deflateParams((z_stream*)jcr->pZLIB_compress_workset, ff_pkt->GZIP_level, Z_DEFAULT_STRATEGY)) != Z_OK) { Jmsg(jcr, M_FATAL, 0, _("Compression deflateParams error: %d\n"), zstat); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto err; } } @@ -960,14 +960,14 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, if ((zstat=deflate((z_stream*)jcr->pZLIB_compress_workset, Z_FINISH)) != Z_STREAM_END) { Jmsg(jcr, M_FATAL, 0, _("Compression deflate error: %d\n"), zstat); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto err; } compress_len = ((z_stream*)jcr->pZLIB_compress_workset)->total_out; /** reset zlib stream to be able to begin from scratch again */ if ((zstat=deflateReset((z_stream*)jcr->pZLIB_compress_workset)) != Z_OK) { Jmsg(jcr, M_FATAL, 0, _("Compression deflateReset error: %d\n"), zstat); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto err; } diff --git a/bacula/src/filed/estimate.c b/bacula/src/filed/estimate.c index 7888bc9ffe..3f9779444b 100644 --- a/bacula/src/filed/estimate.c +++ b/bacula/src/filed/estimate.c @@ -47,7 +47,7 @@ int make_estimate(JCR *jcr) { int stat; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime); /* in accurate mode, we overwrite the find_one check function */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index b829866316..b022dfbf87 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -453,7 +453,7 @@ static int cancel_cmd(JCR *jcr) dir->fsend(_("2901 Job %s not found.\n"), Job); } else { generate_plugin_event(cjcr, bEventCancelCommand, NULL); - set_jcr_job_status(cjcr, JS_Canceled); + cjcr->setJobStatus(JS_Canceled); if (cjcr->store_bsock) { cjcr->store_bsock->set_timed_out(); cjcr->store_bsock->set_terminated(); @@ -1483,7 +1483,7 @@ static int bootstrap_cmd(JCR *jcr) while (dir->recv() >= 0) { } free_bootstrap(jcr); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return 0; } @@ -1783,7 +1783,7 @@ static int backup_cmd(JCR *jcr) goto cleanup; } - set_jcr_job_status(jcr, JS_Blocked); + jcr->setJobStatus(JS_Blocked); jcr->setJobType(JT_BACKUP); Dmsg1(100, "begin backup ff=%p\n", jcr->ff); @@ -1878,11 +1878,11 @@ static int backup_cmd(JCR *jcr) */ Dmsg1(110, "begin blast ff=%p\n", (FF_PKT *)jcr->ff); if (!blast_data_to_storage_daemon(jcr, NULL)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); bnet_suppress_error_messages(sd, 1); Dmsg0(110, "Error in blast_data.\n"); } else { - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); /* Note, the above set status will not override an error */ if (!(jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings)) { bnet_suppress_error_messages(sd, 1); @@ -1892,7 +1892,7 @@ static int backup_cmd(JCR *jcr) * Expect to get response to append_data from Storage daemon */ if (!response(jcr, sd, OK_append, "Append Data")) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto cleanup; } @@ -1902,7 +1902,7 @@ static int backup_cmd(JCR *jcr) sd->fsend(append_end, jcr->Ticket); /* Get end OK */ if (!response(jcr, sd, OK_end, "Append End")) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto cleanup; } @@ -2111,14 +2111,14 @@ static int restore_cmd(JCR *jcr) jcr->setJobType(JT_RESTORE); - set_jcr_job_status(jcr, JS_Blocked); + jcr->setJobStatus(JS_Blocked); if (!open_sd_read_session(jcr)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto bail_out; } - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); /** * Do restore of files and data @@ -2158,7 +2158,7 @@ static int restore_cmd(JCR *jcr) do_restore(jcr); stop_dir_heartbeat(jcr); - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); if (jcr->JobStatus != JS_Terminated) { bnet_suppress_error_messages(sd, 1); } @@ -2203,7 +2203,7 @@ bail_out: bfree_and_null(jcr->where); if (jcr->JobErrors) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } Dmsg0(100, "Done in job.c\n"); @@ -2355,7 +2355,7 @@ static int send_bootstrap_file(JCR *jcr) berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), jcr->RestoreBootstrap, be.bstrerror()); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto bail_out; } sd->msglen = pm_strcpy(sd->msg, bootstrap); @@ -2367,7 +2367,7 @@ static int send_bootstrap_file(JCR *jcr) sd->signal(BNET_EOD); fclose(bs); if (!response(jcr, sd, OKSDbootstrap, "Bootstrap")) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto bail_out; } stat = 1; diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index cb71562ab9..542ce8490d 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -177,7 +177,7 @@ void do_restore(JCR *jcr) int non_support_xattr = 0; sd = jcr->store_bsock; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); LockRes(); CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL); @@ -188,7 +188,7 @@ void do_restore(JCR *jcr) buf_size = 0; /* use default */ } if (!bnet_set_buffer_size(sd, buf_size, BNET_SETBUF_WRITE)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return; } jcr->buf_size = sd->msglen; @@ -791,11 +791,11 @@ void do_restore(JCR *jcr) } close_previous_stream(rctx); - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); goto ok_out; bail_out: - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); ok_out: /* diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index 287f0a4ad3..237e7718db 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -51,7 +51,7 @@ static int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr); */ void do_verify(JCR *jcr) { - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); jcr->buf_size = DEFAULT_NETWORK_BUFFER_SIZE; if ((jcr->big_buf = (char *) malloc(jcr->buf_size)) == NULL) { Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"), @@ -67,7 +67,7 @@ void do_verify(JCR *jcr) free(jcr->big_buf); jcr->big_buf = NULL; } - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); } /* diff --git a/bacula/src/filed/verify_vol.c b/bacula/src/filed/verify_vol.c index bf0ef5c8cf..cae6a3d9fb 100644 --- a/bacula/src/filed/verify_vol.c +++ b/bacula/src/filed/verify_vol.c @@ -61,11 +61,11 @@ void do_verify_volume(JCR *jcr) sd = jcr->store_bsock; if (!sd) { Jmsg(jcr, M_FATAL, 0, _("Storage command not issued before Verify.\n")); - set_jcr_job_status(jcr, JS_FatalError); + jcr->setJobStatus(JS_FatalError); return; } dir = jcr->dir_bsock; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); LockRes(); CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL); @@ -77,7 +77,7 @@ void do_verify_volume(JCR *jcr) buf_size = 0; /* use default */ } if (!bnet_set_buffer_size(sd, buf_size, BNET_SETBUF_WRITE)) { - set_jcr_job_status(jcr, JS_FatalError); + jcr->setJobStatus(JS_FatalError); return; } jcr->buf_size = sd->msglen; @@ -246,11 +246,11 @@ void do_verify_volume(JCR *jcr) } /* end switch */ } /* end while bnet_get */ - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); goto ok_out; bail_out: - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); ok_out: if (jcr->compress_buf) { diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 47575156f3..24dbca6eeb 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -194,6 +194,7 @@ public: bool is_JobStatus(int32_t aJobStatus) { return aJobStatus == JobStatus; }; void setJobLevel(int32_t JobLevel) { m_JobLevel = JobLevel; }; void setJobType(int32_t JobType) { m_JobType = JobType; }; + void forceJobStatus(int32_t aJobStatus) { JobStatus = aJobStatus; }; int32_t getJobType() const { return m_JobType; }; int32_t getJobLevel() const { return m_JobLevel; }; int32_t getJobStatus() const { return JobStatus; }; diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 2c2d89be71..3df798e50b 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -863,12 +863,6 @@ static int get_status_priority(int JobStatus) return priority; } - -void set_jcr_job_status(JCR *jcr, int JobStatus) -{ - jcr->setJobStatus(JobStatus); -} - void JCR::setJobStatus(int newJobStatus) { JCR *jcr = this; @@ -902,7 +896,7 @@ void JCR::setJobStatus(int newJobStatus) } if (oldJobStatus != jcr->JobStatus) { - Dmsg2(800, "leave set_job_status old=%c new=%c\n", oldJobStatus, newJobStatus); + Dmsg2(800, "leave setJobStatus old=%c new=%c\n", oldJobStatus, newJobStatus); // generate_plugin_event(jcr, bEventStatusChange, NULL); } } diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 87f739f58f..97a3a01a2b 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -1270,7 +1270,7 @@ Jmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...) case M_FATAL: len = bsnprintf(rbuf, sizeof(rbuf), _("%s JobId %u: Fatal error: "), my_name, JobId); if (jcr) { - set_jcr_job_status(jcr, JS_FatalError); + jcr->setJobStatus(JS_FatalError); } if (jcr && jcr->JobErrors == 0) { jcr->JobErrors = 1; diff --git a/bacula/src/lib/runscript.c b/bacula/src/lib/runscript.c index 47a55c631b..3cb3568e30 100644 --- a/bacula/src/lib/runscript.c +++ b/bacula/src/lib/runscript.c @@ -277,7 +277,7 @@ bool RUNSCRIPT::run(JCR *jcr, const char *name) bail_out: /* cancel running job properly */ if (fail_on_error) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } Dmsg1(100, "runscript failed. fail_on_error=%d\n", fail_on_error); return false; diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 146aa4530c..73f985ed06 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -317,7 +317,7 @@ default_path: dev->clear_append(); dev->set_read(); - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); Jmsg(jcr, M_INFO, 0, _("Ready to read from volume \"%s\" on device %s.\n"), dcr->VolumeName, dev->print_name()); diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 72bf6ab1ac..47af0d95bb 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -94,17 +94,17 @@ bool do_append_data(JCR *jcr) memset(&rec, 0, sizeof(rec)); if (!fd->set_buffer_size(dcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); Jmsg0(jcr, M_FATAL, 0, _("Unable to set network buffer size.\n")); return false; } if (!acquire_device_for_append(dcr)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return false; } - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); if (dev->VolCatInfo.VolCatName[0] == 0) { @@ -125,7 +125,7 @@ bool do_append_data(JCR *jcr) if (!write_session_label(dcr, SOS_LABEL)) { Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"), dev->bstrerror()); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); ok = false; } if (dev->VolCatInfo.VolCatName[0] == 0) { @@ -266,7 +266,7 @@ fi_checked: } /* Create Job status for end of session label */ - set_jcr_job_status(jcr, ok?JS_Terminated:JS_ErrorTerminated); + jcr->setJobStatus(ok?JS_Terminated:JS_ErrorTerminated); if (ok) { /* Terminate connection with FD */ @@ -305,7 +305,7 @@ fi_checked: dev->bstrerror()); possible_incomplete_job(jcr, last_file_index); } - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); ok = false; } if (dev->VolCatInfo.VolCatName[0] == 0) { @@ -322,7 +322,7 @@ fi_checked: Dmsg0(100, _("Set ok=FALSE after write_block_to_device.\n")); possible_incomplete_job(jcr, last_file_index); } - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); ok = false; } } diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 0d4b998cd6..09eaf7046f 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -546,7 +546,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) } } - set_jcr_job_status(jcr, JS_WaitMedia); + jcr->setJobStatus(JS_WaitMedia); dir_send_job_status(jcr); stat = wait_for_sysop(dcr); @@ -576,7 +576,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) } get_out: - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); Dmsg0(100, "leave dir_ask_sysop_to_mount_create_appendable_volume\n"); return true; @@ -647,7 +647,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr, int mode) dcr->VolumeName, dev->print_name(), jcr->Job); } - set_jcr_job_status(jcr, JS_WaitMount); + jcr->setJobStatus(JS_WaitMount); dir_send_job_status(jcr); stat = wait_for_sysop(dcr); /* wait on device */ @@ -679,7 +679,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr, int mode) } get_out: - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); Dmsg0(400, "leave dir_ask_sysop_to_mount_volume\n"); return true; diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 871697bf7d..bc52836dbb 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -2212,7 +2212,7 @@ static void fillcmd() */ Dmsg0(100, "just before acquire_device\n"); if (!acquire_device_for_append(dcr)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); exit_code = 1; return; } @@ -2223,7 +2223,7 @@ static void fillcmd() * Write Begin Session Record */ if (!write_session_label(dcr, SOS_LABEL)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"), dev->bstrerror()); ok = false; @@ -2336,10 +2336,10 @@ static void fillcmd() Dmsg0(100, "Write_end_session_label()\n"); /* Create Job status for end of session label */ if (!job_canceled(jcr) && ok) { - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); } else if (!ok) { Pmsg0(000, _("Job canceled.\n")); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); exit_code = 1; } if (!write_session_label(dcr, EOS_LABEL)) { diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index f642cf9d4d..09c9b881a0 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -118,12 +118,12 @@ void run_job(JCR *jcr) dir->fsend(Job_start, jcr->Job); jcr->start_time = time(NULL); jcr->run_time = jcr->start_time; - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); /* update director */ do_fd_commands(jcr); jcr->end_time = time(NULL); dequeue_messages(jcr); /* send any queued messages */ - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); generate_daemon_event(jcr, "JobEnd"); dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->JobBytes, ec1), jcr->JobErrors); @@ -167,7 +167,7 @@ void do_fd_commands(JCR *jcr) } else { Jmsg0(jcr, M_FATAL, 0, _("Command error with FD, hanging up.\n")); } - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } quit = true; } diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 8ab4c2ed73..9fa42e1c52 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -93,7 +93,7 @@ bool job_cmd(JCR *jcr) pm_strcpy(jcr->errmsg, dir->msg); dir->fsend(BAD_job, stat, jcr->errmsg); Dmsg1(100, ">dird: %s", dir->msg); - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); return false; } Dmsg3(100, "==== incomplete=%d VolSesId=%d VolSesTime=%d\n", jcr->incomplete, @@ -174,7 +174,7 @@ bool run_cmd(JCR *jcr) return false; } - set_jcr_job_status(jcr, JS_WaitFD); /* wait for FD to connect */ + jcr->setJobStatus(JS_WaitFD); /* wait for FD to connect */ dir_send_job_status(jcr); gettimeofday(&tv, &tz); @@ -261,7 +261,7 @@ void handle_filed_connection(BSOCK *fd, char *job_name) } if (!jcr->authenticated) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); } pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */ free_jcr(jcr); diff --git a/bacula/src/stored/mac.c b/bacula/src/stored/mac.c index 5641e7e853..d4de7c1241 100644 --- a/bacula/src/stored/mac.c +++ b/bacula/src/stored/mac.c @@ -94,13 +94,13 @@ bool do_mac(JCR *jcr) /* Ready devices for reading and writing */ if (!acquire_device_for_read(jcr->read_dcr) || !acquire_device_for_append(jcr->dcr)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); goto bail_out; } Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->dcr->dev->file, jcr->dcr->dev->block_num); - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); begin_data_spool(jcr->dcr); @@ -164,7 +164,7 @@ ok_out: jcr->end_time = time(NULL); dequeue_messages(jcr); /* send any queued messages */ if (ok) { - set_jcr_job_status(jcr, JS_Terminated); + jcr->setJobStatus(JS_Terminated); } generate_daemon_event(jcr, "JobEnd"); dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, diff --git a/bacula/src/stored/read.c b/bacula/src/stored/read.c index c0f87e9951..c6f1c28edd 100644 --- a/bacula/src/stored/read.c +++ b/bacula/src/stored/read.c @@ -78,7 +78,7 @@ bool do_read_data(JCR *jcr) /* Tell File daemon we will send data */ fd->fsend(OK_data); - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); ok = read_records(dcr, record_cb, mount_next_read_volume); diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 3223d884fc..0176e75c49 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -69,7 +69,7 @@ bool use_cmd(JCR *jcr) * Get the device, media, and pool information */ if (!use_storage_cmd(jcr)) { - set_jcr_job_status(jcr, JS_ErrorTerminated); + jcr->setJobStatus(JS_ErrorTerminated); memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); return false; } diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index 898700d063..f152ba1317 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -234,13 +234,13 @@ static bool despool_data(DCR *dcr, bool commit) Jmsg(jcr, M_INFO, 0, _("Committing spooled data to Volume \"%s\". Despooling %s bytes ...\n"), jcr->dcr->VolumeName, edit_uint64_with_commas(jcr->dcr->job_spool_size, ec1)); - set_jcr_job_status(jcr, JS_DataCommitting); + jcr->setJobStatus(JS_DataCommitting); } else { Jmsg(jcr, M_INFO, 0, _("Writing spooled data to Volume. Despooling %s bytes ...\n"), edit_uint64_with_commas(jcr->dcr->job_spool_size, ec1)); - set_jcr_job_status(jcr, JS_DataDespooling); + jcr->setJobStatus(JS_DataDespooling); } - set_jcr_job_status(jcr, JS_DataDespooling); + jcr->setJobStatus(JS_DataDespooling); dir_send_job_status(jcr); dcr->despool_wait = true; dcr->spooling = false; @@ -302,6 +302,8 @@ static bool despool_data(DCR *dcr, bool commit) dcr->dev->print_name(), dcr->dev->bstrerror()); Dmsg2(000, "Fatal append error on device %s: ERR=%s\n", dcr->dev->print_name(), dcr->dev->bstrerror()); + /* Force in case Incomplete set */ + jcr->forceJobStatus(JS_FatalError); } Dmsg3(800, "Write block ok=%d FI=%d LI=%d\n", ok, block->FirstIndex, block->LastIndex); } @@ -319,6 +321,7 @@ static bool despool_data(DCR *dcr, bool commit) if (!dir_create_jobmedia_record(dcr)) { Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->getVolCatName(), jcr->Job); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ } /* Set new file/block parameters for current dcr */ set_new_file_parameters(dcr); @@ -334,7 +337,7 @@ static bool despool_data(DCR *dcr, bool commit) despool_elapsed = 1; } - Jmsg(dcr->jcr, M_INFO, 0, _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s Bytes/second\n"), + Jmsg(jcr, M_INFO, 0, _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s Bytes/second\n"), despool_elapsed / 3600, despool_elapsed % 3600 / 60, despool_elapsed % 60, edit_uint64_with_suffix(jcr->dcr->job_spool_size / despool_elapsed, ec1)); @@ -343,7 +346,7 @@ static bool despool_data(DCR *dcr, bool commit) lseek(rdcr->spool_fd, 0, SEEK_SET); /* rewind */ if (ftruncate(rdcr->spool_fd, 0) != 0) { berrno be; - Jmsg(dcr->jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"), + Jmsg(jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"), be.bstrerror()); /* Note, try continuing despite ftruncate problem */ } @@ -375,7 +378,7 @@ static bool despool_data(DCR *dcr, bool commit) if (!commit) { dcr->dev->dunblock(); } - set_jcr_job_status(jcr, JS_Running); + jcr->setJobStatus(JS_Running); dir_send_job_status(jcr); return ok; } @@ -393,6 +396,7 @@ static int read_block_from_spool_file(DCR *dcr) ssize_t stat; spool_hdr hdr; DEV_BLOCK *block = dcr->block; + JCR *jcr = dcr->jcr; rlen = sizeof(hdr); stat = read(dcr->spool_fd, (char *)&hdr, (size_t)rlen); @@ -406,20 +410,23 @@ static int read_block_from_spool_file(DCR *dcr) be.bstrerror()); } else { Pmsg2(000, _("Spool read error. Wanted %u bytes, got %d\n"), rlen, stat); - Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool header read error. Wanted %u bytes, got %d\n"), rlen, stat); + Jmsg2(jcr, M_FATAL, 0, _("Spool header read error. Wanted %u bytes, got %d\n"), rlen, stat); } + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return RB_ERROR; } rlen = hdr.len; if (rlen > block->buf_len) { Pmsg2(000, _("Spool block too big. Max %u bytes, got %u\n"), block->buf_len, rlen); - Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool block too big. Max %u bytes, got %u\n"), block->buf_len, rlen); + Jmsg2(jcr, M_FATAL, 0, _("Spool block too big. Max %u bytes, got %u\n"), block->buf_len, rlen); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return RB_ERROR; } stat = read(dcr->spool_fd, (char *)block->buf, (size_t)rlen); if (stat != (ssize_t)rlen) { Pmsg2(000, _("Spool data read error. Wanted %u bytes, got %d\n"), rlen, stat); Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool data read error. Wanted %u bytes, got %d\n"), rlen, stat); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return RB_ERROR; } /* Setup write pointers */ @@ -510,6 +517,7 @@ static bool write_spool_header(DCR *dcr) spool_hdr hdr; ssize_t stat; DEV_BLOCK *block = dcr->block; + JCR *jcr = dcr->jcr; hdr.FirstIndex = block->FirstIndex; hdr.LastIndex = block->LastIndex; @@ -520,11 +528,12 @@ static bool write_spool_header(DCR *dcr) stat = write(dcr->spool_fd, (char*)&hdr, sizeof(hdr)); if (stat == -1) { berrno be; - Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing header to spool file. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Error writing header to spool file. ERR=%s\n"), be.bstrerror()); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ } if (stat != (ssize_t)sizeof(hdr)) { - Jmsg(dcr->jcr, M_ERROR, 0, _("Error writing header to spool file." + Jmsg(jcr, M_ERROR, 0, _("Error writing header to spool file." " Disk probably full. Attempting recovery. Wanted to write=%d got=%d\n"), (int)stat, (int)sizeof(hdr)); /* If we wrote something, truncate it, then despool */ @@ -542,14 +551,16 @@ static bool write_spool_header(DCR *dcr) } } if (!despool_data(dcr, false)) { - Jmsg(dcr->jcr, M_FATAL, 0, _("Fatal despooling error.")); + Jmsg(jcr, M_FATAL, 0, _("Fatal despooling error.")); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return false; } continue; /* try again */ } return true; } - Jmsg(dcr->jcr, M_FATAL, 0, _("Retrying after header spooling error failed.\n")); + Jmsg(jcr, M_FATAL, 0, _("Retrying after header spooling error failed.\n")); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return false; } @@ -557,14 +568,16 @@ static bool write_spool_data(DCR *dcr) { ssize_t stat; DEV_BLOCK *block = dcr->block; + JCR *jcr = dcr->jcr; /* Write data */ for (int retry=0; retry<=1; retry++) { stat = write(dcr->spool_fd, block->buf, (size_t)block->binbuf); if (stat == -1) { berrno be; - Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing data to spool file. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Error writing data to spool file. ERR=%s\n"), be.bstrerror()); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ } if (stat != (ssize_t)block->binbuf) { /* @@ -584,7 +597,8 @@ static bool write_spool_data(DCR *dcr) } } if (!despool_data(dcr, false)) { - Jmsg(dcr->jcr, M_FATAL, 0, _("Fatal despooling error.")); + Jmsg(jcr, M_FATAL, 0, _("Fatal despooling error.")); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return false; } if (!write_spool_header(dcr)) { @@ -594,7 +608,8 @@ static bool write_spool_data(DCR *dcr) } return true; } - Jmsg(dcr->jcr, M_FATAL, 0, _("Retrying after data spooling error failed.\n")); + Jmsg(jcr, M_FATAL, 0, _("Retrying after data spooling error failed.\n")); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return false; } @@ -664,6 +679,7 @@ static bool blast_attr_spool_file(JCR *jcr, boffset_t size) if (jcr->dir_bsock->recv() <= 0) { Jmsg(jcr, M_FATAL, 0, _("Network error on BlastAttributes.\n")); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ return false; } @@ -688,6 +704,7 @@ bool commit_attribute_spool(JCR *jcr) berrno be; Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"), be.bstrerror()); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ goto bail_out; } size = ftello(dir->m_spool_fd); @@ -699,6 +716,7 @@ bool commit_attribute_spool(JCR *jcr) berrno be; Jmsg(jcr, M_FATAL, 0, _("Truncate on attributes file failed: ERR=%s\n"), be.bstrerror()); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ goto bail_out; } Dmsg2(100, "=== Attrib spool truncated from %lld to %lld\n", @@ -710,6 +728,7 @@ bool commit_attribute_spool(JCR *jcr) berrno be; Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"), be.bstrerror()); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ goto bail_out; } P(mutex); @@ -718,7 +737,7 @@ bool commit_attribute_spool(JCR *jcr) } spool_stats.attr_size += size; V(mutex); - set_jcr_job_status(jcr, JS_AttrDespooling); + jcr->setJobStatus(JS_AttrDespooling); dir_send_job_status(jcr); Jmsg(jcr, M_INFO, 0, _("Sending spooled attrs to the Director. Despooling %s bytes ...\n"), edit_uint64_with_commas(size, ec1)); @@ -748,6 +767,7 @@ static bool open_attr_spool_file(JCR *jcr, BSOCK *bs) berrno be; Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name, be.bstrerror()); + jcr->forceJobStatus(JS_FatalError); /* override any Incomplete */ free_pool_memory(name); return false; } diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 779507b996..4c485ad18b 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -612,7 +612,7 @@ void terminate_stored(int sig) free_jcr(jcr); continue; /* ignore console */ } - set_jcr_job_status(jcr, JS_Canceled); + jcr->setJobStatus(JS_Canceled); fd = jcr->file_bsock; if (fd) { fd->set_timed_out();