当前位置: 首页>>代码示例>>C++>>正文


C++ DEVICE::detach_dcr_from_dev方法代码示例

本文整理汇总了C++中DEVICE::detach_dcr_from_dev方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::detach_dcr_from_dev方法的具体用法?C++ DEVICE::detach_dcr_from_dev怎么用?C++ DEVICE::detach_dcr_from_dev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DEVICE的用法示例。


在下文中一共展示了DEVICE::detach_dcr_from_dev方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memset

/*
 * Create a new Device Control Record and attach
 *   it to the device (if this is a real job).
 * Note, this has been updated so that it can be called first
 *   without a DEVICE, then a second or third time with a DEVICE,
 *   and each time, it should cleanup and point to the new device.
 *   This should facilitate switching devices.
 * Note, each dcr must point to the controlling job (jcr).  However,
 *   a job can have multiple dcrs, so we must not store in the jcr's
 *   structure as previously. The higher level routine must store
 *   this dcr in the right place
 *
 */
DCR *new_dcr(JCR *jcr, DCR *dcr, DEVICE *dev, bool writing)
{
   DEVICE *odev;
   if (!dcr) {
      dcr = (DCR *)malloc(sizeof(DCR));
      memset(dcr, 0, sizeof(DCR));
      dcr->tid = pthread_self();
      dcr->spool_fd = -1;
   }
   dcr->jcr = jcr;                 /* point back to jcr */
   odev = dcr->dev;
   if (dcr->attached_to_dev && odev) {
      Dmsg2(100, "Detach 0x%x from olddev %s\n", dcr, odev->print_name());
      odev->detach_dcr_from_dev(dcr);
   }
   ASSERT2(!dcr->attached_to_dev, "DCR is attached. Wrong!");
   /* Set device information, possibly change device */
   if (dev) {
      dcr->free_blocks();
      dcr->block = new_block(dev);
      dcr->ameta_block = dcr->block;
      if (dcr->rec) {
         free_record(dcr->rec);
      }
      dcr->rec = new_record();
      /* Use job spoolsize prior to device spoolsize */
      if (jcr && jcr->spool_size) {
         dcr->max_job_spool_size = jcr->spool_size;
      } else {
         dcr->max_job_spool_size = dev->device->max_job_spool_size;
      }
      dcr->device = dev->device;
      dcr->set_dev(dev);
      Dmsg2(100, "Attach 0x%x to dev %s\n", dcr, dev->print_name());
      dev->attach_dcr_to_dev(dcr);
   }
   if (writing) {
      dcr->set_writing();
   } else {
      dcr->clear_writing();
   }
   return dcr;
}
开发者ID:prelegalwonder,项目名称:bacula,代码行数:56,代码来源:acquire.c

示例2: release_device


//.........这里部分代码省略.........
      Dmsg1(100, "There are %d writers in release_device\n", dev->num_writers);
      if (dev->is_labeled()) {
         Dmsg2(200, "dir_create_jobmedia. Release vol=%s dev=%s\n",
               dev->getVolCatName(), dev->print_name());
         if (!dev->at_weot() && !dir_create_jobmedia_record(dcr)) {
            Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
               dcr->getVolCatName(), jcr->Job);
         }
         /* If no more writers, and no errors, and wrote something, write an EOF */
         if (!dev->num_writers && dev->can_write() && dev->block_num > 0) {
            dev->weof(1);
            write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolumeName);
         }
         if (!dev->at_weot()) {
            dev->VolCatInfo.VolCatFiles = dev->get_file();   /* set number of files */
            /* Note! do volume update before close, which zaps VolCatInfo */
            dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
            Dmsg2(200, "dir_update_vol_info. Release vol=%s dev=%s\n",
                  dev->getVolCatName(), dev->print_name());
         }
         if (dev->num_writers == 0) {         /* if not being used */
            volume_unused(dcr);               /*  we obviously are not using the volume */
            generate_plugin_event(jcr, bsdEventDeviceClose, dcr);
         }
      }

   } else {
      /*
       * If we reach here, it is most likely because the job
       *   has failed, since the device is not in read mode and
       *   there are no writers. It was probably reserved.
       */
      volume_unused(dcr);
      generate_plugin_event(jcr, bsdEventDeviceClose, dcr);
   }
   Dmsg3(100, "%d writers, %d reserve, dev=%s\n", dev->num_writers, dev->num_reserved(),
         dev->print_name());

   /* If no writers, close if file or !CAP_ALWAYS_OPEN */
   if (dev->num_writers == 0 && (!dev->is_tape() || !dev->has_cap(CAP_ALWAYSOPEN))) {
      generate_plugin_event(jcr, bsdEventDeviceClose, dcr);
      if (!dev->close()) {
         Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
      }
      free_volume(dev);
   }
   unlock_volumes();

   /* Fire off Alert command and include any output */
   if (!job_canceled(jcr) && dcr->device->alert_command) {
      POOLMEM *alert;
      int status = 1;
      BPIPE *bpipe;
      char line[MAXSTRING];
      alert = get_pool_memory(PM_FNAME);
      alert = edit_device_codes(dcr, alert, dcr->device->alert_command, "");
      /* Wait maximum 5 minutes */
      bpipe = open_bpipe(alert, 60 * 5, "r");
      if (bpipe) {
         while (fgets(line, sizeof(line), bpipe->rfd)) {
            Jmsg(jcr, M_ALERT, 0, _("Alert: %s"), line);
         }
         status = close_bpipe(bpipe);
      } else {
         status = errno;
      }
      if (status != 0) {
         berrno be;
         Jmsg(jcr, M_ALERT, 0, _("3997 Bad alert command: %s: ERR=%s.\n"),
              alert, be.bstrerror(status));
      }

      Dmsg1(400, "alert status=%d\n", status);
      free_pool_memory(alert);
   }
   pthread_cond_broadcast(&dev->wait_next_vol);
   Dmsg2(100, "JobId=%u broadcast wait_device_release at %s\n",
         (uint32_t)jcr->JobId, bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));
   pthread_cond_broadcast(&wait_device_release);

   /*
    * If we are the thread that blocked the device, then unblock it
    */
   if (pthread_equal(dev->no_wait_id, pthread_self())) {
      dev->dunblock(true);
   } else {
      /* Otherwise, reset the prior block status and unlock */
      dev->set_blocked(was_blocked);
      dev->Unlock();
   }

   if (dcr->keep_dcr) {
      dev->detach_dcr_from_dev(dcr);
   } else {
      free_dcr(dcr);
   }
   Dmsg2(100, "Device %s released by JobId=%u\n", dev->print_name(),
         (uint32_t)jcr->JobId);
   return ok;
}
开发者ID:prelegalwonder,项目名称:bacula,代码行数:101,代码来源:acquire.c


注:本文中的DEVICE::detach_dcr_from_dev方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。