Skip to content

Commit

Permalink
encapsulate resolver.resolve(query) + restore-FPU into `WrapResolve…
Browse files Browse the repository at this point in the history
…(...)`
  • Loading branch information
hoijui committed Dec 29, 2010
1 parent bc485d8 commit f84ba96
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
21 changes: 21 additions & 0 deletions rts/System/Net/Socket.cpp
Expand Up @@ -84,5 +84,26 @@ boost::asio::ip::address WrapIP(const std::string& ip, boost::system::error_code
return addr;
}

boost::asio::ip::tcp::resolver::iterator WrapResolve(
boost::asio::ip::tcp::resolver& resolver,
boost::asio::ip::tcp::resolver::query& query,
boost::system::error_code* err)
{
boost::asio::ip::tcp::resolver::iterator resolveIt;

if (err == NULL) {
resolveIt = resolver.resolve(query);
} else {
resolveIt = resolver.resolve(query, *err);
}
#ifdef STREFLOP_H
//! (date of note: 08/22/10)
//! something in resolve() is invalidating the FPU flags
streflop_init<streflop::Simple>();
#endif

return resolveIt;
}

} // namespace netcode

10 changes: 10 additions & 0 deletions rts/System/Net/Socket.h
Expand Up @@ -5,6 +5,7 @@

#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/ip/tcp.hpp>


namespace netcode
Expand All @@ -26,6 +27,15 @@ bool IsLoopbackAddress(const boost::asio::ip::address& addr);
*/
boost::asio::ip::address WrapIP(const std::string& ip, boost::system::error_code* err = NULL);

/**
* Encapsulates the ip::tcp::resolver::resolve(query) function,
* for sync relevant reasons.
*/
boost::asio::ip::tcp::resolver::iterator WrapResolve(
boost::asio::ip::tcp::resolver& resolver,
boost::asio::ip::tcp::resolver::query& query,
boost::system::error_code* err = NULL);

} // namespace netcode

#endif
8 changes: 2 additions & 6 deletions rts/lib/lobby/Connection.cpp
Expand Up @@ -9,6 +9,7 @@
#include <bitset>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include "System/Net/Socket.h"
#include "lib/md5/md5.h"
#include "lib/md5/base64.h"
#include "lib/streflop/streflop_cond.h"
Expand Down Expand Up @@ -47,12 +48,7 @@ void Connection::Connect(const std::string& server, int port)
std::ostringstream portbuf;
portbuf << port;
ip::tcp::resolver::query query(server, portbuf.str());
ip::tcp::resolver::iterator iter = resolver.resolve(query, err);
#ifdef STREFLOP_H
//! (date of note: 08/22/10)
//! something in resolve() is invalidating the FPU flags
streflop_init<streflop::Simple>();
#endif
ip::tcp::resolver::iterator iter = netcode::WrapResolve(resolver, query, &err);
if (err)
{
DoneConnecting(false, err.message());
Expand Down

0 comments on commit f84ba96

Please sign in to comment.