src/dird/jobq.c
static int start_server(jobq_t *jq)
{
   int stat = 0;
   pthread_t id;

   /*
    * if any threads are idle, wake one.
    *   Actually we do a broadcast because on /lib/tls
    *   these signals seem to get lost from time to time.
    */
   if (jq->idle_workers > 0) {
      Dmsg0(2300, "Signal worker to wake up\n");
      if ((stat = pthread_cond_broadcast(&jq->work)) != 0) {
         berrno be;
         Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_signal: ERR=%s\n"), be.bstrerror(stat));
         return stat;
      }
   } else if (jq->num_workers < jq->max_workers) {
      Dmsg0(2300, "Create worker thread\n");
      /* No idle threads so create a new one */
      set_thread_concurrency(jq->max_workers + 1);
      jq->num_workers++;
      if ((stat = pthread_create(&id, &jq->attr, jobq_server, (void *)jq)) != 0) {
         berrno be;
         jq->num_workers--;
         Jmsg1(NULL, M_ERROR, 0, _("pthread_create: ERR=%s\n"), be.bstrerror(stat));
         return stat;
      }
   }
   return stat;
}
/*
 * Start the server thread if it isn't already running
 */
Start the server thread if it isn't already running
Start the server thread if it isn ' t already running
static int start_server(jobq_t *jq)
{
   int stat = 0;
   pthread_t id;
   if (jq->idle_workers > 0) {
      Dmsg0(2300, "Signal worker to wake up\n");
      if ((stat = pthread_cond_broadcast(&jq->work)) != 0) {
         berrno be;
         Jmsg1(NULL, M_ERROR, 0, _("pthread_cond_signal: ERR=%s\n"), be.bstrerror(stat));
         return stat;
      }
   } else if (jq->num_workers < jq->max_workers) {
      Dmsg0(2300, "Create worker thread\n");
      set_thread_concurrency(jq->max_workers + 1);
      jq->num_workers++;
      if ((stat = pthread_create(&id, &jq->attr, jobq_server, (void *)jq)) != 0) {
         berrno be;
         jq->num_workers--;
         Jmsg1(NULL, M_ERROR, 0, _("pthread_create: ERR=%s\n"), be.bstrerror(stat));
         return stat;
      }
   }
   return stat;
}
static int start_server ( jobq_t * jq ) { int stat = 0 ; pthread_t id ; if ( jq -> idle_workers > 0 ) { Dmsg0 ( 2300 , " \n " ) ; if ( ( stat = pthread_cond_broadcast ( & jq -> work ) ) != 0 ) { berrno be ; Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , be . bstrerror ( stat ) ) ; return stat ; } } else if ( jq -> num_workers < jq -> max_workers ) { Dmsg0 ( 2300 , " \n " ) ; set_thread_concurrency ( jq -> max_workers + 1 ) ; jq -> num_workers ++ ; if ( ( stat = pthread_create ( & id , & jq -> attr , jobq_server , ( void * ) jq ) ) != 0 ) { berrno be ; jq -> num_workers -- ; Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , be . bstrerror ( stat ) ) ; return stat ; } } return stat ; }
Start the server thread if it isn't already running
Start the server thread if it isn ' t already running
/*
    * if any threads are idle, wake one.
    *   Actually we do a broadcast because on /lib/tls
    *   these signals seem to get lost from time to time.
    */ /* No idle threads so create a new one */