[rhmessaging-commits] rhmessaging commits: r2054 - in store/trunk/cpp: tests/jrnl/jtt and 1 other directory.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Thu May 15 11:03:20 EDT 2008
Author: kpvdr
Date: 2008-05-15 11:03:20 -0400 (Thu, 15 May 2008)
New Revision: 2054
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
Log:
BZ446216 "jtt tests hanging". Two issues solved: the bad handling of RHM_IORES_ENQCAPTHRESH returns under jtt, which caused it to hang waiting indefinitely for this status to change; and solving the underlying cause - incomplete recovery.
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2008-05-15 14:48:01 UTC (rev 2053)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2008-05-15 15:03:20 UTC (rev 2054)
@@ -652,10 +652,24 @@
std::size_t cum_size_read = 0;
void* xidp = 0;
rec_hdr h;
- if (!jfile_cycle(fid, ifsp, lowi, rd, true))
- return false;
- std::streampos file_pos = ifsp->tellg();
- ifsp->read((char*)&h, sizeof(rec_hdr));
+
+ bool hdr_ok = false;
+ std::streampos file_pos;
+ while (!hdr_ok)
+ {
+ if (!ifsp->is_open())
+ {
+ if (!jfile_cycle(fid, ifsp, lowi, rd, true))
+ return false;
+ }
+ file_pos = ifsp->tellg();
+ ifsp->read((char*)&h, sizeof(rec_hdr));
+ if (ifsp->gcount() == sizeof(rec_hdr))
+ hdr_ok = true;
+ else if (!jfile_cycle(fid, ifsp, lowi, rd, true))
+ return false;
+ }
+
switch(h._magic)
{
case RHM_JDAT_ENQ_MAGIC:
@@ -800,8 +814,8 @@
}
bool
-jcntl::decode(jrec& rec, u_int16_t& fid, std::ifstream* ifsp, std::size_t& cum_size_read, rec_hdr& h,
- bool& lowi, rcvdat& rd, std::streampos& file_offs)
+jcntl::decode(jrec& rec, u_int16_t& fid, std::ifstream* ifsp, std::size_t& cum_size_read,
+ rec_hdr& h, bool& lowi, rcvdat& rd, std::streampos& file_offs)
{
u_int16_t start_fid = fid;
std::streampos start_file_offs = file_offs;
@@ -839,7 +853,6 @@
{
rd._eo = ifsp->tellg(); // remember file offset before closing
ifsp->close();
- ifsp->clear(); // clear eof flag, req'd for older versions of c++
if (++fid >= _num_jfiles)
{
fid = 0;
@@ -854,6 +867,7 @@
std::ostringstream oss;
oss << _jdir.dirname() << "/" << _base_filename << ".";
oss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
+ ifsp->clear(); // clear eof flag, req'd for older versions of c++
ifsp->open(oss.str().c_str(), std::ios_base::in | std::ios_base::binary);
if (!ifsp->good())
throw jexception(jerrno::JERR__FILEIO, oss.str(), "jcntl", "jfile_cycle");
Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp 2008-05-15 14:48:01 UTC (rev 2053)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp 2008-05-15 15:03:20 UTC (rev 2054)
@@ -29,8 +29,9 @@
#include "jrnl/jerrno.hpp"
#include "test_case_result.hpp"
-#define MAX_WR_WAIT 10 // in ms
-#define MAX_RD_WAIT 100 // in ms
+#define MAX_WR_WAIT 10 // in ms
+#define MAX_RD_WAIT 100 // in ms
+#define MAX_ENQCAPTHRESH_CNT 1000 // 10s if MAX_WR_WAIT is 10 ms
namespace rhm
{
@@ -202,8 +203,13 @@
commit(p.get());
break;
case rhm::journal::RHM_IORES_ENQCAPTHRESH:
- if (get_wr_events() == 0)
+ if (++sleep_cnt > MAX_ENQCAPTHRESH_CNT)
{
+ _tcrp->add_exception("Timeout waiting for RHM_IORES_ENQCAPTHRESH to clear.");
+ panic();
+ }
+ else if (get_wr_events() == 0)
+ {
rhm::journal::slock sl(&_wr_full_mutex);
_wr_full_cv.waitintvl(MAX_WR_WAIT * 1000000); // MAX_WR_WAIT in ms
}
More information about the rhmessaging-commits
mailing list