A simple patch for strigi

Evgeny Egorochkin phreedom.stdin at gmail.com
Tue Nov 24 20:59:27 GMT 2009


В сообщении от Вторник 27 октября 2009 21:30:18 автор Jaime Torres написал:
> Hi,
> 
>   As I'm not able to use reviewboard today, I'll ask here:

I missed your email. Sorry my reply taking so long :(

> The first part is to avoid a DIR leak.

This patch is good and will be committed soon.

> The second part is to avoid to use the same variable name into two nested
> loops. gcc may work perfectly fine with it, but probably other compilers
> (will) not.

Looks like more compilers are ok with this than you think. We've got no 
complaints so far ;)

> --- strigi/src/luceneindexer/luceneindexer.cpp	(revision 1041313)
> +++ strigi/src/luceneindexer/luceneindexer.cpp	(copia de trabajo)
> @@ -46,6 +46,7 @@ checkIndexdirIsEmpty(const char* dir) {
>      while (de) {
>          if (strcmp(de->d_name, "..") && strcmp(de->d_name, ".")) {
>              fprintf(stderr, "Directory %s is not empty.\n", dir);
> +            closedir(d);
>              return false;
>          }
>          de = readdir(d);
> --- strigi/src/daemon/eventlistener/fslistener.cpp	(revision 1041313)
> +++ strigi/src/daemon/eventlistener/fslistener.cpp	(copia de trabajo)
> @@ -388,14 +388,14 @@ void FsListener::reindex()
> 
>      calculateDiff(m_indexedDirs, reindexDirs, dirsDeleted, dirsCreated);
> 
> -    for (set<string>::iterator iter = dirsCreated.begin();
> -         iter != dirsCreated.end() && !reindexReq(); ++iter)
> +    for (set<string>::iterator iter1 = dirsCreated.begin();
> +         iter1 != dirsCreated.end() && !reindexReq(); ++iter1)
>      {
>          DirLister lister(m_pAnalyzerConfiguration);
>          string path;
>          vector<pair<string, struct stat> > dirs;
> 
> -        lister.startListing (*iter);
> +        lister.startListing (*iter1);
>          int ret = lister.nextDir(path, dirs);
> 
>          while (ret != -1) {
> 
> // The rest of the affected loop:
>             vector<pair<string, struct stat> >::iterator iter;
>             for (iter = dirs.begin(); iter != dirs.end(); iter++) {
>                 struct stat stats = iter->second;
>                 if (S_ISDIR(stats.st_mode)) {//dir
>                     set<string> toWatch;
>                     recursivelyMonitor (iter->first, toWatch, events);
>                     // add new watches
>                     addWatches (toWatch);
>                     dirsMonitored.insert (iter->first);
>                 }
>                 else if (S_ISREG(stats.st_mode)) {
>                     //file
>                     events.push_back (new Event (Event::CREATED, iter-
> 
> >first));
> 
>                 }
>             }
>             ret = lister.nextDir(path, dirs);
> 

-- 
Evgeny




More information about the kde-core-devel mailing list