mounted and read, or the autochanger unloads the volume.
     This should help the SD re-use volumes that are already mounted,
     and should fix bug #886.
kes  Apply patch from user brettedgar that allows gnome2-console include
     the OpenSSL libraries, and hence work with SSL.  Fixes bug #885.
kes  Apply patch from Lucien Weller that fixes day of week calculation
     because of DST flag problem. Fixes bug #887.
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5012 
91ce42f0-d328-0410-95d8-
f526ca767f89
 
 #CONS_LDFLAGS=@CONS_LDFLAGS@ $(GNOME_LIBDIR) $(GNOMEUI_LIBS)
 
 CONS_INC=$(GNOME_INCLUDEDIR)
-CONS_LIBS=$(GNOME_LIBS)
+CONS_LIBS=$(GNOME_LIBS) $(OPENSSL_LIBS)
 CONS_LDFLAGS=$(GNOME_LIBDIR) $(GNOMEUI_LIBS)
 
 
 
    tm_yday = tm.tm_yday;
    tm.tm_mon = 0;
    tm.tm_mday = 4;
+   tm.tm_isdst = 0;                   /* 4 Jan is not DST */ 
    time4 = mktime(&tm);
    (void)localtime_r(&time4, &tm);
    fty = 1 - tm.tm_wday;
 
    /* Multiply by large prime number, take top bits, mask for remainder */
    index = ((hash * 1103515249) >> rshift) & mask;
    Dmsg2(100, "Leave hash_index hash=0x%x index=%d\n", hash, index);
-   return;
 }
 
 htable::htable(void *item, void *link, int tsize)
 
       } else {
          dev->Slot = 0;            /* nothing loaded */
       }
+      free_volume(dev);            /* Free any volume associated with this drive */
       free_pool_memory(changer);
       unlock_changer(dcr);
    }
       dev->Slot = 0;           /* nothing loaded */
       Dmsg0(100, "Slot unloaded\n");
    }
+   free_volume(dev);               /* Free any volume associated with this drive */
    unlock_changer(dcr);
    dev->dunlock();
    free_pool_memory(changer_cmd);
 
  */
 void DEVICE::clear_volhdr()
 {
-   /* If we have an unused volume associated with this drive, free it */
-   if (vol && !is_busy()) {
-      free_volume(this);
-   }
    Dmsg1(100, "Clear volhdr vol=%s\n", VolHdr.VolumeName);
    memset(&VolHdr, 0, sizeof(VolHdr));
 }
 
 
    lock_volumes();
    foreach_dlist(vol, vol_list) {
-      if (vol->dev) {
-         len = Mmsg(msg, "%s on device %s\n", vol->vol_name, vol->dev->print_name());
+      DEVICE *dev = vol->dev;
+      if (dev) {
+         len = Mmsg(msg, "%s on device %s\n", vol->vol_name, dev->print_name());
+         sendit(msg.c_str(), len, arg);
+         len = Mmsg(msg, "    Reader=%d writers=%d reserved=%d\n", dev->can_read()?1:0,
+            dev->num_writers, dev->reserved_device);
          sendit(msg.c_str(), len, arg);
       } else {
          len = Mmsg(msg, "%s no dev\n", vol->vol_name);
       return false;
    }
 
-   return free_volume(dev);
+   /*  
+    * If this is a tape, we do not free the volume, rather we wait
+    *  until the autoloader unloads it, or until another tape is
+    *  explicitly read in this drive. This allows the SD to remember
+    *  where the tapes are or last were.
+    */
+   if (dev->is_tape()) {
+      return true;
+   } else {
+      return free_volume(dev);
+   }
 }
 
 /*
 
 
 #undef  VERSION
 #define VERSION "2.1.14"
-#define BDATE   "10 June 2007"
-#define LSMDATE "10Jun07"
+#define BDATE   "14 June 2007"
+#define LSMDATE "14Jun07"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2007"       /* year for copyright messages in progs */
 
               Technical notes on version 2.1
 
 General:
-10Jun08
+14Jun07
+kes  Do not free a volume on a tape drive until another volume is
+     mounted and read, or the autochanger unloads the volume.
+     This should help the SD re-use volumes that are already mounted,
+     and should fix bug #886.
+kes  Apply patch from user brettedgar that allows gnome2-console include
+     the OpenSSL libraries, and hence work with SSL.  Fixes bug #885.
+kes  Apply patch from Lucien Weller that fixes day of week calculation
+     because of DST flag problem. Fixes bug #887.
+10Jun07
 kes  Move find_next_appendable_volume() to after acquiring a valid device
      in reserve.c.  This fixes bug #864 -- confirmed by reporter.
 09Jun07