]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/stored.c
Eliminate zombie job in SD
[bacula/bacula] / bacula / src / stored / stored.c
index ae82a14028bba516c2e2d3ee7c439f59e12851c9..366be796c5b2f4c34cd5283064b46d37c9040774 100644 (file)
@@ -290,13 +290,12 @@ static void check_config()
  */
 static void *device_allocation(void *arg)
 {
-   int i;
    DEVRES *device;
 
    LockRes();
    pthread_detach(pthread_self());
 
-   for (device=NULL,i=0;  (device=(DEVRES *)GetNextRes(R_DEVICE, (RES *)device)); i++) {
+   foreach_res(device, R_DEVICE) {
       Dmsg1(90, "calling init_dev %s\n", device->device_name);
       device->dev = init_dev(NULL, device);
       Dmsg1(10, "SD init done %s\n", device->device_name);
@@ -353,7 +352,7 @@ void terminate_stored(int sig)
        *   volume status.
        */
       lock_jcr_chain();
-      for (jcr=NULL; (jcr=get_next_jcr(jcr)); ) {
+      foreach_jcr(jcr) {
         BSOCK *fd;
         free_locked_jcr(jcr);
         if (jcr->JobId == 0) {
@@ -381,7 +380,7 @@ void terminate_stored(int sig)
    Dmsg1(200, "In terminate_stored() sig=%d\n", sig);
 
    LockRes();
-   for (device=NULL; (device=(DEVRES *)GetNextRes(R_DEVICE, (RES *)device)); ) {
+   foreach_res(device, R_DEVICE) {
       if (device->dev) {
         term_dev(device->dev);
       }