Author: kpvdr
Date: 2009-01-30 12:02:05 -0500 (Fri, 30 Jan 2009)
New Revision: 3086
Modified:
store/trunk/cpp/lib/MessageStoreImpl.cpp
Log:
Corrected two bad asserts in class MessageStoreImpl which never trigger; these could
potentially cause hanging instead of halting the broker.
Modified: store/trunk/cpp/lib/MessageStoreImpl.cpp
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-01-30 16:28:22 UTC (rev 3085)
+++ store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-01-30 17:02:05 UTC (rev 3086)
@@ -243,7 +243,7 @@
bool autoJrnlExpand;
u_int16_t autoJrnlExpandMaxFiles;
chkJrnlAutoExpandOptions(opts, autoJrnlExpand, autoJrnlExpandMaxFiles,
"auto-expand-max-jfiles", numJrnlFiles, "num-jfiles");
-
+
// Pass option values to init(...)
return init(opts->storeDir, numJrnlFiles, jrnlFsizePgs, jrnlWrCachePageSizeKib,
tplNumJrnlFiles, tplJrnlFSizePgs, tplJrnlWrCachePageSizeKib, autoJrnlExpand,
autoJrnlExpandMaxFiles);
}
@@ -934,7 +934,9 @@
read = false;
break; // done with all messages. (add call in jrnl to test that _emap is
empty.)
default:
- assert("Store Error: Unexpected msg state");
+ std::ostringstream oss;
+ oss << "recoverMessages(): Queue: " <<
queue->getName() << ": Unexpected return from journal read: " <<
mrg::journal::iores_str(res);
+ THROW_STORE_EXCEPTION(oss.str());
} // switch
} // while
} catch (const journal::jexception& e) {
@@ -1028,7 +1030,8 @@
while (!done) {
dtok.reset();
dtok.set_wstate(DataTokenImpl::ENQ);
- switch (tplStorePtr->read_data_record(&dbuff, dbuffSize, &xidbuff,
xidbuffSize, transientFlag, externalFlag, &dtok)) {
+ mrg::journal::iores res = tplStorePtr->read_data_record(&dbuff,
dbuffSize, &xidbuff, xidbuffSize, transientFlag, externalFlag, &dtok);
+ switch (res) {
case mrg::journal::RHM_IORES_SUCCESS: {
// Every TPL record contains both data and an XID
assert(dbuffSize>0);
@@ -1085,7 +1088,9 @@
done = true;
break; // done with all messages. (add call in jrnl to test that _emap is
empty.)
default:
- assert("Store Error: Unexpected msg state");
+ std::ostringstream oss;
+ oss << "readTplStore(): Unexpected result from journal read:
" << mrg::journal::iores_str(res);
+ THROW_STORE_EXCEPTION(oss.str());
} // switch
}
} catch (const journal::jexception& e) {
@@ -1277,7 +1282,7 @@
Dbt key (&messageId, sizeof(messageId));
char *buffer = new char[length];
Dbt value(buffer, length);
-
+
// Read the first 4 bytes (u_int32_t) which is the header size.
value.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
value.set_ulen(sizeof(u_int32_t));
@@ -1758,7 +1763,7 @@
u_int32_t MessageStoreImpl::bHash(const std::string str)
{
- // Daniel Bernstein hash fn
+ // Daniel Bernstein hash fn
u_int32_t h = 0;
for (std::string::const_iterator i = str.begin(); i < str.end(); i++)
h = 33*h + *i;
Show replies by date