Changeset 142 for trunk/src/sh_utmp.c


Ignore:
Timestamp:
Oct 30, 2007, 12:17:00 AM (17 years ago)
Author:
rainer
Message:

Login watch runs in thread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_utmp.c

    r140 r142  
    455455static struct log_user   * userlist   = NULL;
    456456static time_t  lastcheck;
     457static int     init_done = 0;
    457458
    458459/*************
     
    461462 *
    462463 *************/
    463 int sh_utmp_init (struct mod_type * arg)
    464 {
    465   static int done = 0;
    466   (void) arg;
     464
     465static int sh_utmp_init_internal ()
     466{
    467467
    468468  SL_ENTER(_("sh_utmp_init"));
     
    472472  /* do not re-initialize after a re-configuration
    473473   */
    474   if (done == 1) {
     474  if (init_done == 1) {
    475475    SL_RETURN( (0), _("sh_utmp_init"));
    476476  }
     
    480480  sh_utmp_check_internal (2); /* current logins */
    481481  sh_utmp_check_internal (0);
    482   done = 1;
     482  init_done = 1;
    483483  SL_RETURN( (0), _("sh_utmp_init"));
     484}
     485
     486int sh_utmp_init (struct mod_type * arg)
     487{
     488  if (ShUtmpActive == BAD)
     489    return SH_MOD_FAILED;
     490#ifdef HAVE_PTHREAD
     491  if (arg != NULL && arg->initval < 0)
     492    {
     493      if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg))
     494        return SH_MOD_THREAD;
     495      else
     496        return SH_MOD_FAILED;
     497    }
     498#endif
     499  return sh_utmp_init_internal();
    484500}
    485501
     
    509525  (void) sh_utmp_login_clean();
    510526#endif
     527  /* Reset the flag, such that the module
     528   * can be re-enabled.
     529   */
     530  ShUtmpActive       = S_TRUE;
     531  init_done          = 0;
    511532  SL_RETURN( (0), _("sh_utmp_end"));
    512533}
     
    536557{
    537558  SL_ENTER(_("sh_utmp_check"));
     559  if (ShUtmpActive == BAD)
     560    SL_RETURN( (-1), _("sh_utmp_check"));
    538561  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_UT_CHECK);
    539562  sh_utmp_check_internal (1);
Note: See TracChangeset for help on using the changeset viewer.