Subject: [Boost-bugs] [Boost C++ Libraries] #5285: problem about boost::asio::ip::tcp::resolver
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-09 08:03:33
#5285: problem about boost::asio::ip::tcp::resolver
--------------------------------------------------+-------------------------
Reporter: gong yiling <gongyiling3468@â¦> | Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.45.0 | Severity: Problem
Keywords: |
--------------------------------------------------+-------------------------
one day i found a bug in my project, that's one of async_resolve's
callback never called. i checked this problem and repeat this problem as
following program:
{{{
#include "stdafx.h"
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/system/error_code.hpp>
#include <stdio.h>
using namespace boost::asio;
using namespace boost;
class client
{
public:
client(io_service& ios):
m_ios(ios),
m_resolver(ios)
{
ip::tcp::resolver* resolver = new
ip::tcp::resolver(m_ios);
delete resolver;
ip::tcp::resolver::query query("www.baidu.com","80");
m_resolver.async_resolve(query,boost::bind(&client::handle_resolve,this,_1,_2));
}
void handle_resolve(const system::error_code&
ec,ip::tcp::resolver_iterator it)
{
puts("see me?");
}
io_service& m_ios;
ip::tcp::resolver m_resolver;
};
int _tmain(int argc, _TCHAR* argv[])
{
io_service ios;
client* c = new client(ios);
ios.run();
return 0;
}
}}}
i digged into the source code( in function
boost.asio.detail.resolver_service.destroy ) it seems when i delete a
temporary created resolver, the resolver's work service will be stopped.
and thus client::handle_resolve will never be called.
thx
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5285> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:05 UTC