fixed race condition in enum_net

This commit is contained in:
Arvid Norberg 2007-09-22 16:22:41 +00:00
parent a26bd55ff9
commit 87c079033d
2 changed files with 3 additions and 4 deletions

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent namespace libtorrent
{ {
std::vector<address> const& enum_net_interfaces(asio::io_service& ios, asio::error_code& ec); std::vector<address> enum_net_interfaces(asio::io_service& ios, asio::error_code& ec);
} }
#endif #endif

View File

@ -40,10 +40,9 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent namespace libtorrent
{ {
std::vector<address> const& enum_net_interfaces(asio::io_service& ios, asio::error_code& ec) std::vector<address> enum_net_interfaces(asio::io_service& ios, asio::error_code& ec)
{ {
static std::vector<address> ret; std::vector<address> ret;
if (!ret.empty()) return ret;
#if defined __linux__ || defined __MACH__ || defined(__FreeBSD__) #if defined __linux__ || defined __MACH__ || defined(__FreeBSD__)
int s = socket(AF_INET, SOCK_DGRAM, 0); int s = socket(AF_INET, SOCK_DGRAM, 0);