Author: kpvdr
Date: 2007-11-13 19:17:50 -0500 (Tue, 13 Nov 2007)
New Revision: 1308
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jcntl.hpp
store/trunk/cpp/lib/jrnl/jexception.cpp
store/trunk/cpp/lib/jrnl/jexception.hpp
store/trunk/cpp/lib/jrnl/pmgr.cpp
store/trunk/cpp/lib/jrnl/pmgr.hpp
store/trunk/cpp/lib/jrnl/rmgr.cpp
store/trunk/cpp/lib/jrnl/rmgr.hpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
store/trunk/cpp/lib/jrnl/wmgr.hpp
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/jtest.hpp
store/trunk/cpp/tests/jrnl/msg_consumer.cpp
store/trunk/cpp/tests/jrnl/msg_consumer.hpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
store/trunk/cpp/tests/jrnl/msg_producer.hpp
store/trunk/cpp/tests/jrnl/prof
store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
Log:
Fixes to jexception (again) and to the unit tests for jexception. This time no
out-of-scope pointers... Also solved problem with message producer's
send_deferred_dequeues() method which had intermittent hangs and double dequeueing when
auto-dequeue was active.
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -84,8 +84,8 @@
}
void
-jcntl::initialize(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
- std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb) throw (jexception)
+jcntl::initialize(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
+ std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb) throw (jexception)
{
// Prepare journal dir, journal files and file handles
_jdir.clear_dir();
@@ -116,8 +116,8 @@
// constrains read activity (i.e. one can't read what has not yet been written).
_wrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh);
_rrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh);
- _rmgr.initialize(rd_dtokl, rd_cb);
- _wmgr.initialize(wr_dtokl, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
+ _rmgr.initialize(rdtoklp, rd_cb);
+ _wmgr.initialize(wdtoklp, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
// Write info file (<basename>.jinf) to disk
write_infofile();
@@ -126,7 +126,7 @@
}
void
-jcntl::recover(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
std::deque<data_tok*>* wr_dtokl,
+jcntl::recover(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
std::deque<data_tok*>* wdtoklp,
const aio_cb wr_cb, const std::vector<std::string>& prep_txn_list)
throw (jexception)
{
// Verify journal dir and journal files
@@ -160,8 +160,8 @@
// constrains read activity (i.e. one can't read what has not yet been written).
_wrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh, &_rcvdat);
_rrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh, _rcvdat._ffid);
- _rmgr.initialize(rd_dtokl, rd_cb);
- _wmgr.initialize(wr_dtokl, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
+ _rmgr.initialize(rdtoklp, rd_cb);
+ _wmgr.initialize(wdtoklp, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
_readonly_flag = true;
_init_flag = true;
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -176,16 +176,16 @@
* <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal
default callbacks will be
* used.</b>
*
- * \param rd_dtokl deque for storing data tokens retruning from read AIO
operations.
+ * \param rdtoklp deque for storing data tokens retruning from read AIO
operations.
* \param rd_cb Function pointer to callback function for read operations. May be
NULL.
- * \param wr_dtokl deque for storing data tokens retruning from enqueue and
dequeue (write)
+ * \param wdtoklp deque for storing data tokens retruning from enqueue and dequeue
(write)
* AIO operations.
* \param wr_cb Function pointer to callback function for write operations. May be
NULL.
*
* \exception TODO
*/
- void initialize(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
- std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb) throw (jexception);
+ void initialize(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
+ std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb) throw (jexception);
/**
* \brief Initialize using internal default callbacks and data_tok lists.
@@ -215,17 +215,17 @@
* <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal
default callbacks will be
* used.</b>
*
- * \param rd_dtokl deque for storing data tokens retruning from read AIO
operations.
+ * \param rdtoklp deque for storing data tokens retruning from read AIO
operations.
* \param rd_cb Function pointer to callback function for read operations. May be
NULL.
- * \param wr_dtokl deque for storing data tokens retruning from enqueue and
dequeue (write)
+ * \param wdtoklp deque for storing data tokens retruning from enqueue and dequeue
(write)
* AIO operations.
* \param wr_cb Function pointer to callback function for write operations. May be
NULL.
* \param prep_txn_list
*
* \exception TODO
*/
- void recover(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
- std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb,
+ void recover(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
+ std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb,
const std::vector<std::string>& prep_txn_list) throw (jexception);
/**
Modified: store/trunk/cpp/lib/jrnl/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -44,54 +44,59 @@
jexception::jexception() throw ():
std::exception(),
- _err_code(0),
- _additional_info(NULL),
- _throwing_class(NULL),
- _throwing_fn(NULL)
-{}
+ _err_code(0)
+{
+ *_additional_info = '\0';
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
jexception::jexception(const u_int32_t err_code) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(NULL),
- _throwing_class(NULL),
- _throwing_fn(NULL)
+ _err_code(err_code)
+{
+ *_additional_info = '\0';
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
-{}
-
jexception::jexception(const char* additional_info) throw ():
std::exception(),
- _err_code(0),
- _additional_info(additional_info),
- _throwing_class(NULL),
- _throwing_fn(NULL)
-{}
+ _err_code(0)
+{
+ if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
jexception::jexception(const u_int32_t err_code, const char* additional_info) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(additional_info),
- _throwing_class(NULL),
- _throwing_fn(NULL)
-{}
+ _err_code(err_code)
+{
+ if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
jexception::jexception(const u_int32_t err_code, const char* throwing_class,
const char* throwing_fn) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(NULL),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{}
+ _err_code(err_code)
+{
+ *_additional_info = '\0';
+ if (throwing_class) ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE);
+ if (throwing_fn) ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE);
+}
jexception::jexception(const u_int32_t err_code, const char* additional_info,
const char* throwing_class, const char* throwing_fn) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(additional_info),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{}
+ _err_code(err_code)
+{
+ if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ if (throwing_class) ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE);
+ if (throwing_fn) ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE);
+}
jexception::~jexception() throw ()
{}
@@ -100,11 +105,11 @@
jexception::what() const throw ()
{
std::stringstream ss;
- if (_throwing_class && _throwing_fn)
+ if (::strlen(_throwing_class) &&::strlen( _throwing_fn))
ss << _throwing_class << "::" << _throwing_fn
<< "() threw ";
ss << "jexception: 0x" << std::hex << std::setw(4)
<< std::setfill('0') << _err_code;
ss << " " << jerrno::err_msg(_err_code);
- if (_additional_info)
+ if (::strlen(_additional_info))
ss << " (" << _additional_info << ")";
return ss.str().c_str();
}
Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -47,6 +47,9 @@
#include <string>
#include <sys/types.h>
+#define MAX_MSG_SIZE 1024
+#define MAX_THROWING_SIZE 128
+
namespace rhm
{
namespace journal
@@ -59,9 +62,9 @@
{
private:
u_int32_t _err_code;
- const char* _additional_info;
- const char* _throwing_class;
- const char* _throwing_fn;
+ char _additional_info[MAX_MSG_SIZE];
+ char _throwing_class[MAX_THROWING_SIZE];
+ char _throwing_fn[MAX_THROWING_SIZE];
public:
jexception() throw ();
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -80,7 +80,7 @@
_jc(jc),
_emap(emap),
_tmap(tmap),
- _dtokl(NULL),
+ _dtoklp(NULL),
_page_base_ptr(NULL),
_page_ptr_arr(NULL),
_page_cb_arr(NULL),
@@ -98,13 +98,13 @@
{}
pmgr::pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize,
const u_int16_t pages,
- std::deque<data_tok*>* const dtokl) throw (jexception):
+ std::deque<data_tok*>* const dtoklp) throw (jexception):
_pagesize(pagesize),
_pages(pages),
_jc(jc),
_emap(emap),
_tmap(tmap),
- _dtokl(dtokl),
+ _dtoklp(dtoklp),
_page_base_ptr(NULL),
_page_ptr_arr(NULL),
_page_cb_arr(NULL),
Modified: store/trunk/cpp/lib/jrnl/pmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/pmgr.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -118,7 +118,7 @@
jcntl* _jc; ///< Pointer to journal controller
enq_map& _emap; ///< Ref to enqueue map
txn_map& _tmap; ///< Ref to transaction map
- std::deque<data_tok*>* _dtokl; ///< Pointer to external data token
list
+ std::deque<data_tok*>* _dtoklp; ///< Pointer to external data token
list
void* _page_base_ptr; ///< Base pointer to page memory
void** _page_ptr_arr; ///< Array of pointers to pages in page
memory
page_cb* _page_cb_arr; ///< Array of page_cb structs
@@ -140,7 +140,7 @@
pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize,
const u_int16_t pages);
pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize,
- const u_int16_t pages, std::deque<data_tok*>* const dtokl) throw
(jexception);
+ const u_int16_t pages, std::deque<data_tok*>* const dtoklp) throw
(jexception);
virtual ~pmgr();
virtual const u_int32_t get_events(page_state state) throw (jexception) = 0;
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -60,9 +60,9 @@
{}
void
-rmgr::initialize(std::deque<data_tok*>* const dtokl, const aio_cb rd_cb) throw
(jexception)
+rmgr::initialize(std::deque<data_tok*>* const dtoklp, const aio_cb rd_cb) throw
(jexception)
{
- _dtokl = dtokl;
+ _dtoklp = dtoklp;
_cb = rd_cb;
initialize();
}
@@ -444,7 +444,7 @@
// Transfer all data tokens
u_int32_t s = pcbp->_pdtokl->size();
for (u_int32_t k=0; k<s; k++)
- _dtokl->push_back(pcbp->_pdtokl->at(k));
+ _dtoklp->push_back(pcbp->_pdtokl->at(k));
tot_data_toks += s;
// Increment the completed read offset
Modified: store/trunk/cpp/lib/jrnl/rmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/rmgr.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -67,7 +67,7 @@
std::deque<data_tok*>* const dtokl) throw (jexception);
~rmgr();
- void initialize(std::deque<data_tok*>* const dtokl, const aio_cb rd_cb)
throw (jexception);
+ void initialize(std::deque<data_tok*>* const dtoklp, const aio_cb rd_cb)
throw (jexception);
const iores get(const u_int64_t& rid, const size_t& dsize, const
size_t& dsize_avail,
const void** const data, bool auto_discard) throw (jexception);
const iores discard(data_tok* dtok) throw (jexception);
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -58,9 +58,9 @@
_txn_pending_set()
{}
-wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc,
std::deque<data_tok*>* const dtokl,
+wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc,
std::deque<data_tok*>* const dtoklp,
const u_int32_t max_dtokpp, const u_int32_t max_iowait_us) throw (jexception):
- pmgr(jc, emap, tmap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, dtokl),
+ pmgr(jc, emap, tmap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, dtoklp),
_wrfc(wrfc),
_max_dtokpp(max_dtokpp),
_max_io_wait_us(max_iowait_us),
@@ -81,10 +81,10 @@
}
void
-wmgr::initialize(std::deque<data_tok*>* dtokl, const aio_cb wr_cb, const u_int32_t
max_dtokpp,
+wmgr::initialize(std::deque<data_tok*>* dtoklp, const aio_cb wr_cb, const u_int32_t
max_dtokpp,
const u_int32_t max_iowait_us) throw (jexception)
{
- _dtokl = dtokl;
+ _dtoklp = dtoklp;
_max_dtokpp = max_dtokpp;
_max_io_wait_us = max_iowait_us;
_cb = wr_cb;
@@ -783,19 +783,16 @@
switch (dtp->wstate())
{
case data_tok::ENQ_SUBM:
- assert(dtp->wstate() == data_tok::ENQ_SUBM);
dtp->set_wstate(data_tok::ENQ);
if (dtp->has_xid())
_tmap.set_aio_compl(dtp->xid(), dtp->rid());
break;
case data_tok::DEQ_SUBM:
- assert(dtp->wstate() == data_tok::DEQ_SUBM);
dtp->set_wstate(data_tok::DEQ);
if (dtp->has_xid())
_tmap.set_aio_compl(dtp->xid(), dtp->rid());
break;
case data_tok::ABORT_SUBM:
- assert(dtp->wstate() == data_tok::ABORT_SUBM);
dtp->set_wstate(data_tok::ABORTED);
#if !(defined(RHM_WRONLY) || defined(RHM_RDONLY))
it = _txn_pending_set.find(dtp->xid());
@@ -810,7 +807,6 @@
#endif
break;
case data_tok::COMMIT_SUBM:
- assert(dtp->wstate() == data_tok::COMMIT_SUBM);
dtp->set_wstate(data_tok::COMMITTED);
#if !(defined(RHM_WRONLY) || defined(RHM_RDONLY))
it = _txn_pending_set.find(dtp->xid());
@@ -830,7 +826,7 @@
throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str().c_str(),
"wmgr",
"get_events");
}
- _dtokl->push_back(dtp);
+ _dtoklp->push_back(dtp);
}
tot_data_toks += s;
@@ -905,7 +901,7 @@
{
clean();
std::stringstream ss;
- ss << "_iocba new(): errno=" << errno;
+ ss << "_iocba malloc(): errno=" << errno;
throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "wmgr",
"initialize");
}
::memset(_iocba, 0, sizeof(iocb*) * JRNL_NUM_FILES);
Modified: store/trunk/cpp/lib/jrnl/wmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/wmgr.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -97,11 +97,11 @@
public:
wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc);
wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc,
- std::deque<data_tok*>* const dtokl, const u_int32_t max_dtokpp,
+ std::deque<data_tok*>* const dtoklp, const u_int32_t max_dtokpp,
const u_int32_t max_iowait_us) throw (jexception);
~wmgr();
- void initialize(std::deque<data_tok*>* const dtokl, aio_cb wr_cb,
+ void initialize(std::deque<data_tok*>* const dtoklp, aio_cb wr_cb,
const u_int32_t max_dtokpp, const u_int32_t max_iowait_us) throw
(jexception);
const iores enqueue(const void* const data_buff, const size_t tot_data_len,
const size_t this_data_len, data_tok* dtokp, const void* const xid_ptr,
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -130,6 +130,10 @@
void
jtest::initialize(const targs& ta) throw (rhm::journal::jexception)
{
+ assert(_dtok_master_list.size() == 0);
+ assert(_dtok_wr_aio_list.size() == 0);
+ assert(_dtok_rd_aio_list.size() == 0);
+
#ifdef RHM_TIMERS
gettimeofday(_start_time, _tz_ptr);
#endif
@@ -145,9 +149,8 @@
#ifndef RHM_WRONLY
_mc.initialize(c_args);
#endif
- _jc.initialize(&_mc.aio_dtokl(), NULL, &_mp.aio_dtokl(), &mp_aio_cb);
+ _jc.initialize(&_dtok_rd_aio_list, NULL, &_dtok_wr_aio_list,
&mp_aio_cb);
- assert(_dtok_master_list.size() == 0);
for (u_int32_t i=0; i<p_args->_num_msgs; i++)
{
rhm::journal::data_tok* dtp = new rhm::journal::data_tok;
@@ -261,10 +264,12 @@
// static varialbe declarations
std::deque<rhm::journal::data_tok*> jtest::_dtok_master_list;
+std::deque<rhm::journal::data_tok*> jtest::_dtok_wr_aio_list;
+std::deque<rhm::journal::data_tok*> jtest::_dtok_rd_aio_list;
msg_producer::_p_args* jtest::p_args = NULL;
msg_consumer::_c_args* jtest::c_args = NULL;
-msg_producer jtest::_mp(_dtok_master_list);
-msg_consumer jtest::_mc(_dtok_master_list);
+msg_producer jtest::_mp(_dtok_master_list, _dtok_wr_aio_list);
+msg_consumer jtest::_mc(_dtok_master_list, _dtok_rd_aio_list);
rhm::journal::jcntl jtest::_jc(JOURNAL_ID, JOURNAL_DIR, JOURNAL_BASE_FILENAME);
// static method
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -69,6 +69,8 @@
static msg_consumer::_c_args* c_args;
static rhm::journal::jcntl _jc;
static std::deque<rhm::journal::data_tok*> _dtok_master_list;
+ static std::deque<rhm::journal::data_tok*> _dtok_wr_aio_list;
+ static std::deque<rhm::journal::data_tok*> _dtok_rd_aio_list;
struct timeval* _start_time;
struct timeval* _end_time;
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -51,8 +51,10 @@
_err(0)
{}
-msg_consumer::msg_consumer(std::deque<rhm::journal::data_tok*>&
dtok_master_list):
+msg_consumer::msg_consumer(std::deque<rhm::journal::data_tok*>&
dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list):
_dtok_master_list(dtok_master_list),
+ _aio_cmpl_dtok_list(aio_cmpl_dtok_list),
_tot_dblks(0),
_tot_dsize(0)
{
@@ -95,8 +97,12 @@
u_int32_t
msg_consumer::consume(rhm::journal::jcntl& _jcntl, const u_int32_t num_msgs,
+#ifdef RHM_TIMERS
+ const size_t, const size_t, const size_t, const size_t, const bool, const bool)
+#else
const size_t min_msg_size, const size_t max_msg_size, const size_t min_xid_size,
const size_t max_xid_size, const bool transient_expected, const bool
external_expected)
+#endif
throw (rhm::journal::jexception)
{
//std::cout << "msg_consumer::consume() num_msgs=" << num_msgs
<< std::endl;
@@ -136,7 +142,7 @@
_tot_dblks += dtokp->dblocks_read();
_tot_dsize += data_size;
-#ifdef RHM_TIMERS
+#ifndef RHM_TIMERS
// Comment out these for performance checks/measurements
check_msg(msgCntr, data_size, min_msg_size, max_msg_size,
!external_flag,
datap);
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -68,12 +68,13 @@
static bool _interrupt_flag;
u_int32_t _num_msgs;
std::deque<rhm::journal::data_tok*>& _dtok_master_list; // One dtok per msg
to be received
- std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from
completed AIOs go here
+ std::deque<rhm::journal::data_tok*>& _aio_cmpl_dtok_list; // Dtoks from
completed AIOs go here
u_int64_t _tot_dblks;
u_int64_t _tot_dsize;
public:
- msg_consumer(std::deque<rhm::journal::data_tok*>& dtok_master_list);
+ msg_consumer(std::deque<rhm::journal::data_tok*>& dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list);
~msg_consumer();
void initialize(const u_int32_t numMsgs);
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -50,7 +50,8 @@
_err(0)
{}
-msg_producer::msg_producer(std::deque<rhm::journal::data_tok*>&
dtok_master_list):
+msg_producer::msg_producer(std::deque<rhm::journal::data_tok*>&
dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list):
_jcptr(NULL),
_num_msgs(0),
_num_msgs_enq_subm(0),
@@ -60,6 +61,7 @@
_num_txn_subm(0),
_num_txn(0),
_dtok_master_list(dtok_master_list),
+ _aio_cmpl_dtok_list(aio_cmpl_dtok_list),
_tot_dblks(0),
_tot_dsize(0)
{
@@ -312,10 +314,9 @@
void
msg_producer::send_deferred_dequeues(rhm::journal::jcntl& jc)
{
- std::deque<rhm::journal::data_tok*>::iterator ditr = _dd_dtok_list.begin();
- while (ditr != _dd_dtok_list.end())
+ for (unsigned i=0; i<_dd_dtok_list.size(); i++)
{
- rhm::journal::data_tok* ddtokp = *ditr;
+ rhm::journal::data_tok* ddtokp = _dd_dtok_list[i];
#ifndef RHM_WRONLY
// Wait until data token is read before dequeueing
@@ -323,6 +324,7 @@
#endif
{
//std::cout << " D" << ddtokp->id() << " "
<< std::flush;
+ _dd_dtok_list.erase(_dd_dtok_list.begin() + i--);
unsigned aio_sleep_cnt = 0;
bool written = false;
while (!written)
@@ -403,12 +405,7 @@
}
}
}
- ditr = _dd_dtok_list.erase(ditr);
}
-#ifndef RHM_WRONLY
- else
- ditr++;
-#endif
}
}
Modified: store/trunk/cpp/tests/jrnl/msg_producer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -79,13 +79,14 @@
u_int32_t _num_txn_subm;
u_int32_t _num_txn;
std::deque<rhm::journal::data_tok*>& _dtok_master_list; // One dtok per msg
to be sent
- std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from
completed AIOs go here
+ std::deque<rhm::journal::data_tok*>& _aio_cmpl_dtok_list; // Dtoks from
completed AIOs go here
std::deque<rhm::journal::data_tok*> _dd_dtok_list; // Deferred dequeues
u_int64_t _tot_dblks;
u_int64_t _tot_dsize;
public:
- msg_producer(std::deque<rhm::journal::data_tok*>& dtok_master_list);
+ msg_producer(std::deque<rhm::journal::data_tok*>& dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list);
~msg_producer();
void initialize(const u_int32_t numMsgs, bool auto_dequeue);
Modified: store/trunk/cpp/tests/jrnl/prof
===================================================================
--- store/trunk/cpp/tests/jrnl/prof 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/prof 2007-11-14 00:17:50 UTC (rev 1308)
@@ -4,7 +4,7 @@
opcontrol --setup --no-vmlinux --separate=library
opcontrol --start
# -- Do stuff here --
-./jtest
+./jtest wtests.csv 264
# -- End of stuff --
opcontrol --stop
opcontrol --dump
Modified: store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-11-13 20:52:35 UTC (rev
1307)
+++ store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-11-14 00:17:50 UTC (rev
1308)
@@ -47,19 +47,19 @@
{
jexception e1;
BOOST_CHECK_EQUAL(e1.err_code(), (u_int32_t)0);
- BOOST_CHECK(e1.additional_info() == NULL);
- BOOST_CHECK(e1.throwing_class() == NULL);
- BOOST_CHECK(e1.throwing_fn() == NULL);
- BOOST_CHECK(e1.what() != NULL);
+ BOOST_CHECK(::strlen(e1.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e1.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e1.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e1.what()) > 0);
throw e1;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
- BOOST_CHECK(e.additional_info() == NULL);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -70,19 +70,19 @@
{
jexception e2(err_code);
BOOST_CHECK_EQUAL(e2.err_code(), err_code);
- BOOST_CHECK(e2.additional_info() == NULL);
- BOOST_CHECK(e2.throwing_class() == NULL);
- BOOST_CHECK(e2.throwing_fn() == NULL);
- BOOST_CHECK(e2.what() != NULL);
+ BOOST_CHECK(::strlen(e2.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e2.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e2.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e2.what()) > 0);
throw e2;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
- BOOST_CHECK(e.additional_info() == NULL);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -94,18 +94,18 @@
jexception e3(err_msg);
BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
BOOST_CHECK(::strcmp(e3.additional_info(), err_msg) == 0);
- BOOST_CHECK(e3.throwing_class() == NULL);
- BOOST_CHECK(e3.throwing_fn() == NULL);
- BOOST_CHECK(e3.what() != NULL);
+ BOOST_CHECK(::strlen(e3.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e3.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e3.what()) > 0);
throw e3;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -118,18 +118,18 @@
jexception e4(err_code, err_msg);
BOOST_CHECK_EQUAL(e4.err_code(), err_code);
BOOST_CHECK(::strcmp(e4.additional_info(), err_msg) == 0);
- BOOST_CHECK(e4.throwing_class() == NULL);
- BOOST_CHECK(e4.throwing_fn() == NULL);
- BOOST_CHECK(e4.what() != NULL);
+ BOOST_CHECK(::strlen(e4.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e4.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e4.what()) > 0);
throw e4;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -142,19 +142,19 @@
{
jexception e5(err_code, err_class, err_fn);
BOOST_CHECK_EQUAL(e5.err_code(), err_code);
- BOOST_CHECK(e5.additional_info() == NULL);
+ BOOST_CHECK(::strlen(e5.additional_info()) == 0);
BOOST_CHECK(::strcmp(e5.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e5.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e5.what() != NULL);
+ BOOST_CHECK(::strlen(e5.what()) > 0);
throw e5;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
- BOOST_CHECK(e.additional_info() == NULL);
+ BOOST_CHECK(::strlen(e.additional_info()) == 0);
BOOST_CHECK(::strcmp(e.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -171,7 +171,7 @@
BOOST_CHECK(::strcmp(e6.additional_info(), err_msg) == 0);
BOOST_CHECK(::strcmp(e6.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e6.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e6.what() != NULL);
+ BOOST_CHECK(::strlen(e6.what()) > 0);
throw e6;
}
catch (const jexception& e)
@@ -180,9 +180,27 @@
BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
BOOST_CHECK(::strcmp(e.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
+
+void test_msg_scope()
+{
+ try
+ {
+ // These will go out of scope as soon as jexception is thrown...
+ std::string msg("Error message");
+ std::string cls("class");
+ std::string fn("function");
+ throw jexception(100, msg.c_str(), cls.c_str(), fn.c_str());
+ }
+ catch (const jexception& e)
+ {
+ std::stringstream ss;
+ ss << e;
+ BOOST_CHECK(ss.str().size() > 0);
+ }
+}
// Initialize test suite and include test functions
@@ -200,6 +218,7 @@
ts->add(BOOST_TEST_CASE(&test_constructor_4));
ts->add(BOOST_TEST_CASE(&test_constructor_5));
ts->add(BOOST_TEST_CASE(&test_constructor_6));
+ ts->add(BOOST_TEST_CASE(&test_msg_scope));
return ts;
}