Uploaded image for project: 'AMQ Clients'
  1. AMQ Clients
  2. ENTMQCL-601

[proton-c] container continues to run() after container.stop() called from main thread

XMLWordPrintable

    • Medium
    • Workaround Exists
    • Hide

      Calling container stop() from a messaging_handler callback succeeds.

      Show
      Calling container stop() from a messaging_handler callback succeeds.
    • February 2018

      Using the below code

      #include <proton/container.hpp>
      #include <iostream>
      #include <thread>
      
      int main( int, char** )
      {
        try
        {
          proton::container c;
          c.auto_stop( false );
          auto containerThread = std::thread([&]() { std::cout << "CONTAINER IS RUNNING" << std::endl; 
                                                                                                c.run(); std::cout << "CONTAINER IS DONE" << std::endl; });
          std::this_thread::sleep_for( std::chrono::seconds( 2 ));
          std::cout << "STOPPING CONTAINER" << std::endl;
          c.stop();
          std::cout << "WAITING FOR CONTAINER" << std::endl;
          containerThread.join();
          return 0;
        }
        catch( std::exception& e )
        {
          std::cerr << e.what() << std::endl;
        }
        return 1;
      }
      

      via

      [rkieley@i7t450s build]$ g++ -g -Wall -Wextra -Wpointer-arith -Wconversion -Wformat -Wformat-security -Wformat-y2k -Wsign-promo -Wcast-qual -g3 -ggdb3 -Wunused-variable -fno-eliminate-unused-debug-types -O3 -DNDEBUG -fPIC -DPN_CPP_HAS_LAMBDAS=0  -std=gnu++11  ../attachments/test.cpp -lqpid-proton-cpp -lqpid-proton-core -lqpid-proton-proactor -lrt -lpthread -o test
      

      With both PROACTOR epoll and libuv I see the following when run:

      [New Thread 0x7ffff3c95700 (LWP 20312)]
      CONTAINER IS RUNNING
      STOPPING CONTAINER
      WAITING FOR CONTAINER
      ^C
      Thread 1 "test" received signal SIGINT, Interrupt.

      When I use CTRL-C to stop waiting after running via gdb and waiting 2 minutes.

              astitcher Andrew Stitcher
              rhn-support-rkieley Roderick Kieley
              Jiri Daněk Jiri Daněk
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: