prevent use of threading interfaces without HAVE_THREADS

This commit is contained in:
David Rose 2005-09-30 15:42:28 +00:00
parent 5f3b0fc55b
commit b19e098094
3 changed files with 32 additions and 0 deletions

View File

@ -81,6 +81,20 @@ ConnectionReader::
ConnectionReader(ConnectionManager *manager, int num_threads) :
_manager(manager)
{
#ifndef HAVE_THREADS
// Although this code is written to use thread-locking primitives
// regardless of the definition of HAVE_THREADS, it is not safe to
// spawn multiple threads when HAVE_THREADS is not true, since we
// might be using a non-thread-safe malloc scheme.
#ifndef NDEBUG
if (num_threads != 0) {
net_cat.error()
<< "Threading support is not available.\n";
}
#endif // NDEBUG
num_threads = 0;
#endif // HAVE_THREADS
_raw_mode = false;
_tcp_header_size = datagram_tcp16_header_size;
_polling = (num_threads <= 0);

View File

@ -38,6 +38,20 @@ ConnectionWriter::
ConnectionWriter(ConnectionManager *manager, int num_threads) :
_manager(manager)
{
#ifndef HAVE_THREADS
// Although this code is written to use thread-locking primitives
// regardless of the definition of HAVE_THREADS, it is not safe to
// spawn multiple threads when HAVE_THREADS is not true, since we
// might be using a non-thread-safe malloc scheme.
#ifndef NDEBUG
if (num_threads != 0) {
net_cat.error()
<< "Threading support is not available.\n";
}
#endif // NDEBUG
num_threads = 0;
#endif // HAVE_THREADS
_raw_mode = false;
_tcp_header_size = datagram_tcp16_header_size;
_immediate = (num_threads <= 0);

View File

@ -35,7 +35,11 @@
////////////////////////////////////////////////////////////////////
PStatReader::
PStatReader(PStatServer *manager, PStatMonitor *monitor) :
#ifdef HAVE_THREADS
ConnectionReader(manager, monitor->is_thread_safe() ? 1 : 0),
#else // HAVE_THREADS
ConnectionReader(manager, 0),
#endif // HAVE_THREADS
_manager(manager),
_monitor(monitor),
_writer(manager, 0)