[rhmessaging-commits] rhmessaging commits: r1979 - store/trunk/cpp/tests/jrnl.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Apr 24 15:44:48 EDT 2008


Author: kpvdr
Date: 2008-04-24 15:44:47 -0400 (Thu, 24 Apr 2008)
New Revision: 1979

Modified:
   store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp
   store/trunk/cpp/tests/jrnl/_ut_jinf.cpp
Log:
Additional memory leak fix for read error code path in boost read test

Modified: store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp	2008-04-24 19:08:06 UTC (rev 1978)
+++ store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp	2008-04-24 19:44:47 UTC (rev 1979)
@@ -90,16 +90,19 @@
 }
 
 bool
-check_iores(const string& ctxt, const iores ret, const iores exp_ret)
+check_iores(const string& ctxt, const iores ret, const iores exp_ret, test_dtok* dtp)
 {
     if (ret != exp_ret)
+    {
+        delete dtp;
         BOOST_FAIL(ctxt << ": Expected " << iores_str(exp_ret) << "; got " << iores_str(ret));
+    }
     return false;
 }
 
 bool
 handle_jcntl_response(const iores res, jcntl& jc, unsigned& aio_sleep_cnt, const std::string& ctxt,
-        const iores exp_ret)
+        const iores exp_ret, test_dtok* dtp)
 {
     if (res == RHM_IORES_PAGE_AIOWAIT)
     {
@@ -109,10 +112,10 @@
             usleep(AIO_SLEEP_TIME);
         }
         else
-            return check_iores(ctxt, res, exp_ret);
+            return check_iores(ctxt, res, exp_ret, dtp);
     }
     else
-        return check_iores(ctxt, res, exp_ret);
+        return check_iores(ctxt, res, exp_ret, dtp);
     return true;
 }
 
@@ -127,7 +130,7 @@
     try
     {
         iores res = jc.enqueue_data_record(msg.c_str(), msg.size(), msg.size(), dtp, transient);
-        check_iores(ctxt.str(), res, exp_ret);
+        check_iores(ctxt.str(), res, exp_ret, dtp);
         u_int64_t dtok_rid = dtp->rid();
         if (dtp->done()) delete dtp;
         return dtok_rid;
@@ -146,7 +149,7 @@
     try
     {
     iores res = jc.enqueue_extern_data_record(msg_size, dtp, transient);
-    check_iores(ctxt.str(), res, exp_ret);
+    check_iores(ctxt.str(), res, exp_ret, dtp);
     u_int64_t dtok_rid = dtp->rid();
     if (dtp->done()) delete dtp;
     return dtok_rid;
@@ -166,7 +169,7 @@
     {
         iores res = jc.enqueue_txn_data_record(msg.c_str(), msg.size(), msg.size(), dtp, xid,
                 transient);
-        check_iores(ctxt.str(), res, exp_ret);
+        check_iores(ctxt.str(), res, exp_ret, dtp);
         u_int64_t dtok_rid = dtp->rid();
         if (dtp->done()) delete dtp;
         return dtok_rid;
@@ -185,7 +188,7 @@
     try
     {
         iores res = jc.enqueue_extern_txn_data_record(msg_size, dtp, xid, transient);
-        check_iores(ctxt.str(), res, exp_ret);
+        check_iores(ctxt.str(), res, exp_ret, dtp);
         u_int64_t dtok_rid = dtp->rid();
         if (dtp->done()) delete dtp;
         return dtok_rid;
@@ -205,7 +208,7 @@
     try
     {
         iores res = jc.dequeue_data_record(dtp);
-        check_iores(ctxt.str(), res, exp_ret);
+        check_iores(ctxt.str(), res, exp_ret, dtp);
         u_int64_t dtok_rid = dtp->rid();
         if (dtp->done()) delete dtp;
         return dtok_rid;
@@ -226,7 +229,7 @@
     try
     {
         iores res = jc.dequeue_txn_data_record(dtp, xid);
-        check_iores(ctxt.str(), res, exp_ret);
+        check_iores(ctxt.str(), res, exp_ret, dtp);
         u_int64_t dtok_rid = dtp->rid();
         if (dtp->done()) delete dtp;
         return dtok_rid;
@@ -242,7 +245,7 @@
     try
     {
         iores res = jc.txn_abort(dtp, xid);
-        check_iores("txn_abort", res, exp_ret);
+        check_iores("txn_abort", res, exp_ret, dtp);
         u_int64_t dtok_rid = dtp->rid();
         if (dtp->done()) delete dtp;
         return dtok_rid;
@@ -258,7 +261,7 @@
     try
     {
         iores res = jc.txn_commit(dtp, xid);
-        check_iores("txn_commit", res, exp_ret);
+        check_iores("txn_commit", res, exp_ret, dtp);
         u_int64_t dtok_rid = dtp->rid();
         if (dtp->done()) delete dtp;
         return dtok_rid;
@@ -281,8 +284,9 @@
     unsigned aio_sleep_cnt = 0;
     try
     {
-        while (handle_jcntl_response(jc.read_data_record(&mp, msize, &xp, xsize, transient,
-                external, dtp), jc, aio_sleep_cnt, "read_msg", exp_ret)) ;
+        iores res = jc.read_data_record(&mp, msize, &xp, xsize, transient, external, dtp);
+        while (handle_jcntl_response(res, jc, aio_sleep_cnt, "read_msg", exp_ret, dtp))
+            res = jc.read_data_record(&mp, msize, &xp, xsize, transient, external, dtp);
     }
     catch (exception e) { delete dtp; throw; }
 

Modified: store/trunk/cpp/tests/jrnl/_ut_jinf.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jinf.cpp	2008-04-24 19:08:06 UTC (rev 1978)
+++ store/trunk/cpp/tests/jrnl/_ut_jinf.cpp	2008-04-24 19:44:47 UTC (rev 1979)
@@ -105,13 +105,13 @@
             BOOST_FAIL("Unable to open test journal file " << *itr << " for writing.");
         
         // prepare file_hdr
+        int cnt = sizeof(file_hdr);
         if (scheme == RID_NONE) // create file containing 0s
-            std::memset(&fh, 0, sizeof(file_hdr));
+            std::memset(&fh, 0, cnt);
         else
             init_fhdr(fh, fid, rid, fid >= min_fid_offs);
         
         // write file header
-        int cnt = sizeof(file_hdr);
         of.write((const char*)&fh, cnt);
         
         // fill remaining sblk with 0s




More information about the rhmessaging-commits mailing list