Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Roxie filecache - prevent crash if cache destroyed before files.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
  • Loading branch information...
commit 63be6a83ae6c8d404bb4512b8abeefd7ef1d9c68 1 parent 19280b7
Richard Chapman authored
Showing with 24 additions and 1 deletion.
  1. +19 −1 roxie/ccd/ccdfile.cpp
  2. +5 −0 roxie/ccd/ccdfile.hpp
20 roxie/ccd/ccdfile.cpp
View
@@ -141,6 +141,12 @@ class CLazyFileIO : public CInterface, implements ILazyFileIO, implements IDelay
cached = cache;
}
+ void removeCache(const IRoxieFileCache *cache)
+ {
+ assertex(cached==cache);
+ cached = NULL;
+ }
+
inline void setRemote(bool _remote) { remote = _remote; }
virtual void setCopying(bool _copying)
@@ -657,7 +663,7 @@ class CRoxieFileCache : public CInterface, implements ICopyFileProgress, impleme
else
throw MakeStringException(ROXIE_FILE_OPEN_FAIL, "Could not open file %s", localLocation);
ret->setCache(this);
- files.setValue(localLocation, (ILazyFileIO *) ret);
+ files.setValue(localLocation, (ILazyFileIO *)ret);
return ret.getClear();
}
@@ -940,6 +946,18 @@ class CRoxieFileCache : public CInterface, implements ICopyFileProgress, impleme
started = false;
}
+ ~CRoxieFileCache()
+ {
+ // NOTE - I assume that by the time I am being destroyed, system is single threaded.
+ // Removing any possible race between destroying of the cache and destroying of the files in it would be complex otherwise
+ HashIterator h(files);
+ ForEach(h)
+ {
+ ILazyFileIO *f = files.mapToValue(&h.query());
+ f->removeCache(this);
+ }
+ }
+
virtual void start()
{
if (!started)
5 roxie/ccd/ccdfile.hpp
View
@@ -26,6 +26,8 @@
enum RoxieFileStatus { FileSizeMismatch, FileDateMismatch, FileCRCMismatch, FileIsValid, FileNotFound };
enum RoxieFileType { ROXIE_WU_DLL, ROXIE_PLUGIN_DLL, ROXIE_KEY, ROXIE_FILE, ROXIE_PATCH, ROXIE_BASEINDEX };
interface IFileIOArray;
+interface IRoxieFileCache;
+
interface ILazyFileIO : extends IFileIO
{
virtual const char *queryFilename() = 0;
@@ -58,6 +60,9 @@ interface ILazyFileIO : extends IFileIO
virtual void setCopying(bool copying) = 0;
virtual bool isCopying() const = 0;
virtual IMemoryMappedFile *queryMappedFile() = 0;
+
+ virtual void setCache(const IRoxieFileCache *) = 0;
+ virtual void removeCache(const IRoxieFileCache *) = 0;
};
extern ILazyFileIO *createDynamicFile(const char *id, IPartDescriptor *pdesc, RoxieFileType fileType, int numParts);
Please sign in to comment.
Something went wrong with that request. Please try again.