 +   case JS_WaitJobRes:
 +   case JS_WaitClientRes:
 +   case JS_WaitMaxJobs:
-+   case JS_WaitPriority:  
-+      set_waittime = false;	/* keep old time */
++   case JS_WaitPriority:
++       set_waittime = false;    /* keep old time */
     default:
+       jcr->JobStatus = JobStatus;
 +      if (set_waittime) {
-+	 /* set it before JobStatus */
-+	 Dmsg0(800, "Setting wait_time\n");
-+	 jcr->wait_time = time(NULL);
++         /* set it before JobStatus */
++         Dmsg0(800, "Setting wait_time\n");
++         jcr->wait_time = time(NULL);
 +      }
-       jcr->JobStatus = JobStatus;
     }
- }
+    Dmsg3(100, "jid=%u OnExit JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
+          jcr->JobStatus, JobStatus);

    /* TODO : check if it is used somewhere */
    if (jcr->job->RunScripts == NULL) {
       Dmsg0(200, "Warning, job->RunScripts is empty\n");
@@ -450,15 +456,20 @@
       }
 
       /* check MaxWaitTime */

       }
 
       if (cancel) {
@@ -522,47 +533,71 @@
  * Check if the maxwaittime has expired and it is possible
  *  to cancel the job.
  */
