--- /dev/null
+
+ This patch can be applied to version 3.0.1 and fixes a 
+ a race condition that causes the SD to hang. This should
+ fix bug #1287.
+
+ Apply it to version 3.0.1 with:
+
+ cd <bacula-source>
+ patch -p0 <3.0.1-sd-hang.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+
+
+Index: src/lib/jcr.c
+===================================================================
+--- src/lib/jcr.c      (revision 8840)
++++ src/lib/jcr.c      (working copy)
+@@ -518,6 +518,7 @@
+             jcr->JobId, jcr->use_count(), jcr->Job);
+    }
+    remove_jcr(jcr);                   /* remove Jcr from chain */
++   unlock_jcr_chain();
+ 
+    dequeue_messages(jcr);
+    job_end_pop(jcr);                  /* pop and call hooked routines */
+@@ -571,7 +572,6 @@
+       jcr->daemon_free_jcr(jcr);      /* call daemon free routine */
+    }
+ 
+-   unlock_jcr_chain();
+    free_common_jcr(jcr);
+    close_msg(NULL);                   /* flush any daemon messages */
+    garbage_collect_memory_pool();
 
             jcr->JobId, jcr->use_count(), jcr->Job);
    }
    remove_jcr(jcr);                   /* remove Jcr from chain */
+   unlock_jcr_chain();
 
    dequeue_messages(jcr);
    job_end_pop(jcr);                  /* pop and call hooked routines */
       jcr->daemon_free_jcr(jcr);      /* call daemon free routine */
    }
 
-   unlock_jcr_chain();
    free_common_jcr(jcr);
    close_msg(NULL);                   /* flush any daemon messages */
    garbage_collect_memory_pool();
 
           
 General:
 
+19May09
+kes  During jcr destruction hold jcr_chaing lock only for minimum
+     time necessary.  This should fix the SD deadlock in bug #1287.
 18May09
 kes  Simplify messages printed by SD when reserve fails. This
      should fix bug #1285.