Author: kpvdr
Date: 2007-09-14 13:33:14 -0400 (Fri, 14 Sep 2007)
New Revision: 922
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jcntl.hpp
Log:
Added a blocking ability to jcntl::stop() which will wait for all remianing write AIO
events to complete before returning.
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-14 17:10:49 UTC (rev 921)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-14 17:33:14 UTC (rev 922)
@@ -120,12 +120,8 @@
void
jcntl::delete_jrnl() throw (jexception)
{
- stop();
-
- // wait for AIO or issue cancel...
-
+ stop(true); // wait for AIO to complete
_jdir.delete_dir();
-
}
@@ -164,11 +160,13 @@
}
void
-jcntl::stop() throw (jexception)
+jcntl::stop(bool block_for_aio_cmpl) throw (jexception)
{
check_status("stop");
_stop_flag = true;
flush();
+ if (block_for_aio_cmpl)
+ aio_cmpl_wait();
}
// Private functions
@@ -203,7 +201,18 @@
of.close();
}
+#define AIO_CMPL_SLEEP 10000 // 10 ms
void
+jcntl::aio_cmpl_wait() throw (jexception)
+{
+ while (_wmgr.get_aio_evt_rem())
+ {
+ get_wr_events();
+ usleep(AIO_CMPL_SLEEP);
+ }
+}
+
+void
jcntl::aio_wr_callback(jcntl* journal, u_int32_t num_dtoks)
{
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-14 17:10:49 UTC (rev 921)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-14 17:33:14 UTC (rev 922)
@@ -257,8 +257,11 @@
*
* <b>Note:</b> The jouranl cannot be restarted without either
initailizing it or restoring
* it.
+ *
+ * \param block_for_aio_cmpl If true, will block the thread while waiting for all
outstanding
+ * AIO operations to complete.
*/
- void stop() throw (jexception);
+ void stop(bool block_for_aio_cmpl = false) throw (jexception);
/**
* \brief Force a flush of the write page cache, creating a single AIO write
operation.
@@ -312,6 +315,11 @@
*/
void write_infofile() const throw (jexception);
+ /**
+ * \brief Call that blocks while waiting for all outstanding AIOs to complete
+ */
+ void aio_cmpl_wait() throw (jexception);
+
/**
* Intenal callback write
*/
Show replies by date