Changeset 433 for trunk


Ignore:
Timestamp:
Apr 29, 2013, 7:32:19 PM (12 years ago)
Author:
katerina
Message:

Fix for ticket #338 (steady growth of memory usage).

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Changelog

    r432 r433  
    113.0.12:
     2        * Fix for incorrect use of sh_inotify_add_watch_later
     3          which causes a steady increase in memory usage
     4          (issue reported by Maxime V)
     5        * Fix for potential minor memory leak
    26        * Fix for bug in negated conditionals for config file
    37          (reported by M. Ward)
  • trunk/include/samhain.h

    r415 r433  
    208208#define SH_INOTIFY_NEEDINIT (1<<2)
    209209#define SH_INOTIFY_INSCAN   (1<<3)
     210#define SH_INOTIFY_IFUSED(a)   if ((sh.flag.inotify & SH_INOTIFY_USE) != 0) { a }
    210211
    211212
  • trunk/src/samhain.c

    r424 r433  
    20232023          (flag_check_1 == 1 || flag_check_2 == 1))
    20242024        {
    2025           sh.flag.inotify |= SH_INOTIFY_INSCAN;
     2025          SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_INSCAN; );
    20262026          /* Refresh list files matching glob patterns.
    20272027           */
     
    20882088          flag_check_2 = 0;
    20892089          check_done   = 1;
    2090           sh.flag.inotify &= ~SH_INOTIFY_INSCAN;
    2091           sh.flag.inotify &= ~SH_INOTIFY_DOSCAN;
     2090          SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_INSCAN; );
     2091          SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_DOSCAN; );
    20922092
    20932093          (void) sh_prelink_run (NULL, NULL, 0);
  • trunk/src/sh_fInotify.c

    r426 r433  
    130130    {
    131131      /* Init from main thread */
    132       sh.flag.inotify |= SH_INOTIFY_DOSCAN;
    133       sh.flag.inotify |= SH_INOTIFY_NEEDINIT;
     132      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_DOSCAN;   );
     133      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_NEEDINIT; );
    134134
    135135      if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg))
     
    154154      /* Reconfigure from main thread */
    155155      /* sh_fInotify_init_internal(); */
    156       sh.flag.inotify |= SH_INOTIFY_DOSCAN;
    157       sh.flag.inotify |= SH_INOTIFY_NEEDINIT;
     156      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_DOSCAN;   );
     157      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_NEEDINIT; );
    158158      return SH_MOD_THREAD;
    159159    }
     
    226226    {
    227227      count = 0; /* Re-expand glob patterns to discover added files. */
    228       sh.flag.inotify |= SH_INOTIFY_INSCAN;
     228      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_INSCAN; );
    229229      sh_files_check_globFilePatterns();
    230       sh.flag.inotify &= ~SH_INOTIFY_INSCAN;
    231       sh.flag.inotify |= SH_INOTIFY_NEEDINIT;
     230      SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_INSCAN;  );
     231      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_NEEDINIT; );
    232232    }
    233233
     
    396396   * DOSCAN is finished, hence wouldn't call init().
    397397   */
    398   sh.flag.inotify &= ~SH_INOTIFY_NEEDINIT;
     398  SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_NEEDINIT; );
    399399
    400400  return 0;
     
    474474  else if ((event->mask & IN_Q_OVERFLOW) != 0)
    475475    {
    476       sh.flag.inotify |= SH_INOTIFY_DOSCAN;
    477       sh.flag.inotify |= SH_INOTIFY_NEEDINIT;
     476      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_DOSCAN;   );
     477      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_NEEDINIT; );
     478
    478479      SH_MUTEX_LOCK(mutex_thread_nolog);
    479480      sh_error_handle(SH_ERR_WARN, FIL__, __LINE__, event->wd, MSG_E_SUBGEN,
     
    639640          if (event->mask & IN_ISDIR)
    640641            {
    641               sh.flag.inotify |= SH_INOTIFY_INSCAN;
     642              SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_INSCAN;   );
    642643              sh_files_checkdir (classD, check_maskD, rdepthD,
    643644                                 path, (event->len > 0) ? event->name : NULL);
    644               sh.flag.inotify &= ~SH_INOTIFY_INSCAN;
    645               sh.flag.inotify |= SH_INOTIFY_NEEDINIT;
     645              SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_INSCAN;  );
     646              SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_NEEDINIT; );
    646647              sh_dirs_reset  ();
    647648              sh_files_reset ();
  • trunk/src/sh_files.c

    r425 r433  
    20102010      if (theFile->link_path)   SH_FREE(theFile->link_path);
    20112011      SH_FREE(theFile);
     2012      SH_FREE(tmpname);
    20122013      SL_RETURN((0), _("sh_files_checkdir"));
    20132014    }
     
    20152016  if (status == -1)
    20162017    {
    2017       SH_FREE(tmpname);
    20182018      if (theFile->attr_string) SH_FREE(theFile->attr_string);
    20192019      if (theFile->link_path)   SH_FREE(theFile->link_path);
    20202020      SH_FREE(theFile);
     2021      SH_FREE(tmpname);
    20212022      SL_RETURN((-1), _("sh_files_checkdir"));
    20222023    }
     
    20282029                       tmpname);
    20292030      ++sh.statistics.files_nodir;
    2030       SH_FREE(tmpname);
    20312031      if (theFile->attr_string) SH_FREE(theFile->attr_string);
    20322032      if (theFile->link_path)   SH_FREE(theFile->link_path);
    20332033      SH_FREE(theFile);
     2034      SH_FREE(tmpname);
    20342035      SL_RETURN((-1), _("sh_files_checkdir"));
    20352036    }
     
    21272128      {
    21282129        SH_FREE(theDir);
     2130        SH_FREE(tmpname);
    21292131        SL_RETURN((0), _("sh_files_checkdir"));
    21302132      }
     
    23662368        SH_FREE(theDir);
    23672369        sh_dummy_dirlist = NULL;
     2370        SH_FREE(tmpname);
    23682371        SL_RETURN((0), _("sh_files_checkdir"));
    23692372      }
Note: See TracChangeset for help on using the changeset viewer.