我使用asio :: ip :: tcp :: socket :: async_connect获取helgrind错误,同时io_service :: run在线程池中运行。报告是:
线程#6
在0x507bb50读取大小8期间可能发生数据竞争== 13316 ==在0xDDF1CC:boost :: asio :: detail :: epoll_reactor :: descriptor_state :: perform_io(unsigned int)(epoll_reactor.ipp:610)
== 13316 == by 0xDDF355:boost :: asio :: detail :: epoll_reactor :: descriptor_state :: do_complete(boost :: asio :: detail :: task_io_service *,boost :: asio :: detail :: task_io_service_operation *,boost :: system :: error_code const&,unsigned long)(epoll_reactor.ipp:648)
== 13316 == by 0xD7CF93:boost :: asio :: detail :: task_io_service_operation :: complete(boost :: asio :: detail :: task_io_service&,boost :: system :: error_code const&amp ;, unsigned long) (task_io_service_operation.hpp:37)
== 13316 == by 0xE17469:boost :: asio :: detail :: task_io_service :: do_run_one(boost :: asio :: detail :: scoped_lock&,boost :: asio :: detail :: task_io_service :: thread_info& ;,boost :: asio :: detail :: op_queue&,boost :: system :: error_code const&)(task_io_service.ipp:394)
== 13316 == by 0xE1713B:boost :: asio :: detail :: task_io_service :: run(boost :: system :: error_code&)(task_io_service.ipp:146)
== 13316 == by 0xE176FC:boost :: asio :: io_service :: run()(io_service.ipp:59)
== 13316 == by 0xF97421:Common :: ServiceRunner :: ServiceThread()(ServiceRunner.cpp:67) ....
这与线程#9
之前写入的大小为8冲突== 13316 ==在0xDDE5EF:boost :: asio :: detail :: epoll_reactor :: register_descriptor(int,boost :: asio :: detail :: epoll_reactor :: descriptor_state *&)(epoll_reactor.ipp:156 )
== 13316 == by 0xE75C34:boost :: asio :: detail :: reactive_socket_service_base :: do_open(boost :: asio :: detail :: reactive_socket_service_base :: base_implementation_type&,int,int,int,boost :: system :: error_code&)(reactive_socket_service_base.ipp:152)
== 13316 == by 0xE7B6E2:boost :: asio :: detail :: reactive_socket_service :: open(boost :: asio :: detail :: reactive_socket_service :: implementation_type&,boost :: asio :: ip :: tcp const&,boost :: system :: error_code&)(reactive_socket_service.hpp:106)
== 13316 == by 0xE79FF7:boost :: asio :: stream_socket_service :: open (boost :: asio :: detail :: reactive_socket_service :: implementation_type&,boost :: asio :: ip :: tcp const&,boost :: system :: error_code&)(stream_socket_service.hpp:127)
== 13316 == by 0xE78904:void boost :: asio :: basic_socket> :: async_connect &gt ;, boost :: _ bi :: list3&gt ;, boost :: arg< 1> ; (*)(),boost :: _ bi :: value> > > > >(boost :: asio :: ip :: basic_endpoint const&,boost :: asio :: detail :: wrapped_handler>,boost :: _ bi :: list3&gt ;, boost :: arg< 1>(*)( ),boost :: _ bi :: value>>>> const&)(basic_socket.hpp:712) == 13316 == by 0xE7376B:Common :: Comms :: TCPClient :: HandleResolve(boost :: system :: error_code const&,boost :: asio :: ip :: basic_resolver_iterator)(TCPClient.cpp:297)
* 我发现async_connect不是真正的问题,但是当io_service :: run正在运行时打开套接字。*
提前感谢您的帮助