src/stored/vol_mgr.c
dlist *dup_vol_list(JCR *jcr)
{
   dlist *temp_vol_list;
   VOLRES *vol = NULL;

   Dmsg0(dbglvl, "lock volumes\n");

   Dmsg0(dbglvl, "duplicate vol list\n");
   temp_vol_list = New(dlist(vol, &vol->link));
   foreach_vol(vol) {
      VOLRES *nvol;
      VOLRES *tvol = (VOLRES *)malloc(sizeof(VOLRES));
      memset(tvol, 0, sizeof(VOLRES));
      tvol->vol_name = bstrdup(vol->vol_name);
      tvol->dev = vol->dev;
      tvol->init_mutex();
      tvol->inc_use_count();
      nvol = (VOLRES *)temp_vol_list->binary_insert(tvol, name_compare);
      if (tvol != nvol) {
         tvol->dev = NULL;                   /* don't zap dev entry */
         free_vol_item(tvol);
         Pmsg0(000, "Logic error. Duplicating vol list hit duplicate.\n");
         Jmsg(jcr, M_WARNING, 0, "Logic error. Duplicating vol list hit duplicate.\n");
      }
   }
   endeach_vol(vol);
   Dmsg0(dbglvl, "unlock volumes\n");
   return temp_vol_list;
}
/*
 * Create a temporary copy of the volume list.  We do this,
 *   to avoid having the volume list locked during the
 *   call to reserve_device(), which would cause a deadlock.
 * Note, we may want to add an update counter on the vol_list
 *   so that if it is modified while we are traversing the copy
 *   we can take note and act accordingly (probably redo the
 *   search at least a few times).
 */
Create a temporary copy of the volume list.  We do this,
to avoid having the volume list locked during the
call to reserve_device(), which would cause a deadlock.
Note, we may want to add an update counter on the vol_list
so that if it is modified while we are traversing the copy
we can take note and act accordingly (probably redo the
search at least a few times).
Create a temporary copy of the volume list . We do this to avoid having the volume list locked during the call to reserve_device () which would cause a deadlock . Note we may want to add an update counter on the vol_list so that if it is modified while we are traversing the copy we can take note and act accordingly ( probably redo the search at least a few times ) .
dlist *dup_vol_list(JCR *jcr)
{
   dlist *temp_vol_list;
   VOLRES *vol = NULL;
   Dmsg0(dbglvl, "lock volumes\n");
   Dmsg0(dbglvl, "duplicate vol list\n");
   temp_vol_list = New(dlist(vol, &vol->link));
   foreach_vol(vol) {
      VOLRES *nvol;
      VOLRES *tvol = (VOLRES *)malloc(sizeof(VOLRES));
      memset(tvol, 0, sizeof(VOLRES));
      tvol->vol_name = bstrdup(vol->vol_name);
      tvol->dev = vol->dev;
      tvol->init_mutex();
      tvol->inc_use_count();
      nvol = (VOLRES *)temp_vol_list->binary_insert(tvol, name_compare);
      if (tvol != nvol) {
         tvol->dev = NULL;                   
         free_vol_item(tvol);
         Pmsg0(000, "Logic error. Duplicating vol list hit duplicate.\n");
         Jmsg(jcr, M_WARNING, 0, "Logic error. Duplicating vol list hit duplicate.\n");
      }
   }
   endeach_vol(vol);
   Dmsg0(dbglvl, "unlock volumes\n");
   return temp_vol_list;
}
dlist * dup_vol_list ( JCR * jcr ) { dlist * temp_vol_list ; VOLRES * vol = NULL ; Dmsg0 ( dbglvl , " \n " ) ; Dmsg0 ( dbglvl , " \n " ) ; temp_vol_list = New ( dlist ( vol , & vol -> link ) ) ; foreach_vol ( vol ) { VOLRES * nvol ; VOLRES * tvol = ( VOLRES * ) malloc ( sizeof ( VOLRES ) ) ; memset ( tvol , 0 , sizeof ( VOLRES ) ) ; tvol -> vol_name = bstrdup ( vol -> vol_name ) ; tvol -> dev = vol -> dev ; tvol -> init_mutex ( ) ; tvol -> inc_use_count ( ) ; nvol = ( VOLRES * ) temp_vol_list -> binary_insert ( tvol , name_compare ) ; if ( tvol != nvol ) { tvol -> dev = NULL ; free_vol_item ( tvol ) ; Pmsg0 ( 000 , " \n " ) ; Jmsg ( jcr , M_WARNING , 0 , " \n " ) ; } } endeach_vol ( vol ) ; Dmsg0 ( dbglvl , " \n " ) ; return temp_vol_list ; }
Create a temporary copy of the volume list.
Create a temporary copy of the volume list .
/* don't zap dev entry */