Boost logo

Boost :

From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2005-09-04 09:44:52

Christopher Kohlhoff schrieb:

>The problem arises because WSACleanup is called while the background
>select thread is still running. Applying the following change to
>include/asio/basic_demuxer.hpp should fix the problem:
>@@ -229,6 +229,10 @@
> }
> private:
>+#if defined(_WIN32)
>+ detail::winsock_init<> winsock_init_;
> /// The service registry.
> detail::service_registry<basic_demuxer<Demuxer_Service> >
Yes it apparently fixes the problem, but as I can currently see, it
defeats the original purpose
of the single call to WSAStartup. It seems not to be necessary in this
case. What the code
is trying to achive is kind of a call_once, as I can currently see. But
it delegates instead to
the operating system by calling WSAStartup multiple times.

While it seems to be legal to call it multiple times there are some
1) Is the call to WSAStartup thread safe? (Coudl not find something
definitive, but it seems so.)
2) There was an issue with memory leaking in the WSAStartup code, so
some (older) windows versions might be affected.
3) The call maight fail: e.g.: WSAEINPROGRESS, WSAEPROCLIM, ...
    how will you be able to pair the matching number of WSACleanup calls?

Why not simply use boost threads once function instead?

I also discovered another issue:
The number of demuxers is implicitely limited by available TSS slots.
This also is an issue that long ago has been succesfully solved in the
threading library.

A final question is poping up:
Why not using the boost threading? Or is this planned for future?


Boost list run by bdawes at, gregod at, cpdaniel at, john at