static char NO_open[] = "3901 Error session already open\n";
static char NOT_opened[] = "3902 Error session not opened\n";
static char OK_end[] = "3000 OK end\n";
-static char OK_close[] = "3000 OK close Volumes = %d\n";
+static char OK_close[] = "3000 OK close Status = %d\n";
static char OK_open[] = "3000 OK open ticket = %d\n";
static char OK_append[] = "3000 OK append data\n";
static char ERROR_append[] = "3903 Error append data\n";
char ec1[30];
+ fd->jcr = (void *)jcr;
+ dir->jcr = (void *)jcr;
Dmsg1(120, "Start run Job=%s\n", jcr->Job);
bnet_fsend(dir, Job_start, jcr->Job);
- time(&jcr->start_time);
+ 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;
/* Read command coming from the File daemon */
- if (bnet_recv(fd) <= 0) {
+ stat = bnet_recv(fd);
+ if (is_bnet_stop(fd)) { /* hardeof or error */
break; /* connection terminated */
}
+ if (stat <= 0) {
+ continue; /* ignore signals and zero length msgs */
+ }
Dmsg1(110, "<filed: %s", fd->msg);
found = 0;
for (i=0; fd_cmds[i].cmd; i++) {
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;
break;
}
}
- time(&jcr->end_time);
- if (!job_cancelled(jcr)) {
- jcr->JobStatus = JS_Terminated;
- }
+ bnet_sig(fd, BNET_TERMINATE); /* signal to FD job is done */
+ jcr->end_time = time(NULL);
+ set_jcr_job_status(jcr, JS_Terminated);
bnet_fsend(dir, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1));
return 0;
}
/* Send final statistics to File daemon */
- bnet_fsend(fd, OK_close, jcr->NumVolumes);
+ bnet_fsend(fd, OK_close, jcr->JobStatus);
Dmsg1(160, ">filed: %s\n", fd->msg);
bnet_sig(fd, BNET_EOD); /* send EOD to File daemon */
Dmsg1(110, "Append close session: %s\n", dev_name(jcr->device->dev));
- if (jcr->JobStatus != JS_ErrorTerminated) {
- jcr->JobStatus = JS_Terminated;
- }
jcr->session_opened = FALSE;
return 1;
}
jcr->RestoreBootstrap, strerror(errno));
goto bail_out;
}
- while (bnet_recv(fd) > 0) {
+ while (bnet_recv(fd) >= 0) {
Dmsg1(400, "stored<filed: bootstrap file %s\n", fd->msg);
fputs(fd->msg, bs);
}