2 ===================================================================
3 --- src/dird/job.c (révision 8005)
4 +++ src/dird/job.c (copie de travail)
11 if (!job_waiting(jcr)) {
14 - Dmsg3(200, "check maxwaittime %u - %u >= %u\n", watchdog_time, jcr->wait_time, job->MaxWaitTime);
16 + if (jcr->wait_time) {
17 + current = watchdog_time - jcr->wait_time;
20 + Dmsg3(200, "check maxwaittime %u >= %u\n",
21 + current + jcr->wait_time_sum, job->MaxWaitTime);
22 if (job->MaxWaitTime != 0 &&
23 - (watchdog_time - jcr->wait_time) >= job->MaxWaitTime) {
24 + (current + jcr->wait_time_sum) >= job->MaxWaitTime) {
29 ===================================================================
30 --- src/jcr.h (révision 8005)
31 +++ src/jcr.h (copie de travail)
33 time_t start_time; /* when job actually started */
34 time_t run_time; /* used for computing speed */
35 time_t end_time; /* job end time */
36 - time_t wait_time; /* when job have started to wait */
37 + time_t wait_time_sum; /* cumulative wait time since job start */
38 + time_t wait_time; /* timestamp when job have started to wait */
39 POOLMEM *client_name; /* client name */
40 POOLMEM *RestoreBootstrap; /* Bootstrap file to restore */
41 POOLMEM *stime; /* start time for incremental/differential */
43 ===================================================================
44 --- src/lib/jcr.c (révision 8005)
45 +++ src/lib/jcr.c (copie de travail)
50 -void set_jcr_job_status(JCR *jcr, int JobStatus)
52 +static void update_wait_time(JCR *jcr, int newJobStatus)
54 - bool set_waittime = false;
55 - int oldJobStatus = jcr->JobStatus;
56 - int priority, old_priority;
57 + bool enter_in_waittime;
58 + int oldJobStatus = jcr->JobStatus;
60 - priority = get_status_priority(JobStatus);
61 - old_priority = get_status_priority(oldJobStatus);
63 - Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);
64 - /* if wait state is new, we keep current time for watchdog MaxWaitTime */
65 - switch (JobStatus) {
70 - case JS_WaitStoreRes:
72 - case JS_WaitClientRes:
73 - case JS_WaitMaxJobs:
74 - case JS_WaitPriority:
75 - set_waittime = true;
81 - * For a set of errors, ... keep the current status
82 - * so it isn't lost. For all others, set it.
84 - Dmsg3(300, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
85 - jcr->JobStatus, JobStatus);
86 - if (priority >= old_priority) {
87 - jcr->JobStatus = JobStatus; /* replace with new priority */
88 + switch (newJobStatus) {
93 + case JS_WaitStoreRes:
95 + case JS_WaitClientRes:
96 + case JS_WaitMaxJobs:
97 + case JS_WaitPriority:
98 + enter_in_waittime = true;
101 + enter_in_waittime = false; /* not a Wait situation */
106 * If we were previously waiting and are not any more
107 * we want to update the wait_time variable, which is
108 @@ -788,13 +776,43 @@
109 case JS_WaitClientRes:
111 case JS_WaitPriority:
112 - set_waittime = false; /* keep old time */
113 + if (!enter_in_waittime) { /* we get out the wait time */
114 + jcr->wait_time_sum += (time(NULL) - jcr->wait_time);
115 + jcr->wait_time = 0;
119 + /* if wait state is new, we keep current time for watchdog MaxWaitTime */
121 - if (set_waittime) {
122 - Dmsg0(800, "Setting wait_time\n");
123 + if (enter_in_waittime) {
124 jcr->wait_time = time(NULL);
130 +void set_jcr_job_status(JCR *jcr, int JobStatus)
132 + int priority, old_priority;
133 + int oldJobStatus = jcr->JobStatus;
134 + priority = get_status_priority(JobStatus);
135 + old_priority = get_status_priority(oldJobStatus);
137 + Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);
139 + /* Update wait_time depending on newJobStatus and oldJobStatus */
140 + update_wait_time(jcr, JobStatus);
143 + * For a set of errors, ... keep the current status
144 + * so it isn't lost. For all others, set it.
146 + Dmsg3(300, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
147 + jcr->JobStatus, JobStatus);
148 + if (priority >= old_priority) {
149 + jcr->JobStatus = JobStatus; /* replace with new priority */
152 if (oldJobStatus != jcr->JobStatus) {
153 Dmsg3(200, "jid=%u leave set_old_job_status=%c new_set=%c\n", (uint32_t)jcr->JobId,
154 oldJobStatus, JobStatus);