Github user nsuke commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/1005#discussion_r62283672
  
    --- Diff: lib/cpp/test/TNonblockingServerTest.cpp ---
    @@ -47,14 +47,32 @@ struct Handler : public test::ParentServiceIf {
     class Fixture {
     private:
       struct Runner : public apache::thrift::concurrency::Runnable {
    +    int port;
    +    boost::shared_ptr<event_base> userEventBase;
    +    boost::shared_ptr<TProcessor> processor;
         boost::shared_ptr<server::TNonblockingServer> server;
    -    bool error;
    +
         virtual void run() {
    -      error = false;
    +      // When binding to explicit port, allow retrying to workaround bind 
failures on ports in use
    +      int retryCount = port ? 10 : 0;
    +      startServer(retryCount);
    +    }
    +
    +  private:
    +    void startServer(int retry_count) {
           try {
    +        server.reset(new server::TNonblockingServer(processor, port));
    +        if (userEventBase) {
    +          server->registerEvents(userEventBase.get());
    +        }
             server->serve();
    -      } catch (const TException&) {
    -        error = true;
    +      } catch (const transport::TTransportException&) {
    +        if (retry_count > 0) {
    +          ++port;
    +          startServer(retry_count - 1);
    +        } else {
    +          throw;
    --- End diff --
    
    It's a test failure so my intention here was "no need to catch" and let it 
die with std::terminate with exception log.
    The original `error` flag was needed for retrying from the main thread.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to