src/dird/jobq.c
static bool acquire_resources(JCR *jcr)
{
   bool skip_this_jcr = false;

   jcr->acquired_resource_locks = false;
/*
 * Turning this code off is likely to cause some deadlocks,
 *   but we do not really have enough information here to
 *   know if this is really a deadlock (it may be a dual drive
 *   autochanger), and in principle, the SD reservation system
 *   should detect these deadlocks, so push the work off on it.
 */
#ifdef xxx
   if (jcr->rstore && jcr->rstore == jcr->wstore) {    /* possible deadlock */
      Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
         "    Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
         jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
      jcr->setJobStatus(JS_Canceled);
      return false;
   }
#endif
   if (jcr->rstore) {
      Dmsg1(200, "Rstore=%s\n", jcr->rstore->name());
      if (!inc_read_store(jcr)) {
         Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->getNumConcurrentJobs());
         jcr->setJobStatus(JS_WaitStoreRes);
         return false;
      }
   }

   if (jcr->wstore) {
      Dmsg1(200, "Wstore=%s\n", jcr->wstore->name());
      int num = jcr->wstore->getNumConcurrentJobs();
      if (num < jcr->wstore->MaxConcurrentJobs) {
         Dmsg1(200, "Inc wncj=%d\n", num + 1);
         jcr->wstore->setNumConcurrentJobs(num + 1);
      } else if (jcr->rstore) {
         dec_read_store(jcr);
         skip_this_jcr = true;
      } else {
         Dmsg1(200, "Fail wncj=%d\n", num);
         skip_this_jcr = true;
      }
   }
   if (skip_this_jcr) {
      jcr->setJobStatus(JS_WaitStoreRes);
      return false;
   }

   if (jcr->client) {
      if (jcr->client->getNumConcurrentJobs() < jcr->client->MaxConcurrentJobs) {
         update_client_numconcurrentjobs(jcr, 1);
      } else {
         /* Back out previous locks */
         dec_write_store(jcr);
         dec_read_store(jcr);
         jcr->setJobStatus(JS_WaitClientRes);
         return false;
      }
   }
   if (jcr->job->getNumConcurrentJobs() < jcr->job->MaxConcurrentJobs) {
      int num;
      num = jcr->job->getNumConcurrentJobs() + 1;
      jcr->job->setNumConcurrentJobs(num);
   } else {
      /* Back out previous locks */
      dec_write_store(jcr);
      dec_read_store(jcr);
      update_client_numconcurrentjobs(jcr, -1);
      jcr->setJobStatus(JS_WaitJobRes);
      return false;
   }

   jcr->acquired_resource_locks = true;
   return true;
}
/*
 * See if we can acquire all the necessary resources for the job (JCR)
 *
 *  Returns: true  if successful
 *           false if resource failure
 */
