Ignore:
Timestamp:
Oct 22, 2007, 11:19:15 PM (17 years ago)
Author:
rainer
Message:

Use thread-safe libc functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_schedule.c

    r34 r131  
    130130  struct tm * tval;
    131131  int count, i, nval;
     132#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
     133  struct tm     time_tm;
     134#endif
    132135
    133136  if (!isched)
     
    135138
    136139  now  = time(NULL);
     140#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
     141  tval = localtime_r(&now, &time_tm);
     142#else
    137143  tval = localtime(&now);
    138 
     144#endif
    139145  count = 0;
    140146  for (i = 0; i < 5; ++i)
     
    320326  int    i = 0;
    321327  size_t len;
     328#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     329  char * saveptr;
     330#endif
    322331
    323332  if (!ssched || !isched)
     
    332341  sl_strlcpy(copy, ssched, len);
    333342
     343#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     344  p = strtok_r(copy, " \t", &saveptr); /* parse crontab-style schedule */
     345#else
    334346  p = strtok(copy, " \t"); /* parse crontab-style schedule */
     347#endif
     348
    335349  if (!p)
    336350    goto err;
     
    340354  for (i = 1; i < 5; ++i)
    341355    {
     356#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     357      p = strtok_r(NULL, " \t", &saveptr); /* parse crontab-style schedule */
     358#else
    342359      p = strtok(NULL, " \t"); /* parse crontab-style schedule */
     360#endif
    343361      if (!p)
    344362        goto err;
     
    420438    {
    421439      if (test_sched(&isched))
    422         printf("EXECUTE  at: %s", ctime(&(isched.last_exec)));
     440        printf("EXECUTE  at: %s", ctime(&(isched.last_exec))); /* TESTONLY */
    423441      sleep (1); /* TESTONLY */
    424442    }
Note: See TracChangeset for help on using the changeset viewer.