1 Index: src/dird/backup.c
2 ===================================================================
3 --- src/dird/backup.c (révision 5882)
4 +++ src/dird/backup.c (copie de travail)
6 set_jcr_job_status(jcr, JS_ErrorTerminated);
7 Dmsg1(400, "wait for sd. use=%d\n", jcr->use_count());
9 - cancel_storage_daemon_job(jcr);
10 - wait_for_storage_daemon_termination(jcr);
11 + wait_for_job_termination(jcr, 300);
12 Dmsg1(400, "after wait for sd. use=%d\n", jcr->use_count());
16 * are done, we return the job status.
17 * Also used by restore.c
19 -int wait_for_job_termination(JCR *jcr)
20 +int wait_for_job_termination(JCR *jcr, int timeout)
23 BSOCK *fd = jcr->file_bsock;
25 uint64_t JobBytes = 0;
30 set_jcr_job_status(jcr, JS_Running);
31 - /* Wait for Client to terminate */
32 - while ((n = bget_dirmsg(fd)) >= 0) {
34 - (sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles,
35 - &ReadBytes, &JobBytes, &Errors, &VSS, &Encrypt) == 7 ||
36 - sscanf(fd->msg, OldEndJob, &jcr->FDJobStatus, &JobFiles,
37 - &ReadBytes, &JobBytes, &Errors) == 5)) {
39 - set_jcr_job_status(jcr, jcr->FDJobStatus);
40 - Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
42 - Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"),
47 + tid = start_bsock_timer(fd, timeout); /* TODO: use user timeout */
49 - if (job_canceled(jcr)) {
51 + /* Wait for Client to terminate */
52 + while ((n = bget_dirmsg(fd)) >= 0) {
54 + (sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles,
55 + &ReadBytes, &JobBytes, &Errors, &VSS, &Encrypt) == 7 ||
56 + sscanf(fd->msg, OldEndJob, &jcr->FDJobStatus, &JobFiles,
57 + &ReadBytes, &JobBytes, &Errors) == 5)) {
59 + set_jcr_job_status(jcr, jcr->FDJobStatus);
60 + Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
62 + Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"),
65 + if (job_canceled(jcr)) {
71 + stop_bsock_timer(tid);
74 - if (is_bnet_error(fd)) {
75 - Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"),
76 - job_type_to_str(jcr->JobType), fd->bstrerror());
77 + if (is_bnet_error(fd)) {
78 + Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"),
79 + job_type_to_str(jcr->JobType), fd->bstrerror());
81 + fd->signal(BNET_TERMINATE); /* tell Client we are terminating */
83 - fd->signal(BNET_TERMINATE); /* tell Client we are terminating */
85 /* Force cancel in SD if failing */
86 if (job_canceled(jcr) || !fd_ok) {
88 /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/Errors */
89 wait_for_storage_daemon_termination(jcr);
92 /* Return values from FD */
94 jcr->JobFiles = JobFiles;
96 // jcr->JobStatus, jcr->SDJobStatus);
98 /* Return the first error status we find Dir, FD, or SD */
99 - if (!fd_ok || is_bnet_error(fd)) {
100 + if (!fd_ok || is_bnet_error(fd)) { /* if fd not set, that use !fd_ok */
101 jcr->FDJobStatus = JS_ErrorTerminated;
103 if (jcr->JobStatus != JS_Terminated) {
104 Index: src/dird/protos.h
105 ===================================================================
106 --- src/dird/protos.h (révision 5882)
107 +++ src/dird/protos.h (copie de travail)
109 extern bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr);
112 -extern int wait_for_job_termination(JCR *jcr);
113 +extern int wait_for_job_termination(JCR *jcr, int timeout=0);
114 extern bool do_backup_init(JCR *jcr);
115 extern bool do_backup(JCR *jcr);
116 extern void backup_cleanup(JCR *jcr, int TermCode);
117 Index: src/filed/job.c
118 ===================================================================
119 --- src/filed/job.c (révision 5882)
120 +++ src/filed/job.c (copie de travail)
125 + if (jcr->JobId) { /* send EndJob if running a job */
126 + char ed1[50], ed2[50];
127 + /* Send termination status back to Dir */
128 + bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
129 + edit_uint64(jcr->ReadBytes, ed1),
130 + edit_uint64(jcr->JobBytes, ed2), jcr->Errors, jcr->VSS,
132 + Dmsg1(110, "End FD msg: %s\n", dir->msg);
135 /* Inform Storage daemon that we are done */
136 if (jcr->store_bsock) {
137 bnet_sig(jcr->store_bsock, BNET_TERMINATE);
138 @@ -1331,15 +1341,13 @@
139 BSOCK *sd = jcr->store_bsock;
142 - char ed1[50], ed2[50];
143 - bool bDoVSS = false;
145 #if defined(WIN32_VSS)
146 // capture state here, if client is backed up by multiple directors
147 // and one enables vss and the other does not then enable_vss can change
148 // between here and where its evaluated after the job completes.
149 - bDoVSS = g_pVSSClient && enable_vss;
151 + jcr->VSS = g_pVSSClient && enable_vss;
153 /* Run only one at a time */
156 @@ -1395,7 +1403,7 @@
158 #if defined(WIN32_VSS)
159 /* START VSS ON WIN 32 */
162 if (g_pVSSClient->InitializeForBackup()) {
163 /* tell vss which drives to snapshot */
164 char szWinDriveLetters[27];
165 @@ -1488,7 +1496,7 @@
166 #if defined(WIN32_VSS)
167 /* STOP VSS ON WIN 32 */
168 /* tell vss to close the backup session */
171 if (g_pVSSClient->CloseBackup()) {
172 /* inform user about writer states */
173 for (int i=0; i<(int)g_pVSSClient->GetWriterCount(); i++) {
174 @@ -1504,12 +1512,6 @@
178 - bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
179 - edit_uint64(jcr->ReadBytes, ed1),
180 - edit_uint64(jcr->JobBytes, ed2), jcr->Errors, (int)bDoVSS,
182 - Dmsg1(110, "End FD msg: %s\n", dir->msg);
184 return 0; /* return and stop command loop */
187 @@ -1521,7 +1523,7 @@
189 BSOCK *dir = jcr->dir_bsock;
190 BSOCK *sd = jcr->store_bsock;
191 - char level[100], ed1[50], ed2[50];
194 jcr->JobType = JT_VERIFY;
195 if (sscanf(dir->msg, verifycmd, level) != 1) {
196 @@ -1585,15 +1587,6 @@
198 bnet_sig(dir, BNET_EOD);
200 - /* Send termination status back to Dir */
201 - bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
202 - edit_uint64(jcr->ReadBytes, ed1),
203 - edit_uint64(jcr->JobBytes, ed2), jcr->Errors, 0,
205 - Dmsg1(110, "End FD msg: %s\n", dir->msg);
207 - /* Inform Director that we are done */
208 - bnet_sig(dir, BNET_TERMINATE);
209 return 0; /* return and terminate command loop */
212 @@ -1609,7 +1602,6 @@
213 bool use_regexwhere=false;
216 - char ed1[50], ed2[50];
219 * Scan WHERE (base directory for restore) from command
220 @@ -1696,16 +1688,7 @@
222 set_jcr_job_status(jcr, JS_ErrorTerminated);
224 - /* Send termination status back to Dir */
225 - bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
226 - edit_uint64(jcr->ReadBytes, ed1),
227 - edit_uint64(jcr->JobBytes, ed2), jcr->Errors, 0,
229 - Dmsg1(110, "End FD msg: %s\n", dir->msg);
231 - /* Inform Director that we are done */
232 - bnet_sig(dir, BNET_TERMINATE);
234 Dmsg0(130, "Done in job.c\n");
235 return 0; /* return and terminate command loop */
238 ===================================================================
239 --- src/jcr.h (révision 5882)
240 +++ src/jcr.h (copie de travail)
242 int32_t pki_session_encoded_size; /* Size of DER-encoded pki_session */
243 POOLMEM *crypto_buf; /* Encryption/Decryption buffer */
244 DIRRES* director; /* Director resource */
245 + bool VSS; /* VSS used by FD */
246 #endif /* FILE_DAEMON */