set_jcr_job_status(jcr, JS_WaitFD);
/* Wait for Client to terminate */
- while ((n = bget_msg(fd, 0)) >= 0 && !job_cancelled(jcr)) {
+ while ((n = bget_msg(fd, 0)) >= 0) {
if (sscanf(fd->msg, EndBackup, &jcr->FDJobStatus, &jcr->JobFiles,
&jcr->ReadBytes, &jcr->JobBytes) == 4) {
fd_ok = TRUE;
set_jcr_job_status(jcr, jcr->FDJobStatus);
Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
}
+ if (job_cancelled(jcr)) {
+ break;
+ }
}
if (is_bnet_error(fd)) {
Jmsg(jcr, M_FATAL, 0, _("<filed: network error during BACKUP command. ERR=%s\n"),
if (!db_get_job_record(jcr->db, &jcr->jr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"),
db_strerror(jcr->db));
- TermCode = JS_ErrorTerminated;
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
}
strcpy(mr.VolumeName, jcr->VolumeName);
if (!db_get_media_record(jcr->db, &mr)) {
Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for stats: %s"),
db_strerror(jcr->db));
- TermCode = JS_ErrorTerminated;
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
}
/* Now update the bootstrap file if any */
- if (TermCode == JS_Terminated && jcr->job->WriteBootstrap) {
+ if (jcr->JobStatus == JS_Terminated && jcr->job->WriteBootstrap) {
FILE *fd;
BPIPE *bpipe = NULL;
int got_pipe = 0;
} else {
Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n"
"%s: ERR=%s\n"), fname, strerror(errno));
- TermCode = JS_ErrorTerminated;
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
}
}
msg_type = M_INFO; /* by default INFO message */
- switch (TermCode) {
+ switch (jcr->JobStatus) {
case JS_Terminated:
term_msg = _("Backup OK");
break;
break;
default:
term_msg = term_code;
- sprintf(term_code, _("Inappropriate term code: %c\n"), TermCode);
+ sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
break;
}
bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
* it is normal. Or look at it the other way, only for a
* normal exit should we complain about this error.
*/
- if (TermCode == JS_Terminated) {
+ if (jcr->JobStatus == JS_Terminated) {
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
}
jcr->VolumeName[0] = 0; /* none */
void wait_for_storage_daemon_termination(JCR *jcr)
{
+ int cancel_count = 0;
/* Now wait for Storage daemon to terminate our message thread */
P(jcr->mutex);
set_jcr_job_status(jcr, JS_WaitSD);
- while (!jcr->msg_thread_done && !job_cancelled(jcr)) {
+ while (!jcr->msg_thread_done) {
struct timeval tv;
struct timezone tz;
struct timespec timeout;
timeout.tv_sec = tv.tv_sec + 10; /* wait 10 seconds */
Dmsg0(300, "I'm waiting for message thread termination.\n");
pthread_cond_timedwait(&jcr->term_wait, &jcr->mutex, &timeout);
+ if (job_cancelled(jcr)) {
+ cancel_count++;
+ }
+ /* Give SD 30 seconds to clean up after cancel */
+ if (cancel_count == 3) {
+ break;
+ }
}
V(jcr->mutex);
set_jcr_job_status(jcr, jcr->SDJobStatus);
* Version $Id$
*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Dmsg1(110, "bfiled: opened data connection %d to stored\n", sd->fd);
if (!bnet_set_buffer_size(sd, MAX_NETWORK_BUFFER_SIZE, BNET_SETBUF_WRITE)) {
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
return 0;
}
set_jcr_job_status(jcr, JS_ErrorTerminated);
} else {
set_jcr_job_status(jcr, JS_Terminated);
+ if (jcr->JobStatus != JS_Terminated) {
+ goto cleanup; /* bail out now */
+ }
/*
* Expect to get response to append_data from Storage daemon
*/
*/
sm_check(__FILE__, __LINE__, False);
Dmsg0(90, "Write_end_session_label()\n");
+
/* Create Job status for end of session label */
- if (!job_cancelled(jcr) && ok) {
- set_jcr_job_status(jcr, JS_Terminated);
- } else if (!ok) {
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- }
+ set_jcr_job_status(jcr, ok?JS_Terminated:JS_ErrorTerminated);
+
+ Dmsg1(200, "Write session label JobStatus=%d\n", jcr->JobStatus);
+
if (!write_session_label(jcr, block, EOS_LABEL)) {
Jmsg1(jcr, M_FATAL, 0, _("Error writting end session label. ERR=%s\n"),
strerror_dev(dev));
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
ok = FALSE;
}
/* Write out final block of this session */
if (!write_block_to_device(jcr, dev, block)) {
Pmsg0(000, _("Set ok=FALSE after write_block_to_device.\n"));
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
ok = FALSE;
}
+ Dmsg1(200, "release device JobStatus=%d\n", jcr->JobStatus);
/* Release the device */
if (!release_device(jcr, dev)) {
Pmsg0(000, _("Error in release_device\n"));
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
ok = FALSE;
}
close_spool_file(jcr, jcr->dir_bsock);
}
+ dir_send_job_status(jcr); /* update director */
+
Dmsg0(90, "return from do_append_data()\n");
return ok ? 1 : 0;
}
if (jcr->file_bsock) {
bnet_sig(jcr->file_bsock, BNET_TERMINATE);
}
- bnet_fsend(dir, _("3000 Job %s Status=%c marked to be cancelled.\n"),
- jcr->Job, oldStatus);
+ bnet_fsend(dir, _("3000 Job %s marked to be cancelled.\n"), jcr->Job);
free_jcr(jcr);
}
} else {
bnet_fsend(dir, Job_start, jcr->Job);
jcr->start_time = time(NULL);
jcr->run_time = jcr->start_time;
- jcr->JobStatus = JS_Running;
+ set_jcr_job_status(jcr, JS_Running);
dir_send_job_status(jcr); /* update director */
for (quit=0; !quit;) {
int stat;
if (strncmp(fd_cmds[i].cmd, fd->msg, strlen(fd_cmds[i].cmd)) == 0) {
found = 1; /* indicate command found */
if (!fd_cmds[i].func(jcr)) { /* do command */
- jcr->JobStatus = JS_ErrorTerminated;
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
quit = 1;
}
break;
}
bnet_sig(fd, BNET_TERMINATE); /* signal to FD job is done */
jcr->end_time = time(NULL);
- if (!job_cancelled(jcr)) {
- jcr->JobStatus = JS_Terminated;
- }
+ set_jcr_job_status(jcr, JS_Terminated);
bnet_fsend(dir, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1));
bnet_fsend(fd, NOT_opened);
return 0;
}
- if (jcr->JobStatus != JS_ErrorTerminated) {
- jcr->JobStatus = JS_Terminated;
- }
/* Send final statistics to File daemon */
bnet_fsend(fd, OK_close, jcr->JobStatus);
Dmsg1(160, ">filed: %s\n", fd->msg);