  extern void backup_cleanup(JCR *jcr, int TermCode);
 Index: src/filed/job.c
 ===================================================================
---- src/filed/job.c	(rvision 5856)
+--- src/filed/job.c	(rvision 6032)
 +++ src/filed/job.c	(copie de travail)
 @@ -269,6 +269,16 @@
     /* Run the after job */
     run_scripts(jcr, jcr->RunScripts, "ClientAfterJob");
  
-+   if (jcr->JobId) {
++   if (jcr->JobId) {		/* send EndJob if running a job */
 +      char ed1[50], ed2[50];
 +      /* Send termination status back to Dir */
 +      bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,

 }
Index: src/jcr.h
===================================================================
--- src/jcr.h	(rvision 5856)
+++ src/jcr.h	(copie de travail)
@@ -301,6 +301,7 @@
    int32_t pki_session_encoded_size;  /* Size of DER-encoded pki_session */

    /* Cancel SD */
-   cancel_storage_daemon_job(jcr);
-   wait_for_storage_daemon_termination(jcr);
+   wait_for_job_termination(jcr, FDConnectTimeout);
    Dmsg1(400, "after wait for sd. use=%d\n", jcr->use_count());
    return false;
 }
