#At file:///C:/w/repo/mysql-5.1-telco-7.0-bug45402/ based on revid:jack@stripped
2939 jack andrews 2009-07-02
Bug #45402 Win32AsyncFile::rmrfReq can run an infinite loop
- integrated with Win32AsyncFile
- casual testing shows this is a fix for this bug
modified:
storage/ndb/include/util/DirIterator.hpp
storage/ndb/src/common/util/DirIterator.cpp
storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp
storage/ndb/src/mgmsrv/ConfigManager.cpp
=== modified file 'storage/ndb/include/util/DirIterator.hpp'
--- a/storage/ndb/include/util/DirIterator.hpp 2009-07-01 10:53:50 +0000
+++ b/storage/ndb/include/util/DirIterator.hpp 2009-07-02 18:39:07 +0000
@@ -27,7 +27,7 @@ class DirIterator {
public:
struct Entry {
- enum { UNKNOWN, ISFILE, ISDIR } type;
+ enum { UNKNOWN=1, ISFILE=2, ISDIR=4 } type;
const char* name;
Entry() :
type(UNKNOWN), name(0) {};
@@ -35,7 +35,8 @@ public:
DirIterator();
~DirIterator();
- // 0: success
+ // 0: success,
+ enum { OK = 0, NOTADIR = 1 };
int open(const char *path);
int close();
const char* path();
@@ -57,6 +58,6 @@ public:
Remove a directory and all it's subdirecrories
*/
-int remove_dir_recursive(const char* name);
+int ndb_remove_dir_recursive(const char* name);
#endif
=== modified file 'storage/ndb/src/common/util/DirIterator.cpp'
--- a/storage/ndb/src/common/util/DirIterator.cpp 2009-07-01 18:37:41 +0000
+++ b/storage/ndb/src/common/util/DirIterator.cpp 2009-07-02 18:39:07 +0000
@@ -255,7 +255,7 @@ static inline int rmdir(const char *s)
int ndb_remove_dir_recursive(const char* dir) {
struct stat statbuf;
if(stat(dir,&statbuf)==-1 && errno==ENOENT)
- return -1;
+ return DirIterator::NOTADIR;
Vector<BaseString> bss;
bss.push(dir,0);
for (;bss.size();) {
@@ -290,7 +290,9 @@ int ndb_remove_dir_recursive(const char*
}
#ifdef TAP_TEST
+#ifndef _WIN32
#include <unistd.h>
+#endif
#include <NdbTap.hpp>
inline int mkdirectory(const char *path) {
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2009-07-02 18:39:07 +0000
@@ -22,6 +22,7 @@
#include <kernel_types.h>
#include "AsyncIoThread.hpp"
#include "Filename.hpp"
+#include <DirIterator.hpp>
class AsyncFile
{
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp 2009-05-28 18:54:28 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/Win32AsyncFile.cpp 2009-07-02 18:39:07 +0000
@@ -380,52 +380,10 @@ Win32AsyncFile::rmrfReq(Request * reques
return;
}
- char path[PATH_MAX];
- strcpy(path, src);
- strcat(path, "\\*");
- WIN32_FIND_DATA ffd;
- HANDLE hFindFile;
-loop:
- hFindFile = FindFirstFile(path, &ffd);
- if (INVALID_HANDLE_VALUE == hFindFile)
- {
- DWORD dwError = GetLastError();
- if (dwError != ERROR_PATH_NOT_FOUND)
- request->error = dwError;
- return;
- }
- path[strlen(path) - 1] = 0; // remove '*'
-
- do {
- if (0 != strcmp(".", ffd.cFileName) && 0 != strcmp("..", ffd.cFileName))
- {
- int len = strlen(path);
- strcat(path, ffd.cFileName);
- if(DeleteFile(path))
- {
- path[len] = 0;
- continue;
- }//if
-
- FindClose(hFindFile);
- strcat(path, "\\*");
- goto loop;
- }
- } while(FindNextFile(hFindFile, &ffd));
-
- FindClose(hFindFile);
- path[strlen(path)-1] = 0; // remove '\'
- if (strcmp(src, path) != 0)
- {
- char * t = strrchr(path, '\\');
- t[1] = '*';
- t[2] = 0;
- goto loop;
- }
-
- if(removePath && !RemoveDirectory(src))
- request->error = GetLastError();
+ int err = ndb_remove_dir_recursive(src);
+ if (err != DirIterator::NOTADIR)
+ request->error = err;
}
void Win32AsyncFile::createDirectories()
=== modified file 'storage/ndb/src/mgmsrv/ConfigManager.cpp'
--- a/storage/ndb/src/mgmsrv/ConfigManager.cpp 2009-06-10 10:16:30 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigManager.cpp 2009-07-02 18:39:07 +0000
@@ -16,7 +16,7 @@
#include "ConfigManager.hpp"
#include "MgmtSrvr.hpp"
-#include "DirIterator.hpp"
+#include <DirIterator.hpp>
#include <NdbConfig.h>
#include <NdbSleep.h>
Attachment: [text/bzr-bundle] bzr/jack@sun.com-20090702183907-f1lgwp5cjfpxb5dt.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0 branch (jack:2939) Bug#45402 | jack andrews | 2 Jul |