     default:
 +      if (set_waittime) {
 +	 /* set it before JobStatus */
++	 Dmsg0(800, "Setting wait_time\n");
 +	 jcr->wait_time = time(NULL);
 +      }
        jcr->JobStatus = JobStatus;

===================================================================
--- src/lib/jcr.c	(rvision 4696)
+++ src/lib/jcr.c	(copie de travail)
@@ -546,18 +546,53 @@
 
 void set_jcr_job_status(JCR *jcr, int JobStatus)
 {
+   bool set_waittime=false;
+
+   /* if wait state is new, we keep current time for watchdog MaxWaitTime */
+   switch (JobStatus) {
+      case JS_WaitFD:

+   jcr->JobStatus == JS_WaitJobRes   || \
+   jcr->JobStatus == JS_WaitClientRes|| \
+   jcr->JobStatus == JS_WaitMaxJobs  || \
+   jcr->JobStatus == JS_WaitPriority || \
+   jcr->SDJobStatus == JS_WaitMedia  || \
+   jcr->SDJobStatus == JS_WaitMount  || \
+   jcr->SDJobStatus == JS_WaitMaxJobs)
+
+
+
 #define foreach_jcr(jcr) \
    for (jcr=jcr_walk_start(); jcr; (jcr=jcr_walk_next(jcr)) )
 
@@ -166,6 +182,7 @@
    time_t start_time;                 /* when job actually started */
    time_t run_time;                   /* used for computing speed */
    time_t end_time;                   /* job end time */