See if we can acquire all the necessary resources for the job (JCR)
Returns: true  if successful
false if resource failure
See if we can acquire all the necessary resources for the job ( JCR ) Returns : true if successful false if resource failure
static bool acquire_resources(JCR *jcr)
{
   bool skip_this_jcr = false;
   jcr->acquired_resource_locks = false;
#ifdef xxx
   if (jcr->rstore && jcr->rstore == jcr->wstore) {    
      Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
         "    Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
         jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
      jcr->setJobStatus(JS_Canceled);
      return false;
   }
#endif
   if (jcr->rstore) {
      Dmsg1(200, "Rstore=%s\n", jcr->rstore->name());
      if (!inc_read_store(jcr)) {
         Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->getNumConcurrentJobs());
         jcr->setJobStatus(JS_WaitStoreRes);
         return false;
      }
   }
   if (jcr->wstore) {
      Dmsg1(200, "Wstore=%s\n", jcr->wstore->name());
      int num = jcr->wstore->getNumConcurrentJobs();
      if (num < jcr->wstore->MaxConcurrentJobs) {
         Dmsg1(200, "Inc wncj=%d\n", num + 1);
         jcr->wstore->setNumConcurrentJobs(num + 1);
      } else if (jcr->rstore) {
         dec_read_store(jcr);
         skip_this_jcr = true;
      } else {
         Dmsg1(200, "Fail wncj=%d\n", num);
         skip_this_jcr = true;
      }
   }
   if (skip_this_jcr) {
      jcr->setJobStatus(JS_WaitStoreRes);
      return false;
   }
   if (jcr->client) {
      if (jcr->client->getNumConcurrentJobs() < jcr->client->MaxConcurrentJobs) {
         update_client_numconcurrentjobs(jcr, 1);
      } else {
         dec_write_store(jcr);
         dec_read_store(jcr);
         jcr->setJobStatus(JS_WaitClientRes);
         return false;
      }
   }
   if (jcr->job->getNumConcurrentJobs() < jcr->job->MaxConcurrentJobs) {
      int num;
      num = jcr->job->getNumConcurrentJobs() + 1;
      jcr->job->setNumConcurrentJobs(num);
   } else {
      dec_write_store(jcr);
      dec_read_store(jcr);
      update_client_numconcurrentjobs(jcr, -1);
      jcr->setJobStatus(JS_WaitJobRes);
      return false;
   }
   jcr->acquired_resource_locks = true;
   return true;
}
static bool acquire_resources ( JCR * jcr ) { bool skip_this_jcr = false ; jcr -> acquired_resource_locks = false ; #ifdef xxx if ( jcr -> rstore && jcr -> rstore == jcr -> wstore ) { Jmsg ( jcr , M_FATAL , 0 , _ ( " \n " " \" \" \" \" \n " ) , jcr -> rstore -> name ( ) , jcr -> rstore_source , jcr -> wstore -> name ( ) , jcr -> wstore_source ) ; jcr -> setJobStatus ( JS_Canceled ) ; return false ; } #endif if ( jcr -> rstore ) { Dmsg1 ( 200 , " \n " , jcr -> rstore -> name ( ) ) ; if ( ! inc_read_store ( jcr ) ) { Dmsg1 ( 200 , " \n " , jcr -> rstore -> getNumConcurrentJobs ( ) ) ; jcr -> setJobStatus ( JS_WaitStoreRes ) ; return false ; } } if ( jcr -> wstore ) { Dmsg1 ( 200 , " \n " , jcr -> wstore -> name ( ) ) ; int num = jcr -> wstore -> getNumConcurrentJobs ( ) ; if ( num < jcr -> wstore -> MaxConcurrentJobs ) { Dmsg1 ( 200 , " \n " , num + 1 ) ; jcr -> wstore -> setNumConcurrentJobs ( num + 1 ) ; } else if ( jcr -> rstore ) { dec_read_store ( jcr ) ; skip_this_jcr = true ; } else { Dmsg1 ( 200 , " \n " , num ) ; skip_this_jcr = true ; } } if ( skip_this_jcr ) { jcr -> setJobStatus ( JS_WaitStoreRes ) ; return false ; } if ( jcr -> client ) { if ( jcr -> client -> getNumConcurrentJobs ( ) < jcr -> client -> MaxConcurrentJobs ) { update_client_numconcurrentjobs ( jcr , 1 ) ; } else { dec_write_store ( jcr ) ; dec_read_store ( jcr ) ; jcr -> setJobStatus ( JS_WaitClientRes ) ; return false ; } } if ( jcr -> job -> getNumConcurrentJobs ( ) < jcr -> job -> MaxConcurrentJobs ) { int num ; num = jcr -> job -> getNumConcurrentJobs ( ) + 1 ; jcr -> job -> setNumConcurrentJobs ( num ) ; } else { dec_write_store ( jcr ) ; dec_read_store ( jcr ) ; update_client_numconcurrentjobs ( jcr , -1 ) ; jcr -> setJobStatus ( JS_WaitJobRes ) ; return false ; } jcr -> acquired_resource_locks = true ; return true ; }
See if we can acquire all the necessary resources for the job (JCR)
  Returns: true  if successful
           false if resource failure
See if we can acquire all the necessary resources for the job ( JCR ) Returns : true if successful false if resource failure
/*
 * Turning this code off is likely to cause some deadlocks,
 *   but we do not really have enough information here to
 *   know if this is really a deadlock (it may be a dual drive
 *   autochanger), and in principle, the SD reservation system
 *   should detect these deadlocks, so push the work off on it.
 */ /* possible deadlock */ /* Back out previous locks */ /* Back out previous locks */