Author: kpvdr
Date: 2007-12-17 17:17:21 -0500 (Mon, 17 Dec 2007)
New Revision: 1508
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jexception.cpp
store/trunk/cpp/lib/jrnl/jexception.hpp
Log:
Additional bugfixes around threading for BZ423981 and a fix for possible scope problems in
jexception::what().
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-12-17 22:14:21 UTC (rev 1507)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-12-17 22:17:21 UTC (rev 1508)
@@ -341,7 +341,7 @@
const u_int32_t
jcntl::get_wr_events()
{
- stlock t(&_gev_mutex);
+ stlock t(&_wr_mutex);
if (t.locked())
return _wmgr.get_events(pmgr::UNUSED);
return 0;
@@ -427,7 +427,7 @@
u_int32_t cnt = 0;
while (_wmgr.get_aio_evt_rem())
{
- get_wr_events();
+ _wmgr.get_events(pmgr::UNUSED);
if (cnt++ > MAX_AIO_CMPL_SLEEPS)
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"aio_cmpl_wait");
usleep(AIO_CMPL_SLEEP);
@@ -441,7 +441,7 @@
if (res == RHM_IORES_AIO_WAIT)
{
u_int32_t cnt = 0;
- while (get_wr_events() == 0)
+ while (_wmgr.get_events(pmgr::UNUSED) == 0)
{
if (cnt++ > MAX_AIO_CMPL_SLEEPS)
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"aio_cmpl_wait");
Modified: store/trunk/cpp/lib/jrnl/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp 2007-12-17 22:14:21 UTC (rev 1507)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp 2007-12-17 22:17:21 UTC (rev 1508)
@@ -46,36 +46,48 @@
jexception::jexception() throw ():
std::exception(),
_err_code(0)
-{}
+{
+ format();
+}
jexception::jexception(const u_int32_t err_code) throw ():
std::exception(),
_err_code(err_code)
-{}
+{
+ format();
+}
jexception::jexception(const char* additional_info) throw ():
std::exception(),
_err_code(0),
_additional_info(additional_info)
-{}
+{
+ format();
+}
jexception::jexception(const std::string& additional_info) throw ():
std::exception(),
_err_code(0),
_additional_info(additional_info)
-{}
+{
+ format();
+}
jexception::jexception(const u_int32_t err_code, const char* additional_info) throw ():
std::exception(),
_err_code(err_code),
_additional_info(additional_info)
-{}
+{
+ format();
+}
jexception::jexception(const u_int32_t err_code, const std::string& additional_info)
throw ():
std::exception(),
_err_code(err_code),
_additional_info(additional_info)
-{}
+{
+ format();
+}
jexception::jexception(const u_int32_t err_code, const char* throwing_class,
const char* throwing_fn) throw ():
@@ -83,7 +95,9 @@
_err_code(err_code),
_throwing_class(throwing_class),
_throwing_fn(throwing_fn)
-{}
+{
+ format();
+}
jexception::jexception(const u_int32_t err_code, const std::string& throwing_class,
const std::string& throwing_fn) throw ():
@@ -91,7 +105,9 @@
_err_code(err_code),
_throwing_class(throwing_class),
_throwing_fn(throwing_fn)
-{}
+{
+ format();
+}
jexception::jexception(const u_int32_t err_code, const char* additional_info,
const char* throwing_class, const char* throwing_fn) throw ():
@@ -100,7 +116,9 @@
_additional_info(additional_info),
_throwing_class(throwing_class),
_throwing_fn(throwing_fn)
-{}
+{
+ format();
+}
jexception::jexception(const u_int32_t err_code, const std::string& additional_info,
const std::string& throwing_class, const std::string& throwing_fn) throw
():
@@ -109,13 +127,15 @@
_additional_info(additional_info),
_throwing_class(throwing_class),
_throwing_fn(throwing_fn)
-{}
+{
+ format();
+}
jexception::~jexception() throw ()
{}
-const char*
-jexception::what() const throw ()
+void
+jexception::format()
{
const bool ai = !_additional_info.empty();
const bool tc = !_throwing_class.empty();
@@ -136,9 +156,15 @@
oss << "threw " << jerrno::err_msg(_err_code);
if (ai)
oss << " (" << _additional_info << ")";
- return oss.str().c_str();
+ _what.assign(oss.str());
}
+const char*
+jexception::what() const throw ()
+{
+ return _what.c_str();
+}
+
std::ostream&
operator<<(std::ostream& os, const jexception& je)
{
Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp 2007-12-17 22:14:21 UTC (rev 1507)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2007-12-17 22:17:21 UTC (rev 1508)
@@ -78,6 +78,8 @@
std::string _additional_info;
std::string _throwing_class;
std::string _throwing_fn;
+ std::string _what;
+ void format();
public:
jexception() throw ();