#At file:///C:/w/repo/mysql-5.1-telco-7.0-bug45402/ based on revid:jack@stripped
2941 jack andrews 2009-07-03
Bug #45402 Win32AsyncFile::rmrfReq can run an infinite loop
- added more functions to handle rmrf logic in AsyncFile.
- removed rmrf from Posix and Win32 AsyncFile
- integrated with AsyncFile.hpp
modified:
storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp
storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.hpp
storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp
storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.hpp
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2009-07-02 18:39:07 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2009-07-03 14:29:27 +0000
@@ -23,6 +23,8 @@
#include "AsyncIoThread.hpp"
#include "Filename.hpp"
#include <DirIterator.hpp>
+#include <sys/types.h>
+#include <sys/stat.h>
class AsyncFile
{
@@ -70,7 +72,7 @@ private:
virtual void syncReq(Request *request)=0;
virtual void removeReq(Request *request)=0;
virtual void appendReq(Request *request)=0;
- virtual void rmrfReq(Request *request, const char * path, bool removePath)=0;
+ virtual void rmrfReq(Request *request, const char * path, bool removePath);
virtual void createDirectories()=0;
/**
@@ -111,6 +113,31 @@ public:
SimulatedBlock& m_fs;
};
+inline
+void
+AsyncFile::rmrfReq(Request *request, const char * path, bool removePath)
+{
+ if (!request->par.rmrf.directory)
+ {
+ // Remove file
+ struct stat statbuf;
+ if (stat(path,&statbuf)==-1 && errno==ENOENT)
+ return;
+ if(ndb_remove_entry(path))
+ request->error = errno;
+ return;
+ }
+ if (removePath)
+ {
+ if(ndb_remove_dir_recursive(path))
+ request->error = errno;
+ }
+ else
+ if (ndb_remove_dir_contents(path))
+ request->error = errno;
+ return;
+}
+
inline
void
AsyncFile::set_buffer(Ptr<GlobalPage> ptr, Uint32 cnt)
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp 2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp 2009-07-03 14:29:27 +0000
@@ -764,64 +764,6 @@ void PosixAsyncFile::removeReq(Request *
}
}
-void
-PosixAsyncFile::rmrfReq(Request *request, const char * src, bool removePath)
-{
- if(!request->par.rmrf.directory)
- {
- // Remove file
- if(unlink(src) != 0 && errno != ENOENT)
- request->error = errno;
- return;
- }
-
- char path[PATH_MAX];
- strcpy(path, src);
- strcat(path, "/");
-
- DIR* dirp;
- struct dirent * dp;
-loop:
- dirp = opendir(path);
- if(dirp == 0)
- {
- if(errno != ENOENT)
- request->error = errno;
- return;
- }
-
- while ((dp = readdir(dirp)) != NULL)
- {
- if ((strcmp(".", dp->d_name) != 0) && (strcmp("..", dp->d_name) != 0))
- {
- int len = strlen(path);
- strcat(path, dp->d_name);
- if (remove(path) == 0)
- {
- path[len] = 0;
- continue;
- }
-
- closedir(dirp);
- strcat(path, "/");
- goto loop;
- }
- }
- closedir(dirp);
- path[strlen(path)-1] = 0; // remove /
- if (strcmp(src, path) != 0)
- {
- char * t = strrchr(path, '/');
- t[1] = 0;
- goto loop;
- }
-
- if(removePath && rmdir(src) != 0)
- {
- request->error = errno;
- }
-}
-
PosixAsyncFile::~PosixAsyncFile()
{
if (azfBufferUnaligned)
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.hpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.hpp 2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.hpp 2009-07-03 14:29:27 +0000
@@ -55,7 +55,6 @@ public:
virtual void syncReq(Request *request);
virtual void removeReq(Request *request);
virtual void appendReq(Request *request);
- virtual void rmrfReq(Request *request, const char * path, bool removePath);
virtual int readBuffer(Request*, char * buf, size_t size, off_t offset);
virtual int writeBuffer(const char * buf, size_t size, off_t offset);
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp 2009-07-02 18:39:07 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp 2009-07-03 14:29:27 +0000
@@ -366,26 +366,6 @@ Win32AsyncFile::removeReq(Request * requ
}
}
-void
-Win32AsyncFile::rmrfReq(Request * request, const char * src, bool removePath){
- if (!request->par.rmrf.directory)
- {
- // Remove file
- if (!DeleteFile(src))
- {
- DWORD dwError = GetLastError();
- if (dwError != ERROR_FILE_NOT_FOUND)
- request->error = dwError;
- }
- return;
- }
-
-
- int err = ndb_remove_dir_recursive(src);
- if (err != DirIterator::NOTADIR)
- request->error = err;
-}
-
void Win32AsyncFile::createDirectories()
{
char* tmp;
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.hpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.hpp 2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.hpp 2009-07-03 14:29:27 +0000
@@ -42,7 +42,6 @@ public:
virtual void syncReq(Request *request);
virtual void removeReq(Request *request);
virtual void appendReq(Request *request);
- virtual void rmrfReq(Request *request, const char * path, bool removePath);
virtual int readBuffer(Request*, char * buf, size_t size, off_t offset);
virtual int writeBuffer(const char * buf, size_t size, off_t offset);
Attachment: [text/bzr-bundle] bzr/jack@sun.com-20090703142927-zlgrxlx28ke4gdx7.bundle
Thread |
---|
• bzr commit into mysql-5.1-telco-7.0 branch (jack:2941) Bug#45402 | jack andrews | 3 Jul |