| 485 | } |
| 486 | |
| 487 | void test_container_mt_stop() { |
| 488 | test_mt_handler th; |
| 489 | proton::container c(th); |
| 490 | c.auto_stop(false); |
| 491 | container_runner runner(c); |
| 492 | auto t = std::thread(runner); |
| 493 | // Must ensure that thread is joined |
| 494 | try { |
| 495 | test_listen_handler lh; |
| 496 | ASSERT_EQUAL("start", th.wait()); |
| 497 | c.listen("//:0", lh); // Also opens a connection |
| 498 | ASSERT_EQUAL("open", th.wait()); |
| 499 | c.stop(); |
| 500 | t.join(); |
| 501 | } catch (const std::exception& e) { |
| 502 | std::cerr << FAIL_MSG(e.what()) << std::endl; |
| 503 | // If join hangs, let the test die by timeout. We cannot |
| 504 | // detach and continue: deleting the container while t is |
| 505 | // still alive will put the process in an undefined state. |
| 506 | t.join(); |
| 507 | throw; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | class test_mt_handler_wq : public test_mt_handler { |
| 512 | public: |