fix asio debugging
This commit is contained in:
parent
3167b68e98
commit
86c83fe976
|
@ -83,6 +83,32 @@ using libtorrent::aux::session_impl;
|
|||
|
||||
namespace libtorrent
|
||||
{
|
||||
namespace {
|
||||
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
void wait_for_asio_handlers()
|
||||
{
|
||||
int counter = 0;
|
||||
while (log_async())
|
||||
{
|
||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||
Sleep(1000);
|
||||
#elif defined TORRENT_BEOS
|
||||
snooze_until(system_time() + 1000000, B_SYSTEM_TIMEBASE);
|
||||
#else
|
||||
usleep(1000000);
|
||||
#endif
|
||||
++counter;
|
||||
printf("\x1b[2J\x1b[0;0H\x1b[33m==== Waiting to shut down: %d ==== \x1b[0m\n\n"
|
||||
, counter);
|
||||
}
|
||||
async_dec_threads();
|
||||
|
||||
fprintf(stderr, "\n\nEXPECTS NO MORE ASYNC OPS\n\n\n");
|
||||
}
|
||||
#endif
|
||||
} // anonymous namespace
|
||||
|
||||
TORRENT_EXPORT void min_memory_usage(settings_pack& set)
|
||||
{
|
||||
// receive data directly into disk buffers
|
||||
|
@ -378,28 +404,13 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_impl);
|
||||
TORRENT_ASYNC_CALL(abort);
|
||||
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
int counter = 0;
|
||||
while (log_async())
|
||||
{
|
||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||
Sleep(1000);
|
||||
#elif defined TORRENT_BEOS
|
||||
snooze_until(system_time() + 1000000, B_SYSTEM_TIMEBASE);
|
||||
#else
|
||||
usleep(1000000);
|
||||
#endif
|
||||
++counter;
|
||||
printf("\x1b[2J\x1b[0;0H\x1b[33m==== Waiting to shut down: %d ==== \x1b[0m\n\n"
|
||||
, counter);
|
||||
}
|
||||
async_dec_threads();
|
||||
|
||||
fprintf(stderr, "\n\nEXPECTS NO MORE ASYNC OPS\n\n\n");
|
||||
#endif
|
||||
|
||||
if (m_thread && m_thread.unique())
|
||||
{
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
wait_for_asio_handlers();
|
||||
#endif
|
||||
m_thread->join();
|
||||
}
|
||||
}
|
||||
|
||||
session_proxy session::abort()
|
||||
|
@ -424,7 +435,12 @@ namespace libtorrent
|
|||
session_proxy::~session_proxy()
|
||||
{
|
||||
if (m_thread && m_thread.unique())
|
||||
{
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
wait_for_asio_handlers();
|
||||
#endif
|
||||
m_thread->join();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue