* Since this class uses the asnychronous SimpleIo framework, new data may already be read when
* this method is called.
*
+ * @param wait determines if we need to wait; if @a false it is just checked if new data
+ * was received, but no backend cycle is executed.
* @param usec_timeout
* @param usec_timeout_remaining
* @return @a true if new data is available.
*/
-bool T2NServerConnection::fill_buffer(long long usec_timeout,long long* usec_timeout_remaining)
+bool T2NServerConnection::low_fill_buffer(bool wait, long long usec_timeout, long long* usec_timeout_remaining)
{
SCOPETRACKER();
if (is_closed())
module_logger().debug(HERE) << "fill_buffer() called on closed connection";
return false;
}
- SimpleIo::MilliTime t0,t1;
- SimpleIo::get_current_monotonic_time(t0);
- if (!m_got_new_data)
+ if (not m_got_new_data and wait)
{
+ SimpleIo::MilliTime t0,t1;
+ SimpleIo::get_current_monotonic_time(t0);
IOExportWrapperBasePtr ptr = boost::dynamic_pointer_cast< IOExportWrapperBase >(m_real_connection);
if (!ptr)
{
}
}
Backend::getBackend()->doOneStep( timeout );
+ SimpleIo::get_current_monotonic_time(t1);
+ if (usec_timeout_remaining)
+ {
+ long long delta= ((long long)(t1 - t0).get_milliseconds())* 1000L;
+ *usec_timeout_remaining= (usec_timeout > delta ) ? (usec_timeout - delta) : 0L;
+ }
}
- SimpleIo::get_current_monotonic_time(t1);
- if (usec_timeout_remaining)
+ else
{
- long long delta= ((long long)(t1 - t0).get_milliseconds())* 1000L;
- *usec_timeout_remaining= (usec_timeout > delta ) ? (usec_timeout - delta) : 0L;
+ if (usec_timeout_remaining)
+ {
+ *usec_timeout_remaining= usec_timeout;
+ }
}
if (m_got_new_data)
{
return true;
}
return false;
+} // eo T2NServerConnection::low_fill_buffer(bool,long long,long long*)
+
+
+/**
+ * @brief called to fill the connection buffer.
+ *
+ * Since this class uses the asnychronous SimpleIo framework, new data may already be read when
+ * this method is called.
+ *
+ * @param usec_timeout
+ * @param usec_timeout_remaining
+ * @return @a true if new data is available.
+ */
+bool T2NServerConnection::fill_buffer(long long usec_timeout,long long* usec_timeout_remaining)
+{
+ return low_fill_buffer(true, usec_timeout, usec_timeout_remaining);
} // eo T2NServerConnection::fill_buffer(long long,long long*)
}
continue;
}
- result= result or conn->fill_buffer(0);
+ if ( conn->low_fill_buffer(false, 0) )
+ {
+ result= true;
+ }
}
return result;
} // eo T2NServerBase::fill_connection_buffers()