Author: kpvdr
Date: 2008-07-24 16:32:10 -0400 (Thu, 24 Jul 2008)
New Revision: 2216
Modified:
store/branches/mrg-1.0/cpp/lib/BdbMessageStore.cpp
store/branches/mrg-1.0/cpp/lib/jrnl/jdir.cpp
Log:
Backport from trunk checkin r2215, but excluding new tests: Possible fix for BZ456272:
"Broker fails to create journal directory - File already exists". Removed check
for existence of dir at time of creation in class jdir, and handled EEXIST error instead.
Modified: store/branches/mrg-1.0/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/BdbMessageStore.cpp 2008-07-24 20:07:07 UTC (rev 2215)
+++ store/branches/mrg-1.0/cpp/lib/BdbMessageStore.cpp 2008-07-24 20:32:10 UTC (rev 2216)
@@ -1454,14 +1454,12 @@
string BdbMessageStore::getJrnlDir(const char* queueName) //for exmaple /var/rhm/ +
queueDir/
{
std::stringstream dir;
- dir << getJrnlBaseDir();
- dir << std::setw(4);
- dir << std::setfill('0');
+ dir << getJrnlBaseDir() << std::hex << std::setfill('0')
<< std::setw(4);
u_int32_t count = 0;
for (u_int32_t i = 0; i < strlen(queueName); i++) {
count += queueName[i];
}
- dir << (count % 20);
+ dir << (count % 29); // Use a prime number for better distribution across dirs
dir << "/" << queueName << "/";
return dir.str();
}
Modified: store/branches/mrg-1.0/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/jrnl/jdir.cpp 2008-07-24 20:07:07 UTC (rev 2215)
+++ store/branches/mrg-1.0/cpp/lib/jrnl/jdir.cpp 2008-07-24 20:32:10 UTC (rev 2216)
@@ -81,9 +81,9 @@
if (!exists(parent_dir))
create_dir(parent_dir);
}
- if (!exists(dirname))
+ if (::mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
{
- if (::mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
+ if (errno != EEXIST) // Dir exists, ignore
{
std::ostringstream oss;
oss << "dir=\"" << dirname <<
"\"" << FORMAT_SYSERR(errno);
Show replies by date