Skip to content

Asio hangs on system call close (Mac OS X) #10

@ruslo

Description

@ruslo

This test:

#include <thread>
#include <asio.hpp>
#include <boost/chrono.hpp>

int main() {
  for (int i = 0; i < 10000; ++i) {
    std::cout << i << std::endl;

    asio::io_service ioService;
    asio::deadline_timer timer(ioService);

    ioService.post([&](){
      timer.expires_from_now(boost::posix_time::milliseconds(1));
      timer.async_wait([&](const asio::error_code &) {});
    });

    ioService.post([&](){
      ioService.post([](){});
    });

    // Run some threads
    std::vector<std::thread> threads;
    for (auto i=0; i<3; ++i) {
      threads.emplace_back([&](){ ioService.run(); });
    }
    for (auto& i: threads) {
      i.join();
    }
  }
  return EXIT_SUCCESS;
}

hangs on system call close:

Tested on: Mac OS X 10.9.1/10.8.5, clang -stdlib=libc++ -std=c++11, boost 1.55.0
master branch: e80030f
cpp11-only branch: f1cbf4f

Originally from: http://stackoverflow.com/questions/21835749/boost-asio-io-service-destructor-hangs-on-os-x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions