mksh/mksh.logging/src.1mai/atrshmlog_internal.c
void atrshmlog_cleanup_mutexes()
{
  if (! ATRSHMLOGLOGGING )
    return;

  /* next. we check for initialized */
  atr_shm_log_area_t *a = ATRSHMLOGGETAREA;

  if (a->shmid != atrshmlog_shmid())
    return;

  if (a->safeguard != SAFEGUARDVALUE)
    return;

  if (a->version != ATRSHMLOGVERSION)
    return;
  
  atr_shm_log_buffer_t* b = &(a->logbuffers[0]);

  /* from now on the buffer is useless. so we switch to not logging */
  a->ich_habe_fertig = 1;

  sleep(5); /* we give 5 seconds time for the reader to finish */
  
  for (int i = 0; i < ATRSHMLOGCUTOFFLOWBYTE(a->count); i++)
    {
      b->state = atr_shm_log_illegal; /* no leagal state, no op any more */

      b++;
    }

  b = &(a->logbuffers[0]);
  
  for (int i = 0; i < a->count; i++)
    {
      pthread_mutex_t * m = &(b->lock_mutex);

      pthread_mutex_destroy(m);

      b->safeguard = 0L;
      
      b++;
    }

  a->shmid = 0;
  a->safeguard = 0L;
}
/* we have to clean up the mutexes after stopping 
 * pthread version
 * this is an optional step in shuting down the log.
 * it is itself not mt safe.
 * so use a simple program for that
 * see the atrshmlogfinish.c
 */
we have to clean up the mutexes after stopping
pthread version
this is an optional step in shuting down the log.
it is itself not mt safe.
so use a simple program for that
see the atrshmlogfinish.c
we have to clean up the mutexes after stopping pthread version this is an optional step in shuting down the log . it is itself not mt safe . so use a simple program for that see the atrshmlogfinish . c
void atrshmlog_cleanup_mutexes()
{
  if (! ATRSHMLOGLOGGING )
    return;
  atr_shm_log_area_t *a = ATRSHMLOGGETAREA;
  if (a->shmid != atrshmlog_shmid())
    return;
  if (a->safeguard != SAFEGUARDVALUE)
    return;
  if (a->version != ATRSHMLOGVERSION)
    return;
  atr_shm_log_buffer_t* b = &(a->logbuffers[0]);
  a->ich_habe_fertig = 1;
  sleep(5); 
  for (int i = 0; i < ATRSHMLOGCUTOFFLOWBYTE(a->count); i++)
    {
      b->state = atr_shm_log_illegal; 
      b++;
    }
  b = &(a->logbuffers[0]);
  for (int i = 0; i < a->count; i++)
    {
      pthread_mutex_t * m = &(b->lock_mutex);
      pthread_mutex_destroy(m);
      b->safeguard = 0L;
      b++;
    }
  a->shmid = 0;
  a->safeguard = 0L;
}
void atrshmlog_cleanup_mutexes ( ) { if ( ! ATRSHMLOGLOGGING ) return ; atr_shm_log_area_t * a = ATRSHMLOGGETAREA ; if ( a -> shmid != atrshmlog_shmid ( ) ) return ; if ( a -> safeguard != SAFEGUARDVALUE ) return ; if ( a -> version != ATRSHMLOGVERSION ) return ; atr_shm_log_buffer_t * b = & ( a -> logbuffers [ 0 ] ) ; a -> ich_habe_fertig = 1 ; sleep ( 5 ) ; for ( int i = 0 ; i < ATRSHMLOGCUTOFFLOWBYTE ( a -> count ) ; i ++ ) { b -> state = atr_shm_log_illegal ; b ++ ; } b = & ( a -> logbuffers [ 0 ] ) ; for ( int i = 0 ; i < a -> count ; i ++ ) { pthread_mutex_t * m = & ( b -> lock_mutex ) ; pthread_mutex_destroy ( m ) ; b -> safeguard = 0L ; b ++ ; } a -> shmid = 0 ; a -> safeguard = 0L ; }
we have to clean up the mutexes after stopping
 pthread version
 this is an optional step in shuting down the log.
we have to clean up the mutexes after stopping pthread version this is an optional step in shuting down the log .
/* next. we check for initialized */ /* from now on the buffer is useless. so we switch to not logging */ /* we give 5 seconds time for the reader to finish */ /* no leagal state, no op any more */