src/dird/job.c
void create_unique_job_name(JCR *jcr, const char *base_name)
{
   /* Job start mutex */
   static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
   static time_t last_start_time = 0;
   static int seq = 0;
   time_t now = time(NULL);
   struct tm tm;
   char dt[MAX_TIME_LENGTH];
   char name[MAX_NAME_LENGTH];
   char *p;
   int len;
   int local_seq;

   /* Guarantee unique start time -- maximum one per second, and
    * thus unique Job Name
    */
   P(mutex);                          /* lock creation of jobs */
   seq++;
   if (seq > 59) {                    /* wrap as if it is seconds */
      seq = 0;
      while (now == last_start_time) {
         bmicrosleep(0, 500000);
         now = time(NULL);
      }
   }
   last_start_time = now;
   local_seq = seq;
   V(mutex);                          /* allow creation of jobs */
   jcr->start_time = now;
   /* Form Unique JobName */
   (void)localtime_r(&now, &tm);
   /* Use only characters that are permitted in Windows filenames */
   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm);
   len = strlen(dt) + 5;   /* dt + .%02d EOS */
   bstrncpy(name, base_name, sizeof(name));
   name[sizeof(name)-len] = 0;          /* truncate if too long */
   bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s_%02d", name, dt, local_seq); /* add date & time */
   /* Convert spaces into underscores */
   for (p=jcr->Job; *p; p++) {
      if (*p == ' ') {
         *p = '_';
      }
   }
   Dmsg2(100, "JobId=%u created Job=%s\n", jcr->JobId, jcr->Job);
}
/*
 * Takes base_name and appends (unique) current
 *   date and time to form unique job name.
 *
 *  Note, the seconds are actually a sequence number. This
 *   permits us to start a maximum fo 59 unique jobs a second, which
 *   should be sufficient.
 *
 *  Returns: unique job name in jcr->Job
 *    date/time in jcr->start_time
 */
Takes base_name and appends (unique) current
date and time to form unique job name.

Note, the seconds are actually a sequence number. This
permits us to start a maximum fo 59 unique jobs a second, which
should be sufficient.

unique job name in jcr->Job
date/time in jcr->start_time
Takes base_name and appends ( unique ) current date and time to form unique job name . Note the seconds are actually a sequence number . This permits us to start a maximum fo 59 unique jobs a second which should be sufficient . unique job name in jcr - > Job date / time in jcr - > start_time
void create_unique_job_name(JCR *jcr, const char *base_name)
{
   static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
   static time_t last_start_time = 0;
   static int seq = 0;
   time_t now = time(NULL);
   struct tm tm;
   char dt[MAX_TIME_LENGTH];
   char name[MAX_NAME_LENGTH];
   char *p;
   int len;
   int local_seq;
   P(mutex);                          
   seq++;
   if (seq > 59) {                    
      seq = 0;
      while (now == last_start_time) {
         bmicrosleep(0, 500000);
         now = time(NULL);
      }
   }
   last_start_time = now;
   local_seq = seq;
   V(mutex);                          
   jcr->start_time = now;
   (void)localtime_r(&now, &tm);
   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm);
   len = strlen(dt) + 5;   
   bstrncpy(name, base_name, sizeof(name));
   name[sizeof(name)-len] = 0;          
   bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s_%02d", name, dt, local_seq); 
   for (p=jcr->Job; *p; p++) {
      if (*p == ' ') {
         *p = '_';
      }
   }
   Dmsg2(100, "JobId=%u created Job=%s\n", jcr->JobId, jcr->Job);
}
void create_unique_job_name ( JCR * jcr , const char * base_name ) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER ; static time_t last_start_time = 0 ; static int seq = 0 ; time_t now = time ( NULL ) ; struct tm tm ; char dt [ MAX_TIME_LENGTH ] ; char name [ MAX_NAME_LENGTH ] ; char * p ; int len ; int local_seq ; P ( mutex ) ; seq ++ ; if ( seq > 59 ) { seq = 0 ; while ( now == last_start_time ) { bmicrosleep ( 0 , 500000 ) ; now = time ( NULL ) ; } } last_start_time = now ; local_seq = seq ; V ( mutex ) ; jcr -> start_time = now ; ( void ) localtime_r ( & now , & tm ) ; strftime ( dt , sizeof ( dt ) , " " , & tm ) ; len = strlen ( dt ) + 5 ; bstrncpy ( name , base_name , sizeof ( name ) ) ; name [ sizeof ( name ) - len ] = 0 ; bsnprintf ( jcr -> Job , sizeof ( jcr -> Job ) , " " , name , dt , local_seq ) ; for ( p = jcr -> Job ; * p ; p ++ ) { if ( * p == ' ' ) { * p = ' ' ; } } Dmsg2 ( 100 , " \n " , jcr -> JobId , jcr -> Job ) ; }
Takes base_name and appends (unique) current
   date and time to form unique job name.
Takes base_name and appends ( unique ) current date and time to form unique job name .
/* Job start mutex */ /* Guarantee unique start time -- maximum one per second, and
    * thus unique Job Name
    */ /* lock creation of jobs */ /* wrap as if it is seconds */ /* allow creation of jobs */ /* Form Unique JobName */ /* Use only characters that are permitted in Windows filenames */ /* dt + .%02d EOS */ /* truncate if too long */ /* add date & time */ /* Convert spaces into underscores */