[
https://issues.apache.org/jira/browse/THRIFT-3814?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15273433#comment-15273433
]
ASF GitHub Bot commented on THRIFT-3814:
----------------------------------------
Github user tpcwang commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1005#discussion_r62278341
--- 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 --
Seems bad to throw an unhandled exception from a thread, but maybe this is
catastrophic and rare enough that this is fine? The rest of the change looks
good to me.
> Fix contention in TNonblockingServerTest
> ----------------------------------------
>
> Key: THRIFT-3814
> URL: https://issues.apache.org/jira/browse/THRIFT-3814
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library, Test Suite
> Reporter: Aki Sukegawa
> Assignee: Aki Sukegawa
> Labels: test-stability
>
> User provided event_base could possibly be deleted before the server.
> Hopefully this fixes the occasional failure on Travis-CI.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)