diff options
author | Mark Spruiell <mes@zeroc.com> | 2017-02-09 16:31:31 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2017-02-09 16:31:31 -0800 |
commit | af409fe78bdca7db6315ab0cc99ad063f8daecf7 (patch) | |
tree | b0079f556247a14f43e77ca6a31cb42df019485b | |
parent | Fixed enum-related warnings (diff) | |
download | ice-af409fe78bdca7db6315ab0cc99ad063f8daecf7.tar.bz2 ice-af409fe78bdca7db6315ab0cc99ad063f8daecf7.tar.xz ice-af409fe78bdca7db6315ab0cc99ad063f8daecf7.zip |
ICE-7560 - more AMI test fixes, renaming ConnectionClose enumerators
113 files changed, 953 insertions, 718 deletions
diff --git a/cpp/src/Glacier2/RoutingTable.cpp b/cpp/src/Glacier2/RoutingTable.cpp index e6b090de4cb..feb329e61b6 100644 --- a/cpp/src/Glacier2/RoutingTable.cpp +++ b/cpp/src/Glacier2/RoutingTable.cpp @@ -65,7 +65,7 @@ Glacier2::RoutingTable::add(const ObjectProxySeq& unfiltered, const Current& cur if(!_verifier->verify(*prx)) { - current.con->close(CloseForcefully); + current.con->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); throw ObjectNotExistException(__FILE__, __LINE__); } ObjectPrx proxy = (*prx)->ice_twoway()->ice_secure(false)->ice_facet(""); // We add proxies in default form. diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp index 512d371611f..daed57a99d1 100644 --- a/cpp/src/Glacier2/SessionRouterI.cpp +++ b/cpp/src/Glacier2/SessionRouterI.cpp @@ -80,7 +80,7 @@ public: // Close the connection otherwise the peer has no way to know that // the session has gone. // - _connection->close(CloseForcefully); + _connection->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); _router->destroySession(_connection); } } @@ -922,7 +922,7 @@ SessionRouterI::refreshSession(const Ice::ConnectionPtr& con) // Close the connection otherwise the peer has no way to know that the // session has gone. // - con->close(CloseForcefully); + con->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); throw SessionNotExistException(); } } @@ -1152,7 +1152,7 @@ SessionRouterI::getRouterImpl(const ConnectionPtr& connection, const Ice::Identi out << "rejecting request, no session is associated with the connection.\n"; out << "identity: " << identityToString(id); } - connection->close(CloseForcefully); + connection->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); throw ObjectNotExistException(__FILE__, __LINE__); } return 0; diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 223326203d1..1341cc44e5b 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -498,17 +498,17 @@ Ice::ConnectionI::close(ConnectionClose mode) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if(mode == ICE_ENUM(ConnectionClose, CloseForcefully)) + if(mode == ICE_SCOPED_ENUM(ConnectionClose, Forcefully)) { setState(StateClosed, ConnectionManuallyClosedException(__FILE__, __LINE__, false)); } - else if(mode == ICE_ENUM(ConnectionClose, CloseGracefully)) + else if(mode == ICE_SCOPED_ENUM(ConnectionClose, Gracefully)) { setState(StateClosing, ConnectionManuallyClosedException(__FILE__, __LINE__, true)); } else { - assert(mode == ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + assert(mode == ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); // // Wait until all outstanding requests have been completed. diff --git a/cpp/src/IceBridge/IceBridge.cpp b/cpp/src/IceBridge/IceBridge.cpp index 31ec58aae6c..f3f520cf678 100644 --- a/cpp/src/IceBridge/IceBridge.cpp +++ b/cpp/src/IceBridge/IceBridge.cpp @@ -167,7 +167,7 @@ public: // The incoming connection is already closed. There's no point in leaving the outgoing // connection open. // - outgoing->close(CloseGracefully); + outgoing->close(ICE_SCOPED_ENUM(ConnectionClose, Gracefully)); } else { @@ -206,7 +206,7 @@ public: // if(_incoming) { - _incoming->close(CloseGracefully); + _incoming->close(ICE_SCOPED_ENUM(ConnectionClose, Gracefully)); } } } @@ -258,18 +258,19 @@ public: } catch(const Ice::CloseConnectionException&) { - toBeClosed->close(CloseGracefully); + toBeClosed->close(ICE_SCOPED_ENUM(ConnectionClose, Gracefully)); } catch(const Ice::ConnectionManuallyClosedException& ex) { // // Connection was manually closed by the bridge. // - toBeClosed->close(ex.graceful ? CloseGracefully : CloseForcefully); + toBeClosed->close(ex.graceful ? ICE_SCOPED_ENUM(ConnectionClose, Gracefully) : + ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); } catch(...) { - toBeClosed->close(CloseForcefully); + toBeClosed->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); } } diff --git a/cpp/src/IceGrid/SessionManager.cpp b/cpp/src/IceGrid/SessionManager.cpp index c9b371000ff..1aa2701574e 100644 --- a/cpp/src/IceGrid/SessionManager.cpp +++ b/cpp/src/IceGrid/SessionManager.cpp @@ -58,7 +58,7 @@ SessionManager::findAllQueryObjects(bool cached) { try { - connection->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + connection->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } catch(const Ice::LocalException&) { diff --git a/cpp/test/Ice/ami/AllTests.cpp b/cpp/test/Ice/ami/AllTests.cpp index 1bea36d06d0..ba49a3ec662 100644 --- a/cpp/test/Ice/ami/AllTests.cpp +++ b/cpp/test/Ice/ami/AllTests.cpp @@ -1865,7 +1865,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) test(p->opBatchCount() == 0); auto b1 = p->ice_batchOneway(); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); auto id = this_thread::get_id(); promise<void> promise; @@ -1941,7 +1941,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) auto b1 = Ice::uncheckedCast<Test::TestIntfPrx>( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); promise<void> promise; b1->ice_getConnection()->flushBatchRequestsAsync( @@ -2021,7 +2021,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) auto b1 = Ice::uncheckedCast<Test::TestIntfPrx>( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); promise<void> promise; auto id = this_thread::get_id(); @@ -2093,8 +2093,8 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b2->ice_getConnection(); // Ensure connection is established. b1->opBatch(); b2->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); - b2->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); + b2->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); promise<void> promise; auto id = this_thread::get_id(); @@ -2181,35 +2181,31 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) } cout << "ok" << endl; - if(p->ice_getConnection() && protocol != "bt") + if(p->ice_getConnection() && protocol != "bt" && p->supportsAMD()) { cout << "testing graceful close connection with wait... " << flush; { // - // Local case: begin several requests, close the connection gracefully, and make sure it waits - // for the requests to complete. + // Local case: begin a request, close the connection gracefully, and make sure it waits + // for the request to complete. // - vector<future<void>> results; - for(int i = 0; i < 3; ++i) - { - auto s = make_shared<promise<void>>(); - p->sleepAsync(50, - [s]() { s->set_value(); }, - [s](exception_ptr ex) { s->set_exception(ex); }); - results.push_back(s->get_future()); - } - p->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); - for(vector<future<void>>::iterator p = results.begin(); p != results.end(); ++p) - { - try - { - p->get(); - } - catch(const Ice::LocalException&) + auto con = p->ice_getConnection(); + auto sc = make_shared<promise<void>>(); + con->setCloseCallback( + [sc](Ice::ConnectionPtr connection) { - test(false); - } - } + sc->set_value(); + }); + auto fc = sc->get_future(); + auto s = make_shared<promise<void>>(); + p->sleepAsync(100, + [s]() { s->set_value(); }, + [s](exception_ptr ex) { s->set_exception(ex); }); + auto f = s->get_future(); + // Blocks until the request completes. + con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); + f.get(); // Should complete successfully. + fc.get(); } { // @@ -2222,10 +2218,11 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) *q = static_cast<Ice::Byte>(IceUtilInternal::random(255)); } - + // // Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod. // The goal is to make sure that none of the opWithPayload fail even if the server closes // the connection gracefully in between. + // int maxQueue = 2; bool done = false; @@ -2243,7 +2240,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) results.push_back(s->get_future()); } atomic_flag sent = ATOMIC_FLAG_INIT; - p->closeAsync(Test::CloseMode::CloseGracefullyAndWait, nullptr, nullptr, + p->closeAsync(Test::CloseMode::GracefullyWithWait, nullptr, nullptr, [&sent](bool) { sent.test_and_set(); }); if(!sent.test_and_set()) { @@ -2288,21 +2285,20 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cout << "testing graceful close connection without wait... " << flush; { // - // Local case: start a lengthy operation and then close the connection gracefully on the client side + // Local case: start an operation and then close the connection gracefully on the client side // without waiting for the pending invocation to complete. There will be no retry and we expect the // invocation to fail with ConnectionManuallyClosedException. // - // This test requires two threads in the server's thread pool: one will block in sleep() and the other - // will process the CloseConnection message. - // - p->ice_ping(); + p = p->ice_connectionId("CloseGracefully"); // Start with a new connection. auto con = p->ice_getConnection(); auto s = make_shared<promise<void>>(); - p->sleepAsync(100, - [s]() { s->set_value(); }, - [s](exception_ptr ex) { s->set_exception(ex); }); - future<void> f = s->get_future(); - con->close(Ice::ConnectionClose::CloseGracefully); + auto sent = make_shared<promise<void>>(); + p->startDispatchAsync([s]() { s->set_value(); }, + [s](exception_ptr ex) { s->set_exception(ex); }, + [sent](bool ss) { sent->set_value(); }); + auto f = s->get_future(); + sent->get_future().get(); // Ensure the request was sent before we close the connection. + con->close(Ice::ConnectionClose::Gracefully); try { f.get(); @@ -2312,14 +2308,12 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { test(ex.graceful); } + p->finishDispatch(); // - // Remote case: the server closes the connection gracefully. Our call to TestIntf::close() - // completes successfully and then the connection should be closed immediately afterward, - // despite the fact that there's a pending call to sleep(). The call to sleep() should be - // automatically retried and complete successfully with a new connection. + // Remote case: the server closes the connection gracefully, which means the connection + // will not be closed until all pending dispatched requests have completed. // - p->ice_ping(); con = p->ice_getConnection(); auto sc = make_shared<promise<void>>(); con->setCloseCallback( @@ -2327,14 +2321,14 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { sc->set_value(); }); - future<void> fc = sc->get_future(); + auto fc = sc->get_future(); s = make_shared<promise<void>>(); p->sleepAsync(100, [s]() { s->set_value(); }, [s](exception_ptr ex) { s->set_exception(ex); }); f = s->get_future(); - p->close(Test::CloseMode::CloseGracefully); - fc.get(); + p->close(Test::CloseMode::Gracefully); // Close is delayed until sleep completes. + fc.get(); // Ensure connection was closed. try { f.get(); @@ -2343,8 +2337,6 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { test(false); } - p->ice_ping(); - test(p->ice_getConnection() != con); } cout << "ok" << endl; @@ -2357,11 +2349,13 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) p->ice_ping(); auto con = p->ice_getConnection(); auto s = make_shared<promise<void>>(); - p->sleepAsync(100, - [s]() { s->set_value(); }, - [s](exception_ptr ex) { s->set_exception(ex); }); - future<void> f = s->get_future(); - con->close(Ice::ConnectionClose::CloseForcefully); + auto sent = make_shared<promise<void>>(); + p->startDispatchAsync([s]() { s->set_value(); }, + [s](exception_ptr ex) { s->set_exception(ex); }, + [sent](bool ss) { sent->set_value(); }); + auto f = s->get_future(); + sent->get_future().get(); // Ensure the request was sent before we close the connection. + con->close(Ice::ConnectionClose::Forcefully); try { f.get(); @@ -2371,6 +2365,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { test(!ex.graceful); } + p->finishDispatch(); // // Remote case: the server closes the connection forcefully. This causes the request to fail @@ -2379,7 +2374,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // try { - p->close(Test::CloseMode::CloseForcefully); + p->close(Test::CloseMode::Forcefully); test(false); } catch(const Ice::ConnectionLostException&) @@ -3100,7 +3095,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) test(p->opBatchCount() == 0); Test::TestIntfPrx b1 = p->ice_batchOneway(); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); Ice::AsyncResultPtr r = b1->begin_ice_flushBatchRequests( Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync)); @@ -3118,7 +3113,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) test(p->opBatchCount() == 0); Test::TestIntfPrx b1 = p->ice_batchOneway(); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(cookie); b1->begin_ice_flushBatchRequests( Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync), cookie); @@ -3169,7 +3164,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) test(p->opBatchCount() == 0); Test::TestIntfPrx b1 = p->ice_batchOneway(); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); Ice::AsyncResultPtr r = b1->begin_ice_flushBatchRequests( Ice::newCallback_Object_ice_flushBatchRequests(cb, &FlushCallback::exception, @@ -3187,7 +3182,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) test(p->opBatchCount() == 0); Test::TestIntfPrx b1 = p->ice_batchOneway(); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(cookie); b1->begin_ice_flushBatchRequests( Ice::newCallback_Object_ice_flushBatchRequests(cb, &FlushCallback::exceptionWC, @@ -3215,7 +3210,8 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b1->opBatch(); b1->opBatch(); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync)); cb->check(); test(r->isSent()); @@ -3256,9 +3252,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushExCallbackPtr cb = new FlushExCallback(); - Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushExCallback::completedAsync, &FlushExCallback::sentAsync)); cb->check(); test(!r->isSent()); @@ -3275,7 +3272,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushExCallbackPtr cb = new FlushExCallback(cookie); b1->ice_getConnection()->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushExCallback::completedAsync, &FlushExCallback::sentAsync), cookie); @@ -3293,8 +3290,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b1->opBatch(); b1->opBatch(); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), - Ice::newCallback_Connection_flushBatchRequests(cb, &FlushCallback::exception, &FlushCallback::sent)); + Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::newCallback_Connection_flushBatchRequests(cb, &FlushCallback::exception, + &FlushCallback::sent)); cb->check(); test(r->isSent()); test(r->isCompleted()); @@ -3327,9 +3326,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushExCallbackPtr cb = new FlushExCallback(); - Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Connection_flushBatchRequests(cb, &FlushExCallback::exception, &FlushExCallback::sent)); cb->check(); @@ -3347,7 +3347,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushExCallbackPtr cb = new FlushExCallback(cookie); b1->ice_getConnection()->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Connection_flushBatchRequests(cb, &FlushExCallback::exceptionWC, @@ -3372,7 +3372,8 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b1->opBatch(); b1->opBatch(); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync)); cb->check(); test(r->isSent()); @@ -3405,9 +3406,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync)); cb->check(); test(r->isSent()); // Exceptions are ignored! @@ -3424,7 +3426,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(cookie); communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync), cookie); @@ -3449,7 +3451,8 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b2->opBatch(); b2->opBatch(); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync)); cb->check(); test(r->isSent()); @@ -3475,9 +3478,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b2->ice_getConnection(); // Ensure connection is established. b1->opBatch(); b2->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync)); cb->check(); test(r->isSent()); // Exceptions are ignored! @@ -3502,10 +3506,11 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b2->ice_getConnection(); // Ensure connection is established. b1->opBatch(); b2->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); - b2->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); + b2->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback(cb, &FlushCallback::completedAsync, &FlushCallback::sentAsync)); cb->check(); test(r->isSent()); // Exceptions are ignored! @@ -3523,7 +3528,8 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b1->opBatch(); b1->opBatch(); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Communicator_flushBatchRequests(cb, &FlushCallback::exception, &FlushCallback::sent)); cb->check(); @@ -3558,9 +3564,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Communicator_flushBatchRequests(cb, &FlushCallback::exception, &FlushCallback::sent)); cb->check(); @@ -3578,7 +3585,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Test::TestIntfPrx b1 = Test::TestIntfPrx::uncheckedCast( p->ice_getConnection()->createProxy(p->ice_getIdentity())->ice_batchOneway()); b1->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(cookie); communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Communicator_flushBatchRequests(cb, &FlushCallback::exceptionWC, @@ -3605,7 +3612,8 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b2->opBatch(); b2->opBatch(); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Communicator_flushBatchRequests(cb, &FlushCallback::exception, &FlushCallback::sent)); cb->check(); @@ -3632,9 +3640,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b2->ice_getConnection(); // Ensure connection is established. b1->opBatch(); b2->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Communicator_flushBatchRequests(cb, &FlushCallback::exception, &FlushCallback::sent)); cb->check(); @@ -3660,10 +3669,11 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) b2->ice_getConnection(); // Ensure connection is established. b1->opBatch(); b2->opBatch(); - b1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); - b2->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + b1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); + b2->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); FlushCallbackPtr cb = new FlushCallback(); - Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests(Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + Ice::ICE_SCOPED_ENUM(CompressBatch, BasedOnProxy), Ice::newCallback_Communicator_flushBatchRequests(cb, &FlushCallback::exception, &FlushCallback::sent)); cb->check(); @@ -3874,27 +3884,25 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cout << "testing graceful close connection with wait... " << flush; { // - // Local case: begin several requests, close the connection gracefully, and make sure it waits - // for the requests to complete. + // Local case: begin a request, close the connection gracefully, and make sure it waits + // for the request to complete. // - vector<Ice::AsyncResultPtr> results; - for(int i = 0; i < 3; ++i) + Ice::ConnectionPtr con = p->ice_getConnection(); + CloseCallbackPtr cb = new CloseCallback; + con->setCloseCallback(cb); + Ice::AsyncResultPtr r = p->begin_sleep(100); + // Blocks until the request completes. + con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); + r->waitForCompleted(); // Should complete successfully. + try { - results.push_back(p->begin_sleep(50)); + r->throwLocalException(); } - p->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); - for(vector<Ice::AsyncResultPtr>::const_iterator q = results.begin(); q != results.end(); ++q) + catch(const Ice::LocalException&) { - (*q)->waitForCompleted(); - try - { - (*q)->throwLocalException(); - } - catch(const Ice::LocalException&) - { - test(false); - } + test(false); } + cb->check(); } { // @@ -3923,7 +3931,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { results.push_back(p->begin_opWithPayload(seq)); } - if(!p->begin_close(Test::CloseGracefullyAndWait)->isSent()) + if(!p->begin_close(Test::GracefullyWithWait)->isSent()) { for(int i = 0; i < maxQueue; i++) { @@ -3962,17 +3970,15 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cout << "testing graceful close connection without wait... " << flush; { // - // Local case: start a lengthy operation and then close the connection gracefully on the client side + // Local case: start an operation and then close the connection gracefully on the client side // without waiting for the pending invocation to complete. There will be no retry and we expect the // invocation to fail with ConnectionManuallyClosedException. // - // This test requires two threads in the server's thread pool: one will block in sleep() and the other - // will process the CloseConnection message. - // - p->ice_ping(); + p = p->ice_connectionId("CloseGracefully"); // Start with a new connection. Ice::ConnectionPtr con = p->ice_getConnection(); - Ice::AsyncResultPtr r = p->begin_sleep(100); - con->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefully)); + Ice::AsyncResultPtr r = p->begin_startDispatch(); + r->waitForSent(); // Ensure the request was sent before we close the connection. + con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Gracefully)); r->waitForCompleted(); try { @@ -3983,20 +3989,18 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { test(ex.graceful); } + p->finishDispatch(); // - // Remote case: the server closes the connection gracefully. Our call to TestIntf::close() - // completes successfully and then the connection should be closed immediately afterward, - // despite the fact that there's a pending call to sleep(). The call to sleep() should be - // automatically retried and complete successfully. + // Remote case: the server closes the connection gracefully, which means the connection + // will not be closed until all pending dispatched requests have completed. // - p->ice_ping(); con = p->ice_getConnection(); CloseCallbackPtr cb = new CloseCallback; con->setCloseCallback(cb); r = p->begin_sleep(100); - p->close(Test::CloseGracefully); - cb->check(); + p->close(Test::Gracefully); // Close is delayed until sleep completes. + cb->check(); // Ensure connection was closed. r->waitForCompleted(); try { @@ -4006,21 +4010,20 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { test(false); } - p->ice_ping(); - test(p->ice_getConnection() != con); } cout << "ok" << endl; cout << "testing forceful close connection... " << flush; { // - // Local case: start a lengthy operation and then close the connection forcefully on the client side. + // Local case: start an operation and then close the connection forcefully on the client side. // There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. // p->ice_ping(); Ice::ConnectionPtr con = p->ice_getConnection(); - Ice::AsyncResultPtr r = p->begin_sleep(100); - con->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + Ice::AsyncResultPtr r = p->begin_startDispatch(); + r->waitForSent(); // Ensure the request was sent before we close the connection. + con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); r->waitForCompleted(); try { @@ -4031,6 +4034,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { test(!ex.graceful); } + p->finishDispatch(); // // Remote case: the server closes the connection forcefully. This causes the request to fail @@ -4039,7 +4043,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // try { - p->close(Test::CloseForcefully); + p->close(Test::Forcefully); test(false); } catch(const Ice::ConnectionLostException&) diff --git a/cpp/test/Ice/ami/Test.ice b/cpp/test/Ice/ami/Test.ice index 1e889d89149..7cc9091d806 100644 --- a/cpp/test/Ice/ami/Test.ice +++ b/cpp/test/Ice/ami/Test.ice @@ -20,9 +20,9 @@ exception TestIntfException enum CloseMode { - CloseForcefully, - CloseGracefully, - CloseGracefullyAndWait + Forcefully, + Gracefully, + GracefullyWithWait }; interface TestIntf @@ -42,8 +42,11 @@ interface TestIntf bool waitForBatch(int count); void close(CloseMode mode); void sleep(int ms); + ["amd"] void startDispatch(); + void finishDispatch(); void shutdown(); + bool supportsAMD(); bool supportsFunctionalTests(); }; diff --git a/cpp/test/Ice/ami/TestI.cpp b/cpp/test/Ice/ami/TestI.cpp index d7aa1d44762..b52678a590e 100644 --- a/cpp/test/Ice/ami/TestI.cpp +++ b/cpp/test/Ice/ami/TestI.cpp @@ -105,13 +105,69 @@ TestIntfI::sleep(Ice::Int ms, const Ice::Current& current) timedWait(IceUtil::Time::milliSeconds(ms)); } +#ifdef ICE_CPP11_MAPPING +void +TestIntfI::startDispatchAsync(std::function<void()> response, std::function<void(std::exception_ptr)> ex, + const Ice::Current&) +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + _pending.push_back(move(response)); +} +#else +void +TestIntfI::startDispatch_async(const Test::AMD_TestIntf_startDispatchPtr& cb, const Ice::Current&) +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + _pending.push_back(cb); +} +#endif + +void +TestIntfI::finishDispatch(const Ice::Current& current) +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); +#ifdef ICE_CPP11_MAPPING + for(vector<function<void()>>::iterator p = _pending.begin(); p != _pending.end(); ++p) + { + (*p)(); + } +#else + for(vector<Test::AMD_TestIntf_startDispatchPtr>::iterator p = _pending.begin(); p != _pending.end(); ++p) + { + (*p)->ice_response(); + } +#endif + _pending.clear(); +} + void TestIntfI::shutdown(const Ice::Current& current) { + // + // Just in case a request arrived late. + // + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); +#ifdef ICE_CPP11_MAPPING + for(vector<function<void()>>::iterator p = _pending.begin(); p != _pending.end(); ++p) + { + (*p)(); + } +#else + for(vector<Test::AMD_TestIntf_startDispatchPtr>::iterator p = _pending.begin(); p != _pending.end(); ++p) + { + (*p)->ice_response(); + } +#endif current.adapter->getCommunicator()->shutdown(); } bool +TestIntfI::supportsAMD(const Ice::Current&) +{ + return true; +} + +bool TestIntfI::supportsFunctionalTests(const Ice::Current&) { return false; @@ -132,4 +188,3 @@ TestIntfControllerI::resumeAdapter(const Ice::Current&) TestIntfControllerI::TestIntfControllerI(const Ice::ObjectAdapterPtr& adapter) : _adapter(adapter) { } - diff --git a/cpp/test/Ice/ami/TestI.h b/cpp/test/Ice/ami/TestI.h index edde85f6008..c839cafb551 100644 --- a/cpp/test/Ice/ami/TestI.h +++ b/cpp/test/Ice/ami/TestI.h @@ -34,20 +34,32 @@ public: virtual bool waitForBatch(Ice::Int, const Ice::Current&); virtual void close(Test::CloseMode, const Ice::Current&); virtual void sleep(Ice::Int, const Ice::Current&); +#ifdef ICE_CPP11_MAPPING + virtual void startDispatchAsync(std::function<void()>, std::function<void(std::exception_ptr)>, + const Ice::Current&); +#else + virtual void startDispatch_async(const Test::AMD_TestIntf_startDispatchPtr&, const Ice::Current&); +#endif + virtual void finishDispatch(const Ice::Current&); virtual void shutdown(const Ice::Current&); + virtual bool supportsAMD(const Ice::Current&); virtual bool supportsFunctionalTests(const Ice::Current&); private: int _batchCount; +#ifdef ICE_CPP11_MAPPING + std::vector<std::function<void()>> _pending; +#else + std::vector<Test::AMD_TestIntf_startDispatchPtr> _pending; +#endif }; class TestIntfControllerI : public Test::TestIntfController, IceUtil::Monitor<IceUtil::Mutex> { public: - virtual void holdAdapter(const Ice::Current&); virtual void resumeAdapter(const Ice::Current&); diff --git a/cpp/test/Ice/background/AllTests.cpp b/cpp/test/Ice/background/AllTests.cpp index 5654d66ec02..7d5854eead8 100644 --- a/cpp/test/Ice/background/AllTests.cpp +++ b/cpp/test/Ice/background/AllTests.cpp @@ -379,7 +379,7 @@ allTests(const Ice::CommunicatorPtr& communicator) #ifdef ICE_CPP11_MAPPING background->opAsync(); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); background->opAsync(); vector<future<void>> results; @@ -407,7 +407,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } #else background->begin_op(); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); background->begin_op(); vector<Ice::AsyncResultPtr> results; @@ -452,7 +452,7 @@ connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrxPtr { test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); int i; for(i = 0; i < 4; ++i) @@ -560,7 +560,7 @@ connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrxPtr } configuration->connectException(new Ice::SocketException(__FILE__, __LINE__)); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); configuration->connectException(0); try @@ -592,7 +592,7 @@ initializeTests(const ConfigurationPtr& configuration, { test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); int i; for(i = 0; i < 4; i++) @@ -682,7 +682,7 @@ initializeTests(const ConfigurationPtr& configuration, cerr << ex << endl; test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); try { @@ -695,7 +695,7 @@ initializeTests(const ConfigurationPtr& configuration, cerr << ex << endl; test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); #endif // @@ -728,7 +728,7 @@ initializeTests(const ConfigurationPtr& configuration, { test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); try { @@ -764,7 +764,7 @@ initializeTests(const ConfigurationPtr& configuration, } configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); configuration->initializeException(0); try @@ -784,12 +784,12 @@ initializeTests(const ConfigurationPtr& configuration, } configuration->initializeSocketOperation(IceInternal::SocketOperationWrite); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); background->ice_ping(); configuration->initializeSocketOperation(IceInternal::SocketOperationNone); ctl->initializeException(true); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); ctl->initializeException(false); try @@ -812,11 +812,11 @@ initializeTests(const ConfigurationPtr& configuration, { #if !defined(ICE_USE_IOCP) && !defined(ICE_USE_CFSTREAM) ctl->initializeSocketOperation(IceInternal::SocketOperationWrite); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); background->op(); ctl->initializeSocketOperation(IceInternal::SocketOperationNone); #else - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); background->op(); #endif } @@ -847,7 +847,7 @@ validationTests(const ConfigurationPtr& configuration, { test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); try { @@ -921,7 +921,7 @@ validationTests(const ConfigurationPtr& configuration, cerr << ex << endl; test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); try { @@ -1081,7 +1081,7 @@ validationTests(const ConfigurationPtr& configuration, cerr << ex << endl; test(false); } - background->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + background->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); try { @@ -1163,7 +1163,7 @@ validationTests(const ConfigurationPtr& configuration, #else backgroundBatchOneway->begin_ice_flushBatchRequests(); #endif - backgroundBatchOneway->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + backgroundBatchOneway->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); ctl->holdAdapter(); backgroundBatchOneway->opWithPayload(seq); @@ -1183,10 +1183,10 @@ validationTests(const ConfigurationPtr& configuration, // in the flush to report a CloseConnectionException). Instead we // wait for the first flush to complete. // - //backgroundBatchOneway->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + //backgroundBatchOneway->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); backgroundBatchOneway->end_ice_flushBatchRequests(r); #endif - backgroundBatchOneway->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + backgroundBatchOneway->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } void @@ -1775,10 +1775,10 @@ readWriteTests(const ConfigurationPtr& configuration, IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); background->ice_ping(); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); - background->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + background->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); } thread1->destroy(); diff --git a/cpp/test/Ice/binding/AllTests.cpp b/cpp/test/Ice/binding/AllTests.cpp index 511d186a205..4a07f3675d3 100644 --- a/cpp/test/Ice/binding/AllTests.cpp +++ b/cpp/test/Ice/binding/AllTests.cpp @@ -170,7 +170,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(test2->ice_getConnection() == test3->ice_getConnection()); names.erase(test1->getAdapterName()); - test1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } // @@ -192,7 +192,8 @@ allTests(const Ice::CommunicatorPtr& communicator) for(vector<RemoteObjectAdapterPrxPtr>::const_iterator q = adapters.begin(); q != adapters.end(); ++q) { - (*q)->getTestIntf()->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + (*q)->getTestIntf()->ice_getConnection()->close( + Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } } @@ -217,7 +218,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(test2->ice_getConnection() == test3->ice_getConnection()); names.erase(test1->getAdapterName()); - test1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } // @@ -314,7 +315,8 @@ allTests(const Ice::CommunicatorPtr& communicator) { try { - (*q)->getTestIntf()->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + (*q)->getTestIntf()->ice_getConnection()->close( + Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } catch(const Ice::LocalException&) { @@ -354,7 +356,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(test2->ice_getConnection() == test3->ice_getConnection()); names.erase(getAdapterNameWithAMI(test1)); - test1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } // @@ -376,7 +378,8 @@ allTests(const Ice::CommunicatorPtr& communicator) for(vector<RemoteObjectAdapterPrxPtr>::const_iterator q = adapters.begin(); q != adapters.end(); ++q) { - (*q)->getTestIntf()->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + (*q)->getTestIntf()->ice_getConnection()->close( + Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } } @@ -401,7 +404,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(test2->ice_getConnection() == test3->ice_getConnection()); names.erase(test1->getAdapterName()); - test1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } // @@ -433,7 +436,7 @@ allTests(const Ice::CommunicatorPtr& communicator) while(!names.empty()) { names.erase(test->getAdapterName()); - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } test = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random))); @@ -445,7 +448,7 @@ allTests(const Ice::CommunicatorPtr& communicator) while(!names.empty()) { names.erase(test->getAdapterName()); - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } deactivate(com, adapters); @@ -473,7 +476,7 @@ allTests(const Ice::CommunicatorPtr& communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter31"; i++); } #endif @@ -483,7 +486,7 @@ allTests(const Ice::CommunicatorPtr& communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter32"; i++); } #endif @@ -493,7 +496,7 @@ allTests(const Ice::CommunicatorPtr& communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter33"; i++); } #endif @@ -525,29 +528,29 @@ allTests(const Ice::CommunicatorPtr& communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter36"; i++); } #endif test(i == nRetry); - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); adapters.push_back(com->createObjectAdapter("Adapter35", endpoints[1]->toString())); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter35"; i++); #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter35"; i++); } #endif test(i == nRetry); - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); adapters.push_back(com->createObjectAdapter("Adapter34", endpoints[0]->toString())); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter34"; i++); #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); for(i = 0; i < nRetry && test->getAdapterName() == "Adapter34"; i++); } #endif @@ -865,7 +868,7 @@ allTests(const Ice::CommunicatorPtr& communicator) for(i = 0; i < 5; i++) { test(test->getAdapterName() == "Adapter82"); - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } TestIntfPrxPtr testSecure = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_secure(true)); @@ -881,7 +884,7 @@ allTests(const Ice::CommunicatorPtr& communicator) for(i = 0; i < 5; i++) { test(test->getAdapterName() == "Adapter81"); - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } com->createObjectAdapter("Adapter83", (test->ice_getEndpoints()[1])->toString()); // Reactive tcp OA. @@ -889,7 +892,7 @@ allTests(const Ice::CommunicatorPtr& communicator) for(i = 0; i < 5; i++) { test(test->getAdapterName() == "Adapter83"); - test->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } com->deactivateObjectAdapter(adapters[0]); @@ -1098,7 +1101,8 @@ allTests(const Ice::CommunicatorPtr& communicator) // Close the connection now to free a FD (it could be done after the sleep but // there could be race condiutation since the connection might not be closed // immediately due to threading). - test->ice_connectionId("0")->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + test->ice_connectionId("0")->ice_getConnection()->close( + Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); // // The server closed the acceptor, wait one second and retry after freeing a FD. diff --git a/cpp/test/Ice/hold/AllTests.cpp b/cpp/test/Ice/hold/AllTests.cpp index 36e65746c86..72275674797 100644 --- a/cpp/test/Ice/hold/AllTests.cpp +++ b/cpp/test/Ice/hold/AllTests.cpp @@ -290,7 +290,7 @@ allTests(const Ice::CommunicatorPtr& communicator) { completed->get_future().get(); holdSerialized->ice_ping(); // Ensure everything's dispatched - holdSerialized->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + holdSerialized->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } } completed->get_future().get(); @@ -305,7 +305,7 @@ allTests(const Ice::CommunicatorPtr& communicator) { result->waitForSent(); holdSerialized->ice_ping(); // Ensure everything's dispatched - holdSerialized->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + holdSerialized->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } } result->waitForCompleted(); diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp index f87e2c32d0e..5145a13a7e9 100644 --- a/cpp/test/Ice/location/AllTests.cpp +++ b/cpp/test/Ice/location/AllTests.cpp @@ -637,7 +637,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) cout << "testing object migration... " << flush; hello = ICE_CHECKED_CAST(HelloPrx, communicator->stringToProxy("hello")); obj->migrateHello(); - hello->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + hello->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); hello->sayHello(); obj->migrateHello(); hello->sayHello(); diff --git a/cpp/test/Ice/metrics/AllTests.cpp b/cpp/test/Ice/metrics/AllTests.cpp index d5933489ea8..fbd29160cd4 100644 --- a/cpp/test/Ice/metrics/AllTests.cpp +++ b/cpp/test/Ice/metrics/AllTests.cpp @@ -287,7 +287,7 @@ struct Connect { if(proxy->ice_getCachedConnection()) { - proxy->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + proxy->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } try { @@ -298,7 +298,7 @@ struct Connect } if(proxy->ice_getCachedConnection()) { - proxy->ice_getCachedConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + proxy->ice_getCachedConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } } @@ -534,8 +534,9 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt if(!collocated) { - metrics->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); - metrics->ice_connectionId("Con1")->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + metrics->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); + metrics->ice_connectionId("Con1")->ice_getConnection()->close( + Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -645,7 +646,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt map = toMap(serverMetrics->getMetricsView("View", timestamp)["Connection"]); test(map["holding"]->current == 1); - metrics->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + metrics->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); map = toMap(clientMetrics->getMetricsView("View", timestamp)["Connection"]); test(map["closing"]->current == 1); @@ -660,7 +661,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "none"; updateProps(clientProps, serverProps, update.get(), props, "Connection"); - metrics->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + metrics->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); metrics->ice_timeout(500)->ice_ping(); controller->hold(); @@ -717,7 +718,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt testAttribute(clientMetrics, clientProps, update.get(), "Connection", "mcastHost", ""); testAttribute(clientMetrics, clientProps, update.get(), "Connection", "mcastPort", ""); - m->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + m->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -736,7 +737,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt IceMX::MetricsPtr m1 = clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"][0]; test(m1->current == 0 && m1->total == 1 && m1->id == hostAndPort); - metrics->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + metrics->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); controller->hold(); try { @@ -788,7 +789,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt try { prx->ice_ping(); - prx->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + prx->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); } catch(const Ice::LocalException&) { diff --git a/cpp/test/Ice/metrics/TestAMDI.cpp b/cpp/test/Ice/metrics/TestAMDI.cpp index 37c8b310e0a..57ae9e1fb2e 100644 --- a/cpp/test/Ice/metrics/TestAMDI.cpp +++ b/cpp/test/Ice/metrics/TestAMDI.cpp @@ -22,7 +22,7 @@ MetricsI::opAsync(function<void()> response, function<void(exception_ptr)>, cons void MetricsI::failAsync(function<void()> response, function<void(exception_ptr)>, const Ice::Current& current) { - current.con->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + current.con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); response(); } @@ -87,7 +87,7 @@ MetricsI::op_async(const Test::AMD_Metrics_opPtr& cb, const Ice::Current&) void MetricsI::fail_async(const Test::AMD_Metrics_failPtr& cb, const Ice::Current& current) { - current.con->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + current.con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); cb->ice_response(); } diff --git a/cpp/test/Ice/metrics/TestI.cpp b/cpp/test/Ice/metrics/TestI.cpp index 739fc99d4ae..4d6102c03e1 100644 --- a/cpp/test/Ice/metrics/TestI.cpp +++ b/cpp/test/Ice/metrics/TestI.cpp @@ -18,7 +18,7 @@ MetricsI::op(const Ice::Current&) void MetricsI::fail(const Ice::Current& current) { - current.con->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + current.con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); } void diff --git a/cpp/test/Ice/operations/BatchOneways.cpp b/cpp/test/Ice/operations/BatchOneways.cpp index 47bcf2e87c0..2967a28e098 100644 --- a/cpp/test/Ice/operations/BatchOneways.cpp +++ b/cpp/test/Ice/operations/BatchOneways.cpp @@ -126,7 +126,7 @@ batchOneways(const Test::MyClassPrxPtr& p) batch1->ice_ping(); batch2->ice_ping(); batch1->ice_flushBatchRequests(); - batch1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); batch1->ice_ping(); batch2->ice_ping(); @@ -134,7 +134,7 @@ batchOneways(const Test::MyClassPrxPtr& p) batch2->ice_getConnection(); batch1->ice_ping(); - batch1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); batch1->ice_ping(); batch2->ice_ping(); } diff --git a/cpp/test/Ice/operations/BatchOnewaysAMI.cpp b/cpp/test/Ice/operations/BatchOnewaysAMI.cpp index 92984de8b33..9fab4caae79 100644 --- a/cpp/test/Ice/operations/BatchOnewaysAMI.cpp +++ b/cpp/test/Ice/operations/BatchOnewaysAMI.cpp @@ -127,7 +127,7 @@ batchOnewaysAMI(const Test::MyClassPrxPtr& p) batch1->ice_pingAsync().get(); batch2->ice_pingAsync().get(); batch1->ice_flushBatchRequestsAsync().get(); - batch1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); batch1->ice_pingAsync().get(); batch2->ice_pingAsync().get(); @@ -135,7 +135,7 @@ batchOnewaysAMI(const Test::MyClassPrxPtr& p) batch2->ice_getConnection(); batch1->ice_pingAsync().get(); - batch1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); batch1->ice_pingAsync().get(); batch2->ice_pingAsync().get(); @@ -182,7 +182,7 @@ batchOnewaysAMI(const Test::MyClassPrxPtr& p) batch1->end_ice_ping(batch1->begin_ice_ping()); batch2->end_ice_ping(batch2->begin_ice_ping()); batch1->end_ice_flushBatchRequests(batch1->begin_ice_flushBatchRequests()); - batch1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); batch1->end_ice_ping(batch1->begin_ice_ping()); batch2->end_ice_ping(batch2->begin_ice_ping()); @@ -190,7 +190,7 @@ batchOnewaysAMI(const Test::MyClassPrxPtr& p) batch2->ice_getConnection(); batch1->end_ice_ping(batch1->begin_ice_ping()); - batch1->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + batch1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); batch1->end_ice_ping(batch1->begin_ice_ping()); batch2->end_ice_ping(batch2->begin_ice_ping()); diff --git a/cpp/test/Ice/retry/TestI.cpp b/cpp/test/Ice/retry/TestI.cpp index 24a8d60cc6a..1b35edb81cd 100644 --- a/cpp/test/Ice/retry/TestI.cpp +++ b/cpp/test/Ice/retry/TestI.cpp @@ -22,7 +22,7 @@ RetryI::op(bool kill, const Ice::Current& current) { if(current.con) { - current.con->close(Ice::ICE_ENUM(ConnectionClose, CloseForcefully)); + current.con->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); } else { diff --git a/cpp/test/Ice/timeout/AllTests.cpp b/cpp/test/Ice/timeout/AllTests.cpp index 4c297bfe755..3ce32a52b99 100644 --- a/cpp/test/Ice/timeout/AllTests.cpp +++ b/cpp/test/Ice/timeout/AllTests.cpp @@ -294,7 +294,7 @@ allTests(const Ice::CommunicatorPtr& communicator) TimeoutPrxPtr to = ICE_CHECKED_CAST(TimeoutPrx, obj->ice_timeout(250)); Ice::ConnectionPtr connection = to->ice_getConnection(); timeout->holdAdapter(600); - connection->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + connection->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); try { connection->getInfo(); // getInfo() doesn't throw in the closing state. diff --git a/cpp/test/Ice/udp/AllTests.cpp b/cpp/test/Ice/udp/AllTests.cpp index c72145cfd89..c02c0d4d5f4 100644 --- a/cpp/test/Ice/udp/AllTests.cpp +++ b/cpp/test/Ice/udp/AllTests.cpp @@ -116,7 +116,7 @@ allTests(const CommunicatorPtr& communicator) { test(seq.size() > 16384); } - obj->ice_getConnection()->close(ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + obj->ice_getConnection()->close(ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); communicator->getProperties()->setProperty("Ice.UDP.SndSize", "64000"); seq.resize(50000); try diff --git a/cpp/test/IceSSL/configuration/AllTests.cpp b/cpp/test/IceSSL/configuration/AllTests.cpp index 6d4147ea6e9..c776202b261 100644 --- a/cpp/test/IceSSL/configuration/AllTests.cpp +++ b/cpp/test/IceSSL/configuration/AllTests.cpp @@ -1585,7 +1585,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12) // verifier->reset(); verifier->returnValue(false); - server->ice_getConnection()->close(Ice::ICE_ENUM(ConnectionClose, CloseGracefullyAndWait)); + server->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait)); try { server->ice_ping(); diff --git a/cpp/test/IceStorm/stress/Subscriber.cpp b/cpp/test/IceStorm/stress/Subscriber.cpp index 4722fe93caf..4a76a18e441 100644 --- a/cpp/test/IceStorm/stress/Subscriber.cpp +++ b/cpp/test/IceStorm/stress/Subscriber.cpp @@ -163,7 +163,7 @@ public: if(!_done && (IceUtilInternal::random(10) == 1 || ++_count == _total)) { _done = true; - current.con->close(CloseForcefully); + current.con->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); // Deactivate the OA. This ensures that the subscribers // that have subscribed with oneway QoS will be booted. current.adapter->deactivate(); diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index a1cbdde8fcf..cce7d863668 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -185,17 +185,17 @@ namespace Ice { lock(this) { - if(mode == ConnectionClose.CloseForcefully) + if(mode == ConnectionClose.Forcefully) { setState(StateClosed, new ConnectionManuallyClosedException(false)); } - else if(mode == ConnectionClose.CloseGracefully) + else if(mode == ConnectionClose.Gracefully) { setState(StateClosing, new ConnectionManuallyClosedException(true)); } else { - Debug.Assert(mode == ConnectionClose.CloseGracefullyAndWait); + Debug.Assert(mode == ConnectionClose.GracefullyWithWait); // // Wait until all outstanding requests have been completed. diff --git a/csharp/test/Ice/ami/AllTests.cs b/csharp/test/Ice/ami/AllTests.cs index d6f4f68e4d3..9b1c3f82508 100644 --- a/csharp/test/Ice/ami/AllTests.cs +++ b/csharp/test/Ice/ami/AllTests.cs @@ -1904,7 +1904,7 @@ public class AllTests : TestCommon.AllTests test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(cb.completedAsync, cookie); r.whenSent(cb.sentAsync); @@ -1940,7 +1940,7 @@ public class AllTests : TestCommon.AllTests test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted(cb.exception); @@ -1989,7 +1989,7 @@ public class AllTests : TestCommon.AllTests test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); System.Threading.Tasks.Task t = b1.ice_flushBatchRequestsAsync( progress:new Progress(sentSynchronously => @@ -2058,7 +2058,7 @@ public class AllTests : TestCommon.AllTests test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( (Ice.AsyncResult result) => @@ -2110,7 +2110,7 @@ public class AllTests : TestCommon.AllTests test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests(); r.whenCompleted( @@ -2167,7 +2167,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); Task t = b1.ice_getConnection().flushBatchRequestsAsync( Ice.CompressBatch.BasedOnProxy, progress: new Progress( @@ -2210,7 +2210,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2250,7 +2250,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted(cb.exception); @@ -2306,7 +2306,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushExCallback cb = new FlushExCallback(cookie); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2360,7 +2360,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted( @@ -2415,7 +2415,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); SentCallback cb = new SentCallback(); Task t = communicator.flushBatchRequestsAsync( Ice.CompressBatch.BasedOnProxy, @@ -2472,7 +2472,7 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); SentCallback cb = new SentCallback(); Task t = communicator.flushBatchRequestsAsync( Ice.CompressBatch.BasedOnProxy, @@ -2500,8 +2500,8 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); SentCallback cb = new SentCallback(); Task t = communicator.flushBatchRequestsAsync( Ice.CompressBatch.BasedOnProxy, @@ -2545,7 +2545,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.completedAsync, @@ -2598,7 +2598,7 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.completedAsync, @@ -2624,8 +2624,8 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.completedAsync, @@ -2664,7 +2664,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted(cb.exception); @@ -2714,7 +2714,7 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted(cb.exception); @@ -2739,8 +2739,8 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted(cb.exception); @@ -2793,7 +2793,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2859,7 +2859,7 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2892,8 +2892,8 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(cookie); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2947,7 +2947,7 @@ public class AllTests : TestCommon.AllTests TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted( @@ -3013,7 +3013,7 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted( @@ -3046,8 +3046,8 @@ public class AllTests : TestCommon.AllTests b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy); r.whenCompleted( @@ -3384,25 +3384,25 @@ public class AllTests : TestCommon.AllTests } WriteLine("ok"); - if(p.ice_getConnection() != null) + if(p.ice_getConnection() != null && p.supportsAMD()) { Write("testing graceful close connection with wait... "); Flush(); { // - // Local case: begin several requests, close the connection gracefully, and make sure it waits - // for the requests to complete. + // Local case: begin a request, close the connection gracefully, and make sure it waits + // for the request to complete. // - List<Task> results = new List<Task>(); - for(int i = 0; i < 3; ++i) - { - results.Add(p.sleepAsync(50)); - } - p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - foreach(Task t in results) - { - t.Wait(); - } + Ice.Connection con = p.ice_getConnection(); + CallbackBase cb = new CallbackBase(); + con.setCloseCallback(_ => + { + cb.called(); + }); + Task t = p.sleepAsync(100); + con.close(Ice.ConnectionClose.GracefullyWithWait); + t.Wait(); // Should complete successfully. + cb.check(); } { // @@ -3428,7 +3428,7 @@ public class AllTests : TestCommon.AllTests } ProgresCallback cb = new ProgresCallback(); - p.closeAsync(CloseMode.CloseGracefullyAndWait, progress:cb); + p.closeAsync(CloseMode.GracefullyWithWait, progress:cb); if(!cb.SentSynchronously) { @@ -3462,17 +3462,20 @@ public class AllTests : TestCommon.AllTests Flush(); { // - // Local case: start a lengthy operation and then close the connection gracefully on the client side + // Local case: start an operation and then close the connection gracefully on the client side // without waiting for the pending invocation to complete. There will be no retry and we expect the // invocation to fail with ConnectionManuallyClosedException. // - // This test requires two threads in the server's thread pool: one will block in sleep() and the other - // will process the CloseConnection message. - // - p.ice_ping(); + p = (TestIntfPrx)p.ice_connectionId("CloseGracefully"); // Start with a new connection. Ice.Connection con = p.ice_getConnection(); - Task t = p.sleepAsync(100); - con.close(Ice.ConnectionClose.CloseGracefully); + CallbackBase cb = new CallbackBase(); + Task t = p.startDispatchAsync( + progress: new Progress(sentSynchronously => + { + cb.called(); + })); + cb.check(); // Ensure the request was sent before we close the connection. + con.close(Ice.ConnectionClose.Gracefully); try { t.Wait(); @@ -3483,26 +3486,22 @@ public class AllTests : TestCommon.AllTests test(ex.InnerException is Ice.ConnectionManuallyClosedException); test((ex.InnerException as Ice.ConnectionManuallyClosedException).graceful); } + p.finishDispatch(); // - // Remote case: the server closes the connection gracefully. Our call to TestIntf::close() - // completes successfully and then the connection should be closed immediately afterward, - // despite the fact that there's a pending call to sleep(). The call to sleep() should be - // automatically retried and complete successfully. + // Remote case: the server closes the connection gracefully, which means the connection + // will not be closed until all pending dispatched requests have completed. // - p.ice_ping(); con = p.ice_getConnection(); - CallbackBase cb = new CallbackBase(); + cb = new CallbackBase(); con.setCloseCallback(_ => { cb.called(); }); t = p.sleepAsync(100); - p.close(CloseMode.CloseGracefully); + p.close(CloseMode.Gracefully); // Close is delayed until sleep completes. cb.check(); t.Wait(); - p.ice_ping(); - test(p.ice_getConnection() != con); } WriteLine("ok"); @@ -3510,13 +3509,19 @@ public class AllTests : TestCommon.AllTests Flush(); { // - // Local case: start a lengthy operation and then close the connection forcefully on the client side. + // Local case: start an operation and then close the connection forcefully on the client side. // There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. // p.ice_ping(); Ice.Connection con = p.ice_getConnection(); - Task t = p.sleepAsync(5000); - con.close(Ice.ConnectionClose.CloseForcefully); + CallbackBase cb = new CallbackBase(); + Task t = p.startDispatchAsync( + progress: new Progress(sentSynchronously => + { + cb.called(); + })); + cb.check(); // Ensure the request was sent before we close the connection. + con.close(Ice.ConnectionClose.Forcefully); try { t.Wait(); @@ -3527,6 +3532,7 @@ public class AllTests : TestCommon.AllTests test(ex.InnerException is Ice.ConnectionManuallyClosedException); test(!(ex.InnerException as Ice.ConnectionManuallyClosedException).graceful); } + p.finishDispatch(); // // Remote case: the server closes the connection forcefully. This causes the request to fail @@ -3535,7 +3541,7 @@ public class AllTests : TestCommon.AllTests // try { - p.close(CloseMode.CloseForcefully); + p.close(CloseMode.Forcefully); test(false); } catch(Ice.ConnectionLostException) diff --git a/csharp/test/Ice/ami/Test.ice b/csharp/test/Ice/ami/Test.ice index b9f88916103..029369be9d6 100644 --- a/csharp/test/Ice/ami/Test.ice +++ b/csharp/test/Ice/ami/Test.ice @@ -20,9 +20,9 @@ exception TestIntfException enum CloseMode { - CloseForcefully, - CloseGracefully, - CloseGracefullyAndWait + Forcefully, + Gracefully, + GracefullyWithWait }; interface TestIntf @@ -37,8 +37,11 @@ interface TestIntf bool waitForBatch(int count); void close(CloseMode mode); void sleep(int ms); + ["amd"] void startDispatch(); + void finishDispatch(); void shutdown(); + bool supportsAMD(); bool supportsFunctionalTests(); ["amd"] void opAsyncDispatch(); diff --git a/csharp/test/Ice/ami/TestI.cs b/csharp/test/Ice/ami/TestI.cs index a18fc738cbe..c3f8b3d6959 100644 --- a/csharp/test/Ice/ami/TestI.cs +++ b/csharp/test/Ice/ami/TestI.cs @@ -8,6 +8,7 @@ // ********************************************************************** using System; +using System.Collections.Generic; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -103,6 +104,12 @@ public class TestI : TestIntfDisp_ } override public bool + supportsAMD(Ice.Current current) + { + return true; + } + + override public bool supportsFunctionalTests(Ice.Current current) { return false; @@ -139,7 +146,32 @@ public class TestI : TestIntfDisp_ return TestIntfPrxHelper.uncheckedCast(current.adapter.createProxy(current.id)); } + override public Task + startDispatchAsync(Ice.Current current) + { + lock(this) + { + TaskCompletionSource<object> t = new TaskCompletionSource<object>(); + _pending.Add(t); + return t.Task; + } + } + + override public void + finishDispatch(Ice.Current current) + { + lock(this) + { + foreach(TaskCompletionSource<object> t in _pending) + { + t.SetResult(null); + } + } + _pending.Clear(); + } + private int _batchCount; + private List<TaskCompletionSource<object>> _pending = new List<TaskCompletionSource<object>>(); } public class TestControllerI : TestIntfControllerDisp_ diff --git a/csharp/test/Ice/background/AllTests.cs b/csharp/test/Ice/background/AllTests.cs index 0594a541224..28f38b3f754 100644 --- a/csharp/test/Ice/background/AllTests.cs +++ b/csharp/test/Ice/background/AllTests.cs @@ -327,7 +327,7 @@ public class AllTests configuration.buffered(true); backgroundController.buffered(true); background.begin_op(); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); background.begin_op(); OpAMICallback cb = new OpAMICallback(); @@ -367,7 +367,7 @@ public class AllTests System.Console.Out.WriteLine(ex); test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); for(int i = 0; i < 4; ++i) { @@ -433,7 +433,7 @@ public class AllTests } configuration.connectException(new Ice.SocketException()); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); Thread.Sleep(10); configuration.connectException(null); try @@ -463,7 +463,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); for(int i = 0; i < 4; ++i) { @@ -544,7 +544,7 @@ public class AllTests } configuration.initializeException(new Ice.SocketException()); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); Thread.Sleep(10); configuration.initializeException(null); try @@ -563,11 +563,11 @@ public class AllTests test(false); } - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); background.ice_ping(); ctl.initializeException(true); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); Thread.Sleep(10); ctl.initializeException(false); try @@ -588,7 +588,7 @@ public class AllTests try { - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); background.op(); } catch(Ice.LocalException) @@ -620,7 +620,7 @@ public class AllTests { CloseCallback cb = new CloseCallback(); prx.ice_getConnection().setCloseCallback(cb.closed); - prx.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + prx.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); cb.check(); } @@ -823,7 +823,7 @@ public class AllTests // in the flush to report a CloseConnectionException). Instead we flush a second time // with the same callback to wait for the first flush to complete. // - //backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + //backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); backgroundBatchOneway.end_ice_flushBatchRequests(r3); closeConnection(backgroundBatchOneway); } @@ -1159,10 +1159,10 @@ public class AllTests Thread.Sleep(10); background.ice_ping(); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); Thread.Sleep(10); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); } thread1.destroy(); diff --git a/csharp/test/Ice/binding/AllTests.cs b/csharp/test/Ice/binding/AllTests.cs index 949d6c12b19..264a18a22f0 100644 --- a/csharp/test/Ice/binding/AllTests.cs +++ b/csharp/test/Ice/binding/AllTests.cs @@ -159,7 +159,7 @@ public class AllTests : TestCommon.AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -181,7 +181,7 @@ public class AllTests : TestCommon.AllTests foreach(RemoteObjectAdapterPrx adpt in adapters) { - adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } @@ -206,7 +206,7 @@ public class AllTests : TestCommon.AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -290,7 +290,7 @@ public class AllTests : TestCommon.AllTests { try { - a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } catch(Ice.LocalException) { @@ -331,7 +331,7 @@ public class AllTests : TestCommon.AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -353,7 +353,7 @@ public class AllTests : TestCommon.AllTests foreach(RemoteObjectAdapterPrx adpt in adapters) { - adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } @@ -378,7 +378,7 @@ public class AllTests : TestCommon.AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -411,7 +411,7 @@ public class AllTests : TestCommon.AllTests while(names.Count > 0) { names.Remove(obj.getAdapterName()); - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Random)); @@ -423,7 +423,7 @@ public class AllTests : TestCommon.AllTests while(names.Count > 0) { names.Remove(obj.getAdapterName()); - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } deactivate(com, adapters); @@ -480,11 +480,11 @@ public class AllTests : TestCommon.AllTests adapters.Add(com.createObjectAdapter("Adapter36", endpoints[2].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter36"); i++); test(i == nRetry); - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.Add(com.createObjectAdapter("Adapter35", endpoints[1].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter35"); i++); test(i == nRetry); - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.Add(com.createObjectAdapter("Adapter34", endpoints[0].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter34"); i++); test(i == nRetry); @@ -761,7 +761,7 @@ public class AllTests : TestCommon.AllTests for(i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter82")); - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } TestIntfPrx testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true)); @@ -777,7 +777,7 @@ public class AllTests : TestCommon.AllTests for(i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter81")); - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.createObjectAdapter("Adapter83", (obj.ice_getEndpoints()[1]).ToString()); // Reactive tcp OA. @@ -785,7 +785,7 @@ public class AllTests : TestCommon.AllTests for(i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter83")); - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); diff --git a/csharp/test/Ice/hold/AllTests.cs b/csharp/test/Ice/hold/AllTests.cs index 41773301b3c..09a8098acb5 100644 --- a/csharp/test/Ice/hold/AllTests.cs +++ b/csharp/test/Ice/hold/AllTests.cs @@ -187,7 +187,7 @@ public class AllTests : TestCommon.AllTests { result.waitForSent(); holdSerialized.ice_ping(); // Ensure everything's dispatched. - holdSerialized.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + holdSerialized.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } result.waitForCompleted(); diff --git a/csharp/test/Ice/location/AllTests.cs b/csharp/test/Ice/location/AllTests.cs index aa4a23a3a22..ac580a70b21 100644 --- a/csharp/test/Ice/location/AllTests.cs +++ b/csharp/test/Ice/location/AllTests.cs @@ -533,7 +533,7 @@ public class AllTests : TestCommon.AllTests Flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); - hello.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); hello.sayHello(); obj.migrateHello(); hello.sayHello(); diff --git a/csharp/test/Ice/metrics/AllTests.cs b/csharp/test/Ice/metrics/AllTests.cs index 41cc8468930..4dba93b5701 100644 --- a/csharp/test/Ice/metrics/AllTests.cs +++ b/csharp/test/Ice/metrics/AllTests.cs @@ -271,7 +271,7 @@ public class AllTests : TestCommon.AllTests { if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + proxy.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); } try @@ -284,7 +284,7 @@ public class AllTests : TestCommon.AllTests if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + proxy.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } @@ -486,8 +486,8 @@ public class AllTests : TestCommon.AllTests if(!collocated) { - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - metrics.ice_connectionId("Con1").ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + metrics.ice_connectionId("Con1").ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -590,7 +590,7 @@ public class AllTests : TestCommon.AllTests map = toMap(serverMetrics.getMetricsView("View", out timestamp)["Connection"]); test(map["holding"].current == 1); - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); map = toMap(clientMetrics.getMetricsView("View", out timestamp)["Connection"]); test(map["closing"].current == 1); @@ -605,7 +605,7 @@ public class AllTests : TestCommon.AllTests props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "none"; updateProps(clientProps, serverProps, update, props, "Connection"); - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); metrics.ice_timeout(500).ice_ping(); controller.hold(); @@ -661,7 +661,7 @@ public class AllTests : TestCommon.AllTests testAttribute(clientMetrics, clientProps, update, "Connection", "mcastHost", ""); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastPort", ""); - m.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + m.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -681,7 +681,7 @@ public class AllTests : TestCommon.AllTests IceMX.Metrics m1 = clientMetrics.getMetricsView("View", out timestamp)["ConnectionEstablishment"][0]; test(m1.current == 0 && m1.total == 1 && m1.id.Equals(hostAndPort)); - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); controller.hold(); try { @@ -733,7 +733,7 @@ public class AllTests : TestCommon.AllTests try { prx.ice_ping(); - prx.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + prx.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } catch(Ice.LocalException) { diff --git a/csharp/test/Ice/metrics/MetricsAMDI.cs b/csharp/test/Ice/metrics/MetricsAMDI.cs index d85fa95c919..34f34e7c4e5 100644 --- a/csharp/test/Ice/metrics/MetricsAMDI.cs +++ b/csharp/test/Ice/metrics/MetricsAMDI.cs @@ -41,7 +41,7 @@ public sealed class MetricsI : MetricsDisp_ override public Task failAsync(Ice.Current current) { - current.con.close(Ice.ConnectionClose.CloseForcefully); + current.con.close(Ice.ConnectionClose.Forcefully); return null; } diff --git a/csharp/test/Ice/metrics/MetricsI.cs b/csharp/test/Ice/metrics/MetricsI.cs index 4139191de9e..9185bc8dd6b 100644 --- a/csharp/test/Ice/metrics/MetricsI.cs +++ b/csharp/test/Ice/metrics/MetricsI.cs @@ -40,7 +40,7 @@ public sealed class MetricsI : MetricsDisp_ override public void fail(Ice.Current current) { - current.con.close(Ice.ConnectionClose.CloseForcefully); + current.con.close(Ice.ConnectionClose.Forcefully); } override public void opWithUserException(Ice.Current current) diff --git a/csharp/test/Ice/operations/BatchOneways.cs b/csharp/test/Ice/operations/BatchOneways.cs index 1eb020416ba..670387f4f36 100644 --- a/csharp/test/Ice/operations/BatchOneways.cs +++ b/csharp/test/Ice/operations/BatchOneways.cs @@ -100,7 +100,7 @@ class BatchOneways batch1.ice_ping(); batch2.ice_ping(); batch1.ice_flushBatchRequests(); - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch1.ice_ping(); batch2.ice_ping(); @@ -108,7 +108,7 @@ class BatchOneways batch2.ice_getConnection(); batch1.ice_ping(); - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch1.ice_ping(); batch2.ice_ping(); } diff --git a/csharp/test/Ice/operations/BatchOnewaysAMI.cs b/csharp/test/Ice/operations/BatchOnewaysAMI.cs index e482b261eb1..957e57f677a 100644 --- a/csharp/test/Ice/operations/BatchOnewaysAMI.cs +++ b/csharp/test/Ice/operations/BatchOnewaysAMI.cs @@ -91,7 +91,7 @@ class BatchOnewaysAMI batch1.begin_ice_ping(); batch2.begin_ice_ping(); batch1.end_ice_flushBatchRequests(batch1.begin_ice_flushBatchRequests()); - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch1.begin_ice_ping(); batch2.begin_ice_ping(); @@ -99,7 +99,7 @@ class BatchOnewaysAMI batch2.ice_getConnection(); batch1.begin_ice_ping(); - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch1.begin_ice_ping(); batch2.begin_ice_ping(); diff --git a/csharp/test/Ice/retry/RetryI.cs b/csharp/test/Ice/retry/RetryI.cs index 952527cf15d..1305cfc5357 100644 --- a/csharp/test/Ice/retry/RetryI.cs +++ b/csharp/test/Ice/retry/RetryI.cs @@ -19,7 +19,7 @@ public sealed class RetryI : Test.RetryDisp_ { if(current.con != null) { - current.con.close(Ice.ConnectionClose.CloseForcefully); + current.con.close(Ice.ConnectionClose.Forcefully); } else { diff --git a/csharp/test/Ice/timeout/AllTests.cs b/csharp/test/Ice/timeout/AllTests.cs index 7c405f5872b..41196e4fead 100644 --- a/csharp/test/Ice/timeout/AllTests.cs +++ b/csharp/test/Ice/timeout/AllTests.cs @@ -248,7 +248,7 @@ public class AllTests : TestCommon.AllTests Test.TimeoutPrx to = Test.TimeoutPrxHelper.checkedCast(obj.ice_timeout(100)); Ice.Connection connection = to.ice_getConnection(); timeout.holdAdapter(500); - connection.close(Ice.ConnectionClose.CloseGracefullyAndWait); + connection.close(Ice.ConnectionClose.GracefullyWithWait); try { connection.getInfo(); // getInfo() doesn't throw in the closing state. diff --git a/csharp/test/Ice/udp/AllTests.cs b/csharp/test/Ice/udp/AllTests.cs index 710a0acb287..1ba092a0351 100644 --- a/csharp/test/Ice/udp/AllTests.cs +++ b/csharp/test/Ice/udp/AllTests.cs @@ -126,7 +126,7 @@ public class AllTests // test(seq.Length > 16384); } - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000"); seq = new byte[50000]; try diff --git a/csharp/test/IceSSL/configuration/AllTests.cs b/csharp/test/IceSSL/configuration/AllTests.cs index 64ae2a9932c..a2813a4f909 100644 --- a/csharp/test/IceSSL/configuration/AllTests.cs +++ b/csharp/test/IceSSL/configuration/AllTests.cs @@ -948,7 +948,7 @@ public class AllTests // verifier.reset(); verifier.returnValue(false); - server.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + server.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { server.ice_ping(); diff --git a/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java b/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java index 0130c676dd5..80f63e8865d 100644 --- a/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java +++ b/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java @@ -162,17 +162,17 @@ public final class ConnectionI extends IceInternal.EventHandler throw new Ice.OperationInterruptedException(); } - if(mode == ConnectionClose.CloseForcefully) + if(mode == ConnectionClose.Forcefully) { setState(StateClosed, new ConnectionManuallyClosedException(false)); } - else if(mode == ConnectionClose.CloseGracefully) + else if(mode == ConnectionClose.Gracefully) { setState(StateClosing, new ConnectionManuallyClosedException(true)); } else { - assert(mode == ConnectionClose.CloseGracefullyAndWait); + assert(mode == ConnectionClose.GracefullyWithWait); // // Wait until all outstanding requests have been completed. diff --git a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java index 60514dfd230..ce8e69a940f 100644 --- a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java +++ b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java @@ -141,7 +141,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // for(Ice.ConnectionI c : connections) { - c.close(Ice.ConnectionClose.CloseForcefully); + c.close(Ice.ConnectionClose.Forcefully); } throw e; } diff --git a/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java b/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java index 3102f3a500f..63792c49368 100644 --- a/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java +++ b/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java @@ -133,7 +133,7 @@ public final class OutgoingConnectionFactory { for(Ice.ConnectionI c : l) { - c.close(Ice.ConnectionClose.CloseForcefully); + c.close(Ice.ConnectionClose.Forcefully); } } throw new Ice.OperationInterruptedException(); diff --git a/java-compat/test/src/main/java/test/Ice/ami/AMI.java b/java-compat/test/src/main/java/test/Ice/ami/AMI.java index e3d3b792338..51ce40bc06f 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/AMI.java +++ b/java-compat/test/src/main/java/test/Ice/ami/AMI.java @@ -629,7 +629,6 @@ public class AMI run(Application app, Ice.Communicator communicator, boolean collocated, TestIntfPrx p, TestIntfControllerPrx testController) { - PrintWriter out = app.getWriter(); out.print("testing begin/end invocation... "); @@ -1830,7 +1829,7 @@ public class AMI test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( new Ice.Callback() @@ -1892,7 +1891,7 @@ public class AMI TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.ice_getConnection(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( new Ice.Callback_Object_ice_flushBatchRequests() @@ -1962,7 +1961,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2026,7 +2025,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2095,7 +2094,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2171,7 +2170,7 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2209,8 +2208,8 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2274,7 +2273,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast( p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2350,7 +2349,7 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2388,8 +2387,8 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -2613,33 +2612,30 @@ public class AMI } out.println("ok"); - if(p.ice_getConnection() != null) + if(p.ice_getConnection() != null && p.supportsAMD()) { out.print("testing graceful close connection with wait... "); out.flush(); { // - // Local case: begin several requests, close the connection gracefully, and make sure it waits - // for the requests to complete. + // Local case: begin a request, close the connection gracefully, and make sure it waits + // for the request to complete. // - java.util.List<Ice.AsyncResult> results = new java.util.ArrayList<>(); - for(int i = 0; i < 3; ++i) + CloseCallback cb = new CloseCallback(); + Ice.Connection con = p.ice_getConnection(); + con.setCloseCallback(cb); + Ice.AsyncResult r = p.begin_sleep(100); + con.close(Ice.ConnectionClose.GracefullyWithWait); // Blocks until the request completes. + r.waitForCompleted(); // Should complete successfully. + try { - results.add(p.begin_sleep(50)); + r.throwLocalException(); } - p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - for(Ice.AsyncResult r : results) + catch(Throwable ex) { - r.waitForCompleted(); - try - { - r.throwLocalException(); - } - catch(Throwable ex) - { - test(false); - } + test(false); } + cb.check(); } { // @@ -2663,7 +2659,7 @@ public class AMI { results.add(p.begin_opWithPayload(seq)); } - if(!p.begin_close(CloseMode.CloseGracefullyAndWait).isSent()) + if(!p.begin_close(CloseMode.GracefullyWithWait).isSent()) { for(int i = 0; i < maxQueue; i++) { @@ -2702,17 +2698,15 @@ public class AMI out.flush(); { // - // Local case: start a lengthy operation and then close the connection gracefully on the client side + // Local case: start an operation and then close the connection gracefully on the client side // without waiting for the pending invocation to complete. There will be no retry and we expect the // invocation to fail with ConnectionManuallyClosedException. // - // This test requires two threads in the server's thread pool: one will block in sleep() and the other - // will process the CloseConnection message. - // - p.ice_ping(); + p = (TestIntfPrx)p.ice_connectionId("CloseGracefully"); // Start with a new connection. Ice.Connection con = p.ice_getConnection(); - Ice.AsyncResult r = p.begin_sleep(100); - con.close(Ice.ConnectionClose.CloseGracefully); + Ice.AsyncResult r = p.begin_startDispatch(); + r.waitForSent(); // Ensure the request was sent before we close the connection. + con.close(Ice.ConnectionClose.Gracefully); r.waitForCompleted(); try { @@ -2723,20 +2717,18 @@ public class AMI { test(ex.graceful); } + p.finishDispatch(); // - // Remote case: the server closes the connection gracefully. Our call to TestIntf::close() - // completes successfully and then the connection should be closed immediately afterward, - // despite the fact that there's a pending call to sleep(). The call to sleep() should be - // automatically retried and complete successfully. + // Remote case: the server closes the connection gracefully, which means the connection + // will not be closed until all pending dispatched requests have completed. // - p.ice_ping(); con = p.ice_getConnection(); CloseCallback cb = new CloseCallback(); con.setCloseCallback(cb); r = p.begin_sleep(100); - p.close(CloseMode.CloseGracefully); - cb.check(); + p.close(CloseMode.Gracefully); // Close is delayed until sleep completes. + cb.check(); // Ensure connection was closed. r.waitForCompleted(); try { @@ -2746,8 +2738,6 @@ public class AMI { test(false); } - p.ice_ping(); - test(p.ice_getConnection() != con); } out.println("ok"); @@ -2755,13 +2745,14 @@ public class AMI out.flush(); { // - // Local case: start a lengthy operation and then close the connection forcefully on the client side. + // Local case: start an operation and then close the connection forcefully on the client side. // There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. // p.ice_ping(); Ice.Connection con = p.ice_getConnection(); - Ice.AsyncResult r = p.begin_sleep(100); - con.close(Ice.ConnectionClose.CloseForcefully); + Ice.AsyncResult r = p.begin_startDispatch(); + r.waitForSent(); // Ensure the request was sent before we close the connection. + con.close(Ice.ConnectionClose.Forcefully); r.waitForCompleted(); try { @@ -2772,6 +2763,7 @@ public class AMI { test(!ex.graceful); } + p.finishDispatch(); // // Remote case: the server closes the connection forcefully. This causes the request to fail @@ -2780,7 +2772,7 @@ public class AMI // try { - p.close(CloseMode.CloseForcefully); + p.close(CloseMode.Forcefully); test(false); } catch(Ice.ConnectionLostException ex) diff --git a/java-compat/test/src/main/java/test/Ice/ami/Test.ice b/java-compat/test/src/main/java/test/Ice/ami/Test.ice index c6a72decd11..f0e50bd642f 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/Test.ice +++ b/java-compat/test/src/main/java/test/Ice/ami/Test.ice @@ -21,9 +21,9 @@ exception TestIntfException enum CloseMode { - CloseForcefully, - CloseGracefully, - CloseGracefullyAndWait + Forcefully, + Gracefully, + GracefullyWithWait }; interface TestIntf @@ -38,8 +38,11 @@ interface TestIntf bool waitForBatch(int count); void close(CloseMode mode); void sleep(int ms); + ["amd"] void startDispatch(); + void finishDispatch(); void shutdown(); + bool supportsAMD(); bool supportsFunctionalTests(); bool opBool(bool b); byte opByte(byte b); diff --git a/java-compat/test/src/main/java/test/Ice/ami/TestI.java b/java-compat/test/src/main/java/test/Ice/ami/TestI.java index af4c50e5d33..aa6c1ce0a41 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/TestI.java +++ b/java-compat/test/src/main/java/test/Ice/ami/TestI.java @@ -10,6 +10,7 @@ package test.Ice.ami; import test.Ice.ami.Test._TestIntfDisp; +import test.Ice.ami.Test.AMD_TestIntf_startDispatch; import test.Ice.ami.Test.CloseMode; import test.Ice.ami.Test.TestIntfException; @@ -62,6 +63,12 @@ public class TestI extends _TestIntfDisp } @Override + public boolean supportsAMD(Ice.Current current) + { + return true; + } + + @Override public boolean supportsFunctionalTests(Ice.Current current) { return true; @@ -149,11 +156,37 @@ public class TestI extends _TestIntfDisp } @Override - public void + public synchronized void + startDispatch_async(AMD_TestIntf_startDispatch cb, Ice.Current current) + { + _pending.add(cb); + } + + @Override + public synchronized void + finishDispatch(Ice.Current current) + { + for(AMD_TestIntf_startDispatch cb : _pending) + { + cb.ice_response(); + } + _pending.clear(); + } + + @Override + public synchronized void shutdown(Ice.Current current) { + // + // Just in case a request arrived late. + // + for(AMD_TestIntf_startDispatch cb : _pending) + { + cb.ice_response(); + } current.adapter.getCommunicator().shutdown(); } private int _batchCount; + private java.util.List<AMD_TestIntf_startDispatch> _pending = new java.util.LinkedList<>(); } diff --git a/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java b/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java index f64ea6dda04..ed3eba066eb 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java +++ b/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java @@ -845,7 +845,7 @@ public class AMI test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( null, @@ -903,7 +903,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -950,7 +950,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -1004,7 +1004,7 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, @@ -1031,8 +1031,8 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( Ice.CompressBatch.BasedOnProxy, diff --git a/java-compat/test/src/main/java/test/Ice/background/AllTests.java b/java-compat/test/src/main/java/test/Ice/background/AllTests.java index e3f92a9f4d9..735c10f5e32 100644 --- a/java-compat/test/src/main/java/test/Ice/background/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/background/AllTests.java @@ -398,7 +398,7 @@ public class AllTests configuration.buffered(true); backgroundController.buffered(true); background.begin_op(); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); background.begin_op(); OpAMICallbackNoOp cb = new OpAMICallbackNoOp(); @@ -439,7 +439,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); for(int i = 0; i < 4; ++i) { @@ -505,7 +505,7 @@ public class AllTests } configuration.connectException(new Ice.SocketException()); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -548,7 +548,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); for(int i = 0; i < 4; i++) { @@ -611,7 +611,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { @@ -623,7 +623,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { @@ -667,7 +667,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { @@ -702,7 +702,7 @@ public class AllTests } configuration.initializeException(new Ice.SocketException()); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -728,7 +728,7 @@ public class AllTests } configuration.initializeSocketStatus(IceInternal.SocketOperation.Write); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); try { @@ -743,7 +743,7 @@ public class AllTests configuration.initializeSocketStatus(IceInternal.SocketOperation.None); ctl.initializeException(true); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -771,7 +771,7 @@ public class AllTests try { ctl.initializeSocketStatus(IceInternal.SocketOperation.Write); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); background.op(); ctl.initializeSocketStatus(IceInternal.SocketOperation.None); } @@ -806,7 +806,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { @@ -852,7 +852,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { @@ -922,7 +922,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { @@ -952,7 +952,7 @@ public class AllTests backgroundBatchOneway.op(); ctl.resumeAdapter(); backgroundBatchOneway.ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); // // Send bigger requests to test with auto-flushing. @@ -964,7 +964,7 @@ public class AllTests backgroundBatchOneway.opWithPayload(seq); ctl.resumeAdapter(); backgroundBatchOneway.ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); // // Then try the same thing with async flush. @@ -976,7 +976,7 @@ public class AllTests backgroundBatchOneway.op(); ctl.resumeAdapter(); backgroundBatchOneway.begin_ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); ctl.holdAdapter(); backgroundBatchOneway.opWithPayload(seq); @@ -986,7 +986,7 @@ public class AllTests ctl.resumeAdapter(); r = backgroundBatchOneway.begin_ice_flushBatchRequests(); backgroundBatchOneway.end_ice_flushBatchRequests(r); - backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } private static void @@ -1328,7 +1328,7 @@ public class AllTests } background.ice_ping(); - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -1337,7 +1337,7 @@ public class AllTests { } - background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); } thread1._destroy(); diff --git a/java-compat/test/src/main/java/test/Ice/binding/AllTests.java b/java-compat/test/src/main/java/test/Ice/binding/AllTests.java index 062a5c87393..cc7541f9e68 100644 --- a/java-compat/test/src/main/java/test/Ice/binding/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/binding/AllTests.java @@ -176,7 +176,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(test1.getAdapterName()); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -198,7 +198,7 @@ public class AllTests for(RemoteObjectAdapterPrx p : adapters) { - p.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + p.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } @@ -224,7 +224,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(test1.getAdapterName()); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -332,7 +332,7 @@ public class AllTests { try { - a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } catch(Ice.LocalException ex) { @@ -374,7 +374,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -396,7 +396,7 @@ public class AllTests for(RemoteObjectAdapterPrx p : adapters) { - p.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + p.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } @@ -422,7 +422,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // @@ -455,7 +455,7 @@ public class AllTests while(!names.isEmpty()) { names.remove(test.getAdapterName()); - test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } test = TestIntfPrxHelper.uncheckedCast(test.ice_endpointSelection(Ice.EndpointSelectionType.Random)); @@ -467,7 +467,7 @@ public class AllTests while(!names.isEmpty()) { names.remove(test.getAdapterName()); - test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } deactivate(com, adapters); @@ -531,11 +531,11 @@ public class AllTests adapters.add(com.createObjectAdapter("Adapter36", endpoints[2].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter36"); i++); test(i == nRetry); - test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.add(com.createObjectAdapter("Adapter35", endpoints[1].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter35"); i++); test(i == nRetry); - test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.add(com.createObjectAdapter("Adapter34", endpoints[0].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter34"); i++); test(i == nRetry); @@ -832,7 +832,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter82")); - test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } TestIntfPrx testSecure = TestIntfPrxHelper.uncheckedCast(test.ice_secure(true)); @@ -848,7 +848,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter81")); - test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.createObjectAdapter("Adapter83", (test.ice_getEndpoints()[1]).toString()); // Reactive tcp OA. @@ -856,7 +856,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter83")); - test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.deactivateObjectAdapter(adapters.get(0)); @@ -1051,7 +1051,7 @@ public class AllTests // Close the connection now to free a FD (it could be done after the sleep but // there could be race condiutation since the connection might not be closed // immediately due to threading). - test.ice_connectionId("0").ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_connectionId("0").ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); // // The server closed the acceptor, wait one second and retry after freeing a FD. diff --git a/java-compat/test/src/main/java/test/Ice/hold/AllTests.java b/java-compat/test/src/main/java/test/Ice/hold/AllTests.java index bd642b9882f..c7d463780b0 100644 --- a/java-compat/test/src/main/java/test/Ice/hold/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/hold/AllTests.java @@ -206,7 +206,7 @@ public class AllTests { result.waitForSent(); holdSerialized.ice_ping(); // Ensure everything's dispatched - holdSerialized.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + holdSerialized.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } result.waitForCompleted(); diff --git a/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java b/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java index 379c64d1032..a7b95da5a62 100644 --- a/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java @@ -379,7 +379,7 @@ public class AllTests out.flush(); { final Thread mainThread = Thread.currentThread(); - p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + p.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); AsyncResult r = p.begin_ice_getConnection(); mainThread.interrupt(); @@ -393,7 +393,7 @@ public class AllTests // Expected } - p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + p.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); final CallbackBase cb = new CallbackBase(); mainThread.interrupt(); diff --git a/java-compat/test/src/main/java/test/Ice/location/AllTests.java b/java-compat/test/src/main/java/test/Ice/location/AllTests.java index f8a3ab46d65..1f12cb72b81 100644 --- a/java-compat/test/src/main/java/test/Ice/location/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/location/AllTests.java @@ -611,7 +611,7 @@ public class AllTests out.flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); - hello.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); hello.sayHello(); obj.migrateHello(); hello.sayHello(); diff --git a/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java b/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java index 42bb7ee43d7..43b6640077f 100644 --- a/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java +++ b/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java @@ -28,7 +28,7 @@ public final class AMDMetricsI extends _MetricsDisp public void fail_async(AMD_Metrics_fail cb, Ice.Current current) { - current.con.close(Ice.ConnectionClose.CloseForcefully); + current.con.close(Ice.ConnectionClose.Forcefully); cb.ice_response(); } diff --git a/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java b/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java index 52de5aef9c1..1502df2ec51 100644 --- a/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java @@ -313,7 +313,7 @@ public class AllTests { if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + proxy.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); } try @@ -326,7 +326,7 @@ public class AllTests if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + proxy.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } @@ -545,8 +545,8 @@ public class AllTests if(!collocated) { - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - metrics.ice_connectionId("Con1").ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); + metrics.ice_connectionId("Con1").ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -649,7 +649,7 @@ public class AllTests map = toMap(serverMetrics.getMetricsView("View", timestamp).get("Connection")); test(map.get("holding").current == 1); - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); map = toMap(clientMetrics.getMetricsView("View", timestamp).get("Connection")); test(map.get("closing").current == 1); @@ -664,7 +664,7 @@ public class AllTests props.put("IceMX.Metrics.View.Map.Connection.GroupBy", "none"); updateProps(clientProps, serverProps, update, props, "Connection"); - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); metrics.ice_timeout(500).ice_ping(); controller.hold(); @@ -726,7 +726,7 @@ public class AllTests testAttribute(clientMetrics, clientProps, update, "Connection", "mcastHost", "", out); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastPort", "", out); - m.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + m.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -746,7 +746,7 @@ public class AllTests IceMX.Metrics m1 = clientMetrics.getMetricsView("View", timestamp).get("ConnectionEstablishment")[0]; test(m1.current == 0 && m1.total == 1 && m1.id.equals(hostAndPort)); - metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); controller.hold(); try { @@ -806,7 +806,7 @@ public class AllTests m1 = clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup")[0]; test(m1.current <= 1 && m1.total == 1 && m1.id.equals(prx.ice_getConnection().getEndpoint().toString())); - prx.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + prx.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); boolean dnsException = false; try diff --git a/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java b/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java index 37a3a440351..394a771ecb0 100644 --- a/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java +++ b/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java @@ -27,7 +27,7 @@ public final class MetricsI extends _MetricsDisp public void fail(Ice.Current current) { - current.con.close(Ice.ConnectionClose.CloseForcefully); + current.con.close(Ice.ConnectionClose.Forcefully); } @Override diff --git a/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java b/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java index 5e62fe3c230..4e4780647d6 100644 --- a/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java +++ b/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java @@ -120,7 +120,7 @@ class BatchOneways batch1.ice_ping(); batch2.ice_ping(); batch1.ice_flushBatchRequests(); - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch1.ice_ping(); batch2.ice_ping(); @@ -128,7 +128,7 @@ class BatchOneways batch2.ice_getConnection(); batch1.ice_ping(); - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch1.ice_ping(); batch2.ice_ping(); } diff --git a/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java b/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java index 985abb4e945..160cea4ad06 100644 --- a/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java +++ b/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java @@ -107,7 +107,7 @@ class BatchOnewaysAMI batch.begin_ice_ping(); batch2.begin_ice_ping(); batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()); - batch.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch.begin_ice_ping(); batch2.begin_ice_ping(); @@ -115,7 +115,7 @@ class BatchOnewaysAMI batch2.ice_getConnection(); batch.begin_ice_ping(); - batch.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + batch.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); batch.begin_ice_ping().throwLocalException(); batch2.begin_ice_ping().throwLocalException(); } diff --git a/java-compat/test/src/main/java/test/Ice/retry/RetryI.java b/java-compat/test/src/main/java/test/Ice/retry/RetryI.java index ab0d3ec70f7..54e1f76b6b5 100644 --- a/java-compat/test/src/main/java/test/Ice/retry/RetryI.java +++ b/java-compat/test/src/main/java/test/Ice/retry/RetryI.java @@ -25,7 +25,7 @@ public final class RetryI extends _RetryDisp { if(current.con != null) { - current.con.close(Ice.ConnectionClose.CloseForcefully); + current.con.close(Ice.ConnectionClose.Forcefully); } else { diff --git a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java index 28172f950c3..94989f343c3 100644 --- a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java @@ -329,7 +329,7 @@ public class AllTests TimeoutPrx to = TimeoutPrxHelper.checkedCast(obj.ice_timeout(100 * mult)); Ice.Connection connection = to.ice_getConnection(); timeout.holdAdapter(500); - connection.close(Ice.ConnectionClose.CloseGracefullyAndWait); + connection.close(Ice.ConnectionClose.GracefullyWithWait); try { connection.getInfo(); // getInfo() doesn't throw in the closing state. diff --git a/java-compat/test/src/main/java/test/Ice/udp/AllTests.java b/java-compat/test/src/main/java/test/Ice/udp/AllTests.java index 5d000d818d0..b80f309682a 100644 --- a/java-compat/test/src/main/java/test/Ice/udp/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/udp/AllTests.java @@ -130,7 +130,7 @@ public class AllTests { test(seq.length > 16384); } - obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000"); seq = new byte[50000]; try diff --git a/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java b/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java index a13868fbeb8..6ef5389b9a2 100644 --- a/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java +++ b/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java @@ -891,7 +891,7 @@ public class AllTests // verifier.reset(); verifier.returnValue(false); - server.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + server.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); try { server.ice_ping(); diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java b/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java index 4634a5ca4ec..3fee8354bb9 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java @@ -172,17 +172,17 @@ public final class ConnectionI extends com.zeroc.IceInternal.EventHandler throw new OperationInterruptedException(); } - if(mode == ConnectionClose.CloseForcefully) + if(mode == ConnectionClose.Forcefully) { setState(StateClosed, new ConnectionManuallyClosedException(false)); } - else if(mode == ConnectionClose.CloseGracefully) + else if(mode == ConnectionClose.Gracefully) { setState(StateClosing, new ConnectionManuallyClosedException(true)); } else { - assert(mode == ConnectionClose.CloseGracefullyAndWait); + assert(mode == ConnectionClose.GracefullyWithWait); // // Wait until all outstanding requests have been completed. diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java index 2aacbaebdc3..583144199a3 100644 --- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java +++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java @@ -137,7 +137,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Con // for(ConnectionI c : connections) { - c.close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + c.close(com.zeroc.Ice.ConnectionClose.Forcefully); } throw e; } diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/OutgoingConnectionFactory.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/OutgoingConnectionFactory.java index 99f29b8cbd1..853daa920a1 100644 --- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/OutgoingConnectionFactory.java @@ -138,7 +138,7 @@ public final class OutgoingConnectionFactory { for(ConnectionI c : l) { - c.close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + c.close(com.zeroc.Ice.ConnectionClose.Forcefully); } } throw new com.zeroc.Ice.OperationInterruptedException(); diff --git a/java/test/src/main/java/test/Ice/ami/AMI.java b/java/test/src/main/java/test/Ice/ami/AMI.java index bc47eb8882f..9cbbbfa6281 100644 --- a/java/test/src/main/java/test/Ice/ami/AMI.java +++ b/java/test/src/main/java/test/Ice/ami/AMI.java @@ -349,7 +349,7 @@ public class AMI test(p.opBatchCount() == 0); TestIntfPrx b1 = p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); CompletableFuture<Void> r = b1.ice_flushBatchRequestsAsync(); Util.getInvocationFuture(r).whenSent((sentSynchronously, ex) -> { @@ -398,7 +398,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity())). ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); CompletableFuture<Void> r = b1.ice_getConnection().flushBatchRequestsAsync(CompressBatch.BasedOnProxy); Util.getInvocationFuture(r).whenSent((sentSynchronously, ex) -> @@ -448,7 +448,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity())). ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); CompletableFuture<Void> r = communicator.flushBatchRequestsAsync(CompressBatch.BasedOnProxy); Util.getInvocationFuture(r).whenSent((sentSynchronously, ex) -> { @@ -504,7 +504,7 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); CompletableFuture<Void> r = communicator.flushBatchRequestsAsync(CompressBatch.BasedOnProxy); Util.getInvocationFuture(r).whenSent((sentSynchronously, ex) -> { @@ -532,8 +532,8 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); CompletableFuture<Void> r = communicator.flushBatchRequestsAsync(CompressBatch.BasedOnProxy); Util.getInvocationFuture(r).whenSent((sentSynchronously, ex) -> { @@ -759,32 +759,29 @@ public class AMI } out.println("ok"); - if(p.ice_getConnection() != null) + if(p.ice_getConnection() != null && p.supportsAMD()) { out.print("testing graceful close connection with wait... "); out.flush(); { // - // Local case: begin several requests, close the connection gracefully, and make sure it waits - // for the requests to complete. + // Local case: begin a request, close the connection gracefully, and make sure it waits + // for the request to complete. // - java.util.List<CompletableFuture<Void>> results = new java.util.ArrayList<>(); - for(int i = 0; i < 3; ++i) + com.zeroc.Ice.Connection con = p.ice_getConnection(); + Callback cb = new Callback(); + con.setCloseCallback(c -> cb.called()); + CompletableFuture<Void> f = p.sleepAsync(100); + con.close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); // Blocks until the request completes. + try { - results.add(p.sleepAsync(50)); + f.join(); // Should complete successfully. } - p.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); - for(CompletableFuture<Void> f : results) + catch(Throwable ex) { - try - { - f.join(); - } - catch(Throwable ex) - { - test(false); - } + test(false); } + cb.check(); } { // @@ -808,7 +805,7 @@ public class AMI { results.add(Util.getInvocationFuture(p.opWithPayloadAsync(seq))); } - if(!Util.getInvocationFuture(p.closeAsync(CloseMode.CloseGracefullyAndWait)).isSent()) + if(!Util.getInvocationFuture(p.closeAsync(CloseMode.GracefullyWithWait)).isSent()) { for(int i = 0; i < maxQueue; i++) { @@ -839,17 +836,15 @@ public class AMI out.flush(); { // - // Local case: start a lengthy operation and then close the connection gracefully on the client side + // Local case: start an operation and then close the connection gracefully on the client side // without waiting for the pending invocation to complete. There will be no retry and we expect the // invocation to fail with ConnectionManuallyClosedException. // - // This test requires two threads in the server's thread pool: one will block in sleep() and the other - // will process the CloseConnection message. - // - p.ice_ping(); + p = p.ice_connectionId("CloseGracefully"); // Start with a new connection. com.zeroc.Ice.Connection con = p.ice_getConnection(); - CompletableFuture<Void> f = p.sleepAsync(100); - con.close(com.zeroc.Ice.ConnectionClose.CloseGracefully); + CompletableFuture<Void> f = p.startDispatchAsync(); + Util.getInvocationFuture(f).waitForSent(); // Ensure the request was sent before we close the connection + con.close(com.zeroc.Ice.ConnectionClose.Gracefully); try { f.join(); @@ -864,23 +859,19 @@ public class AMI { test(false); } + p.finishDispatch(); // - // Remote case: the server closes the connection gracefully. Our call to TestIntf::close() - // completes successfully and then the connection should be closed immediately afterward, - // despite the fact that there's a pending call to sleep(). The call to sleep() should be - // automatically retried and complete successfully. + // Remote case: the server closes the connection gracefully, which means the connection + // will not be closed until all pending dispatched requests have completed. // - p.ice_ping(); con = p.ice_getConnection(); Callback cb = new Callback(); con.setCloseCallback(c -> cb.called()); f = p.sleepAsync(100); - p.close(CloseMode.CloseGracefully); + p.close(CloseMode.Gracefully); // Close is delayed until sleep completes. cb.check(); f.join(); - p.ice_ping(); - test(p.ice_getConnection() != con); } out.println("ok"); @@ -888,13 +879,14 @@ public class AMI out.flush(); { // - // Local case: start a lengthy operation and then close the connection forcefully on the client side. + // Local case: start an operation and then close the connection forcefully on the client side. // There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. // p.ice_ping(); com.zeroc.Ice.Connection con = p.ice_getConnection(); - CompletableFuture<Void> f = p.sleepAsync(100); - con.close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + CompletableFuture<Void> f = p.startDispatchAsync(); + Util.getInvocationFuture(f).waitForSent(); // Ensure the request was sent before we close the connection + con.close(com.zeroc.Ice.ConnectionClose.Forcefully); try { f.join(); @@ -909,6 +901,7 @@ public class AMI { test(false); } + p.finishDispatch(); // // Remote case: the server closes the connection forcefully. This causes the request to fail @@ -917,7 +910,7 @@ public class AMI // try { - p.close(CloseMode.CloseForcefully); + p.close(CloseMode.Forcefully); test(false); } catch(com.zeroc.Ice.ConnectionLostException ex) diff --git a/java/test/src/main/java/test/Ice/ami/Test.ice b/java/test/src/main/java/test/Ice/ami/Test.ice index c6a72decd11..f0e50bd642f 100644 --- a/java/test/src/main/java/test/Ice/ami/Test.ice +++ b/java/test/src/main/java/test/Ice/ami/Test.ice @@ -21,9 +21,9 @@ exception TestIntfException enum CloseMode { - CloseForcefully, - CloseGracefully, - CloseGracefullyAndWait + Forcefully, + Gracefully, + GracefullyWithWait }; interface TestIntf @@ -38,8 +38,11 @@ interface TestIntf bool waitForBatch(int count); void close(CloseMode mode); void sleep(int ms); + ["amd"] void startDispatch(); + void finishDispatch(); void shutdown(); + bool supportsAMD(); bool supportsFunctionalTests(); bool opBool(bool b); byte opByte(byte b); diff --git a/java/test/src/main/java/test/Ice/ami/TestI.java b/java/test/src/main/java/test/Ice/ami/TestI.java index ee7f4eef6f9..a498c234982 100644 --- a/java/test/src/main/java/test/Ice/ami/TestI.java +++ b/java/test/src/main/java/test/Ice/ami/TestI.java @@ -13,6 +13,9 @@ import test.Ice.ami.Test.CloseMode; import test.Ice.ami.Test.TestIntf; import test.Ice.ami.Test.TestIntfException; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.CompletableFuture; + public class TestI implements TestIntf { TestI() @@ -56,6 +59,12 @@ public class TestI implements TestIntf } @Override + public boolean supportsAMD(com.zeroc.Ice.Current current) + { + return true; + } + + @Override public boolean supportsFunctionalTests(com.zeroc.Ice.Current current) { return true; @@ -143,11 +152,39 @@ public class TestI implements TestIntf } @Override - public void + public synchronized CompletionStage<Void> + startDispatchAsync(com.zeroc.Ice.Current current) + { + CompletableFuture<Void> f = new CompletableFuture<>(); + _pending.add(f); + return f; + } + + @Override + public synchronized void + finishDispatch(com.zeroc.Ice.Current current) + { + for(CompletableFuture<Void> f : _pending) + { + f.complete(null); + } + _pending.clear(); + } + + @Override + public synchronized void shutdown(com.zeroc.Ice.Current current) { + // + // Just in case a request arrived late. + // + for(CompletableFuture<Void> f : _pending) + { + f.complete(null); + } current.adapter.getCommunicator().shutdown(); } private int _batchCount; + private java.util.List<CompletableFuture<Void>> _pending = new java.util.LinkedList<>(); } diff --git a/java/test/src/main/java/test/Ice/background/AllTests.java b/java/test/src/main/java/test/Ice/background/AllTests.java index b174df088ed..60583708a49 100644 --- a/java/test/src/main/java/test/Ice/background/AllTests.java +++ b/java/test/src/main/java/test/Ice/background/AllTests.java @@ -295,7 +295,7 @@ public class AllTests configuration.buffered(true); backgroundController.buffered(true); background.opAsync(); - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); background.opAsync(); java.util.List<CompletableFuture<Void>> results = new java.util.ArrayList<>(); @@ -334,7 +334,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); for(int i = 0; i < 4; ++i) { @@ -396,7 +396,7 @@ public class AllTests } configuration.connectException(new com.zeroc.Ice.SocketException()); - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -439,7 +439,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); for(int i = 0; i < 4; i++) { @@ -498,7 +498,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { @@ -510,7 +510,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { @@ -554,7 +554,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { @@ -589,7 +589,7 @@ public class AllTests } configuration.initializeException(new com.zeroc.Ice.SocketException()); - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -615,7 +615,7 @@ public class AllTests } configuration.initializeSocketStatus(com.zeroc.IceInternal.SocketOperation.Write); - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); try { @@ -630,7 +630,7 @@ public class AllTests configuration.initializeSocketStatus(com.zeroc.IceInternal.SocketOperation.None); ctl.initializeException(true); - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -658,7 +658,7 @@ public class AllTests try { ctl.initializeSocketStatus(com.zeroc.IceInternal.SocketOperation.Write); - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); background.op(); ctl.initializeSocketStatus(com.zeroc.IceInternal.SocketOperation.None); } @@ -693,7 +693,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { @@ -741,7 +741,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { @@ -815,7 +815,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + background.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { @@ -845,7 +845,7 @@ public class AllTests backgroundBatchOneway.op(); ctl.resumeAdapter(); backgroundBatchOneway.ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); // // Send bigger requests to test with auto-flushing. @@ -857,7 +857,7 @@ public class AllTests backgroundBatchOneway.opWithPayload(seq); ctl.resumeAdapter(); backgroundBatchOneway.ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); // // Then try the same thing with async flush. @@ -869,7 +869,7 @@ public class AllTests backgroundBatchOneway.op(); ctl.resumeAdapter(); backgroundBatchOneway.ice_flushBatchRequestsAsync(); - backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); ctl.holdAdapter(); backgroundBatchOneway.opWithPayload(seq); @@ -879,7 +879,7 @@ public class AllTests ctl.resumeAdapter(); r = backgroundBatchOneway.ice_flushBatchRequestsAsync(); r.join(); - backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + backgroundBatchOneway.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } private static void readWriteTests(Configuration configuration, BackgroundPrx background, @@ -1274,7 +1274,7 @@ public class AllTests } background.ice_ping(); - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); try { Thread.sleep(10); @@ -1283,7 +1283,7 @@ public class AllTests { } - background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + background.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.Forcefully); } thread1._destroy(); diff --git a/java/test/src/main/java/test/Ice/binding/AllTests.java b/java/test/src/main/java/test/Ice/binding/AllTests.java index 068307d7c96..ff9a5b74b9a 100644 --- a/java/test/src/main/java/test/Ice/binding/AllTests.java +++ b/java/test/src/main/java/test/Ice/binding/AllTests.java @@ -133,7 +133,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(test1.getAdapterName()); - test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } // @@ -155,7 +155,7 @@ public class AllTests for(RemoteObjectAdapterPrx p : adapters) { - p.getTestIntf().ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + p.getTestIntf().ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } } @@ -180,7 +180,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(test1.getAdapterName()); - test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } // @@ -288,7 +288,7 @@ public class AllTests { try { - a.getTestIntf().ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + a.getTestIntf().ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } catch(com.zeroc.Ice.LocalException ex) { @@ -329,7 +329,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } // @@ -351,7 +351,7 @@ public class AllTests for(RemoteObjectAdapterPrx p : adapters) { - p.getTestIntf().ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + p.getTestIntf().ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } } @@ -376,7 +376,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } // @@ -409,7 +409,7 @@ public class AllTests while(!names.isEmpty()) { names.remove(test.getAdapterName()); - test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } test = test.ice_endpointSelection(EndpointSelectionType.Random); @@ -421,7 +421,7 @@ public class AllTests while(!names.isEmpty()) { names.remove(test.getAdapterName()); - test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } deactivate(rcom, adapters); @@ -485,11 +485,11 @@ public class AllTests adapters.add(rcom.createObjectAdapter("Adapter36", endpoints[2].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter36"); i++); test(i == nRetry); - test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); adapters.add(rcom.createObjectAdapter("Adapter35", endpoints[1].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter35"); i++); test(i == nRetry); - test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); adapters.add(rcom.createObjectAdapter("Adapter34", endpoints[0].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter34"); i++); test(i == nRetry); @@ -786,7 +786,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter82")); - test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } TestIntfPrx testSecure = test.ice_secure(true); @@ -802,7 +802,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter81")); - test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } rcom.createObjectAdapter("Adapter83", (test.ice_getEndpoints()[1]).toString()); // Reactive tcp OA. @@ -810,7 +810,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter83")); - test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + test.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } rcom.deactivateObjectAdapter(adapters.get(0)); @@ -1005,7 +1005,7 @@ public class AllTests // Close the connection now to free a FD (it could be done after the sleep but // there could be race condiutation since the connection might not be closed // immediately due to threading). - test.ice_connectionId("0").ice_getConnection().close(ConnectionClose.CloseGracefullyAndWait); + test.ice_connectionId("0").ice_getConnection().close(ConnectionClose.GracefullyWithWait); // // The server closed the acceptor, wait one second and retry after freeing a FD. diff --git a/java/test/src/main/java/test/Ice/hold/AllTests.java b/java/test/src/main/java/test/Ice/hold/AllTests.java index 36974038091..acd6353cfd9 100644 --- a/java/test/src/main/java/test/Ice/hold/AllTests.java +++ b/java/test/src/main/java/test/Ice/hold/AllTests.java @@ -205,7 +205,7 @@ public class AllTests { f.waitForSent(); holdSerialized.ice_ping(); // Ensure everything's dispatched - holdSerialized.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + holdSerialized.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } } r.join(); diff --git a/java/test/src/main/java/test/Ice/interrupt/AllTests.java b/java/test/src/main/java/test/Ice/interrupt/AllTests.java index c7b00170209..3267059970f 100644 --- a/java/test/src/main/java/test/Ice/interrupt/AllTests.java +++ b/java/test/src/main/java/test/Ice/interrupt/AllTests.java @@ -337,7 +337,7 @@ public class AllTests { final Thread mainThread = Thread.currentThread(); - p.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + p.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); CompletableFuture<com.zeroc.Ice.Connection> r = p.ice_getConnectionAsync(); mainThread.interrupt(); @@ -359,7 +359,7 @@ public class AllTests // Expected } - p.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + p.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); final Callback cb = new Callback(); mainThread.interrupt(); diff --git a/java/test/src/main/java/test/Ice/location/AllTests.java b/java/test/src/main/java/test/Ice/location/AllTests.java index 2b6fb9aa789..9b0e20cf139 100644 --- a/java/test/src/main/java/test/Ice/location/AllTests.java +++ b/java/test/src/main/java/test/Ice/location/AllTests.java @@ -592,7 +592,7 @@ public class AllTests out.flush(); hello = HelloPrx.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); - hello.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + hello.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); hello.sayHello(); obj.migrateHello(); hello.sayHello(); diff --git a/java/test/src/main/java/test/Ice/metrics/AMDMetricsI.java b/java/test/src/main/java/test/Ice/metrics/AMDMetricsI.java index c329b58a85b..991973c85a7 100644 --- a/java/test/src/main/java/test/Ice/metrics/AMDMetricsI.java +++ b/java/test/src/main/java/test/Ice/metrics/AMDMetricsI.java @@ -29,7 +29,7 @@ public final class AMDMetricsI implements Metrics @Override public CompletionStage<Void> failAsync(com.zeroc.Ice.Current current) { - current.con.close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + current.con.close(com.zeroc.Ice.ConnectionClose.Forcefully); return CompletableFuture.completedFuture((Void)null); } diff --git a/java/test/src/main/java/test/Ice/metrics/AllTests.java b/java/test/src/main/java/test/Ice/metrics/AllTests.java index 5f7ada1e51f..c6d9555859b 100644 --- a/java/test/src/main/java/test/Ice/metrics/AllTests.java +++ b/java/test/src/main/java/test/Ice/metrics/AllTests.java @@ -260,7 +260,7 @@ public class AllTests { if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + proxy.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } try @@ -273,7 +273,7 @@ public class AllTests if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + proxy.ice_getCachedConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } } @@ -478,9 +478,9 @@ public class AllTests if(!collocated) { - metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); metrics.ice_connectionId("Con1").ice_getConnection().close( - com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + com.zeroc.Ice.ConnectionClose.GracefullyWithWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -583,7 +583,7 @@ public class AllTests map = toMap(serverMetrics.getMetricsView("View").returnValue.get("Connection")); test(map.get("holding").current == 1); - metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); map = toMap(clientMetrics.getMetricsView("View").returnValue.get("Connection")); test(map.get("closing").current == 1); @@ -598,7 +598,7 @@ public class AllTests props.put("IceMX.Metrics.View.Map.Connection.GroupBy", "none"); updateProps(clientProps, serverProps, props, "Connection"); - metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); metrics.ice_timeout(500).ice_ping(); controller.hold(); @@ -660,7 +660,7 @@ public class AllTests testAttribute(clientMetrics, clientProps, "Connection", "mcastHost", "", out); testAttribute(clientMetrics, clientProps, "Connection", "mcastPort", "", out); - m.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + m.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -681,7 +681,7 @@ public class AllTests clientMetrics.getMetricsView("View").returnValue.get("ConnectionEstablishment")[0]; test(m1.current == 0 && m1.total == 1 && m1.id.equals(hostAndPort)); - metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); controller.hold(); try { @@ -738,7 +738,7 @@ public class AllTests try { prx.ice_ping(); - prx.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + prx.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); } catch(com.zeroc.Ice.LocalException ex) { diff --git a/java/test/src/main/java/test/Ice/metrics/MetricsI.java b/java/test/src/main/java/test/Ice/metrics/MetricsI.java index 7c9e1a527e5..86d012803c4 100644 --- a/java/test/src/main/java/test/Ice/metrics/MetricsI.java +++ b/java/test/src/main/java/test/Ice/metrics/MetricsI.java @@ -25,7 +25,7 @@ public final class MetricsI implements Metrics @Override public void fail(com.zeroc.Ice.Current current) { - current.con.close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + current.con.close(com.zeroc.Ice.ConnectionClose.Forcefully); } @Override diff --git a/java/test/src/main/java/test/Ice/operations/BatchOneways.java b/java/test/src/main/java/test/Ice/operations/BatchOneways.java index be982010978..27792cc109e 100644 --- a/java/test/src/main/java/test/Ice/operations/BatchOneways.java +++ b/java/test/src/main/java/test/Ice/operations/BatchOneways.java @@ -114,7 +114,7 @@ class BatchOneways batch1.ice_ping(); batch2.ice_ping(); batch1.ice_flushBatchRequests(); - batch1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); batch1.ice_ping(); batch2.ice_ping(); @@ -122,7 +122,7 @@ class BatchOneways batch2.ice_getConnection(); batch1.ice_ping(); - batch1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + batch1.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); batch1.ice_ping(); batch2.ice_ping(); } diff --git a/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java b/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java index 1093418d3b1..3aec78e44f0 100644 --- a/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java +++ b/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java @@ -100,7 +100,7 @@ class BatchOnewaysAMI batch.ice_pingAsync(); batch2.ice_pingAsync(); batch.ice_flushBatchRequestsAsync().join(); - batch.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + batch.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); batch.ice_pingAsync(); batch2.ice_pingAsync(); @@ -108,7 +108,7 @@ class BatchOnewaysAMI batch2.ice_getConnection(); batch.ice_pingAsync(); - batch.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + batch.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); test(!batch.ice_pingAsync().isCompletedExceptionally()); test(!batch2.ice_pingAsync().isCompletedExceptionally()); } diff --git a/java/test/src/main/java/test/Ice/retry/RetryI.java b/java/test/src/main/java/test/Ice/retry/RetryI.java index 23d09ead06e..37137dc6db9 100644 --- a/java/test/src/main/java/test/Ice/retry/RetryI.java +++ b/java/test/src/main/java/test/Ice/retry/RetryI.java @@ -24,7 +24,7 @@ public final class RetryI implements Retry { if(current.con != null) { - current.con.close(com.zeroc.Ice.ConnectionClose.CloseForcefully); + current.con.close(com.zeroc.Ice.ConnectionClose.Forcefully); } else { diff --git a/java/test/src/main/java/test/Ice/timeout/AllTests.java b/java/test/src/main/java/test/Ice/timeout/AllTests.java index 1b8172762f9..e336c0a68fa 100644 --- a/java/test/src/main/java/test/Ice/timeout/AllTests.java +++ b/java/test/src/main/java/test/Ice/timeout/AllTests.java @@ -262,7 +262,7 @@ public class AllTests TimeoutPrx to = TimeoutPrx.checkedCast(obj.ice_timeout(100 * mult)); com.zeroc.Ice.Connection connection = to.ice_getConnection(); timeout.holdAdapter(500); - connection.close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + connection.close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { connection.getInfo(); // getInfo() doesn't throw in the closing state. diff --git a/java/test/src/main/java/test/Ice/udp/AllTests.java b/java/test/src/main/java/test/Ice/udp/AllTests.java index 8fddc3c1388..bdb50f7ca3d 100644 --- a/java/test/src/main/java/test/Ice/udp/AllTests.java +++ b/java/test/src/main/java/test/Ice/udp/AllTests.java @@ -124,7 +124,7 @@ public class AllTests { test(seq.length > 16384); } - obj.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + obj.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000"); seq = new byte[50000]; try diff --git a/java/test/src/main/java/test/IceSSL/configuration/AllTests.java b/java/test/src/main/java/test/IceSSL/configuration/AllTests.java index a7228f347bb..5bc2d5a2f0d 100644 --- a/java/test/src/main/java/test/IceSSL/configuration/AllTests.java +++ b/java/test/src/main/java/test/IceSSL/configuration/AllTests.java @@ -889,7 +889,7 @@ public class AllTests // verifier.reset(); verifier.returnValue(false); - server.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.CloseGracefullyAndWait); + server.ice_getConnection().close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait); try { server.ice_ping(); diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js index 4243b438ad9..9b3fdc153f8 100644 --- a/js/src/Ice/ConnectionI.js +++ b/js/src/Ice/ConnectionI.js @@ -223,19 +223,19 @@ class ConnectionI { const r = new AsyncResultBase(this._communicator, "close", this, null, null); - if(mode == ConnectionClose.CloseForcefully) + if(mode == ConnectionClose.Forcefully) { this.setState(StateClosed, new Ice.ConnectionManuallyClosedException(false)); r.resolve(); } - else if(mode == ConnectionClose.CloseGracefully) + else if(mode == ConnectionClose.Gracefully) { this.setState(StateClosing, new Ice.ConnectionManuallyClosedException(true)); r.resolve(); } else { - Debug.assert(mode == ConnectionClose.CloseGracefullyAndWait); + Debug.assert(mode == ConnectionClose.GracefullyWithWait); // // Wait until all outstanding requests have been completed. @@ -250,7 +250,7 @@ class ConnectionI checkClose() { // - // If close(CloseGracefullyAndWait) has been called, then we need to check if all + // If close(GracefullyWithWait) has been called, then we need to check if all // requests have completed and we can transition to StateClosing. // We also complete outstanding promises. // diff --git a/js/test/Ice/ami/Client.js b/js/test/Ice/ami/Client.js index 39b5aeae704..8b8a09cb73e 100644 --- a/js/test/Ice/ami/Client.js +++ b/js/test/Ice/ami/Client.js @@ -111,7 +111,7 @@ // test(batchCount === 0); b1.opBatch(); - b1.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); return communicator.flushBatchRequests().then(() => p.opBatchCount()); } ).then(batchCount => @@ -156,7 +156,7 @@ b2 = prx; b1.opBatch(); b2.opBatch(); - b1.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); return communicator.flushBatchRequests(); } ).then(() => p.waitForBatch(1) @@ -181,8 +181,8 @@ b2 = prx; b1.opBatch(); b2.opBatch(); - b1.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); - b2.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b1.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); + b2.ice_getCachedConnection().close(Ice.ConnectionClose.GracefullyWithWait); return communicator.flushBatchRequests(); } ).then(() => p.opBatchCount()); diff --git a/js/test/Ice/ami/Test.ice b/js/test/Ice/ami/Test.ice index a9c4ffb88bc..74e8dc1728f 100644 --- a/js/test/Ice/ami/Test.ice +++ b/js/test/Ice/ami/Test.ice @@ -18,6 +18,13 @@ exception TestIntfException { }; +enum CloseMode +{ + Forcefully, + Gracefully, + GracefullyWithWait +}; + interface TestIntf { void op(); @@ -28,9 +35,13 @@ interface TestIntf void opBatch(); int opBatchCount(); bool waitForBatch(int count); - void close(bool force); + void close(CloseMode mode); + void sleep(int ms); + ["amd"] void startDispatch(); + void finishDispatch(); void shutdown(); + bool supportsAMD(); bool supportsFunctionalTests(); }; diff --git a/js/test/Ice/binding/Client.js b/js/test/Ice/binding/Client.js index 680b0341df9..a5011cbac1d 100644 --- a/js/test/Ice/binding/Client.js +++ b/js/test/Ice/binding/Client.js @@ -260,7 +260,7 @@ ).then( function(conn) { - return conn.close(Ice.ConnectionClose.CloseGracefullyAndWait); + return conn.close(Ice.ConnectionClose.GracefullyWithWait); } ).then( function() @@ -339,7 +339,7 @@ }).then( function(c) { - return c.close(Ice.ConnectionClose.CloseGracefullyAndWait); + return c.close(Ice.ConnectionClose.GracefullyWithWait); } ); })); @@ -422,7 +422,7 @@ ).then( function(conn) { - return conn.close(Ice.ConnectionClose.CloseGracefullyAndWait); + return conn.close(Ice.ConnectionClose.GracefullyWithWait); } ).then( function() @@ -585,7 +585,7 @@ }).then( function(c) { - return c.close(Ice.ConnectionClose.CloseGracefullyAndWait); + return c.close(Ice.ConnectionClose.GracefullyWithWait); }, function(ex) { @@ -651,7 +651,7 @@ } return prx.ice_getConnection(); } - ).then(conn => conn.close(Ice.ConnectionClose.CloseGracefullyAndWait) + ).then(conn => conn.close(Ice.ConnectionClose.GracefullyWithWait) ).then(() => names.length > 0 ? f1() : prx); }; @@ -678,7 +678,7 @@ ).then( function(conn) { - return conn.close(Ice.ConnectionClose.CloseGracefullyAndWait); + return conn.close(Ice.ConnectionClose.GracefullyWithWait); } ).then( function() diff --git a/js/test/Ice/hold/Client.js b/js/test/Ice/hold/Client.js index 03f31d4c353..43f8918bc73 100644 --- a/js/test/Ice/hold/Client.js +++ b/js/test/Ice/hold/Client.js @@ -230,7 +230,7 @@ ).then( function(con) { - return con.close(Ice.ConnectionClose.CloseGracefullyAndWait); + return con.close(Ice.ConnectionClose.GracefullyWithWait); } ); } diff --git a/js/test/Ice/location/Client.js b/js/test/Ice/location/Client.js index 62168831822..46c33848e4f 100644 --- a/js/test/Ice/location/Client.js +++ b/js/test/Ice/location/Client.js @@ -1110,7 +1110,7 @@ ).then( function(con) { - return con.close(Ice.ConnectionClose.CloseGracefullyAndWait); + return con.close(Ice.ConnectionClose.GracefullyWithWait); } ).then( function() diff --git a/js/test/Ice/operations/BatchOneways.js b/js/test/Ice/operations/BatchOneways.js index b6660b97781..7940b703a7f 100644 --- a/js/test/Ice/operations/BatchOneways.js +++ b/js/test/Ice/operations/BatchOneways.js @@ -82,7 +82,7 @@ ).then(count => batch.ice_flushBatchRequests() ).then(() => prx.opByteSOnewayCallCount() ).then(() => batch.ice_getConnection() - ).then(con => bidir ? undefined : con.close(Ice.ConnectionClose.CloseGracefullyAndWait) + ).then(con => bidir ? undefined : con.close(Ice.ConnectionClose.GracefullyWithWait) ).then(() => Promise.all([batch.ice_ping(), batch2.ice_ping()]) ).then(() => { diff --git a/js/test/Ice/timeout/Client.js b/js/test/Ice/timeout/Client.js index 9f2872dfecb..8490b197f18 100644 --- a/js/test/Ice/timeout/Client.js +++ b/js/test/Ice/timeout/Client.js @@ -142,7 +142,7 @@ connection = con; return timeout.holdAdapter(1500); } - ).then(() => connection.close(Ice.ConnectionClose.CloseGracefullyAndWait) + ).then(() => connection.close(Ice.ConnectionClose.GracefullyWithWait) ).then(() => { try diff --git a/objective-c/test/Ice/ami/AMITest.ice b/objective-c/test/Ice/ami/AMITest.ice index aef85211dce..c300528463b 100644 --- a/objective-c/test/Ice/ami/AMITest.ice +++ b/objective-c/test/Ice/ami/AMITest.ice @@ -19,6 +19,14 @@ exception TestIntfException { }; +["objc:scoped"] +enum CloseMode +{ + Forcefully, + Gracefully, + GracefullyWithWait +}; + interface TestIntf { void op(); @@ -29,9 +37,13 @@ interface TestIntf void opBatch(); int opBatchCount(); bool waitForBatch(int count); + void close(CloseMode mode); void sleep(int ms); + ["amd"] void startDispatch(); + void finishDispatch(); void shutdown(); + bool supportsAMD(); bool supportsFunctionalTests(); }; diff --git a/objective-c/test/Ice/ami/AllTests.m b/objective-c/test/Ice/ami/AllTests.m index cdddbaef6a5..8f4552c2946 100644 --- a/objective-c/test/Ice/ami/AllTests.m +++ b/objective-c/test/Ice/ami/AllTests.m @@ -563,7 +563,7 @@ amiAllTests(id<ICECommunicator> communicator, BOOL collocated) test([p opBatchCount] == 0); id<TestAMITestIntfPrx> b1 = [p ice_batchOneway]; [b1 opBatch]; - [[b1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[b1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; id<ICEAsyncResult> r = [b1 begin_ice_flushBatchRequests]; [b1 end_ice_flushBatchRequests:r]; test([r isSent]); @@ -604,7 +604,7 @@ amiAllTests(id<ICECommunicator> communicator, BOOL collocated) uncheckedCast:[[p ice_getConnection] createProxy:[p ice_getIdentity]]] ice_batchOneway]; [b1 opBatch]; - [[b1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[b1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; TestAMICallback* cb = [TestAMICallback create]; id<ICEAsyncResult> r = [[b1 ice_getConnection] begin_flushBatchRequests:ICECompressBatchBasedOnProxy exception:^(ICEException* ex) { [cb called]; } @@ -644,7 +644,7 @@ amiAllTests(id<ICECommunicator> communicator, BOOL collocated) uncheckedCast:[[p ice_getConnection] createProxy:[p ice_getIdentity]]] ice_batchOneway]; [b1 opBatch]; - [[b1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[b1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; TestAMICallback* cb = [TestAMICallback create]; id<ICEAsyncResult> r = [communicator begin_flushBatchRequests:ICECompressBatchBasedOnProxy exception:^(ICEException* ex) { test(NO); } diff --git a/objective-c/test/Ice/ami/TestI.m b/objective-c/test/Ice/ami/TestI.m index 2777f81c5bb..736adefda00 100644 --- a/objective-c/test/Ice/ami/TestI.m +++ b/objective-c/test/Ice/ami/TestI.m @@ -90,6 +90,10 @@ } return NO; } +-(void) close:(TestAMICloseMode)mode current:(ICECurrent *)current +{ + [current.con close:(ICEConnectionClose)mode]; +} -(void) sleep:(ICEInt)delay current:(ICECurrent *)current { [_cond lock]; @@ -102,6 +106,16 @@ [_cond unlock]; } } +-(void) startDispatch:(ICECurrent*)current +{ +} +-(void) finishDispatch:(ICECurrent*)current +{ +} +-(BOOL) supportsAMD:(ICECurrent *)current +{ + return NO; +} -(BOOL) supportsFunctionalTests:(ICECurrent *)current { return NO; diff --git a/objective-c/test/Ice/binding/AllTests.m b/objective-c/test/Ice/binding/AllTests.m index aa112be642e..5236b246146 100644 --- a/objective-c/test/Ice/binding/AllTests.m +++ b/objective-c/test/Ice/binding/AllTests.m @@ -229,7 +229,7 @@ bindingAllTests(id<ICECommunicator> communicator) test([[test2 ice_getConnection] isEqual:[test3 ice_getConnection]]); [names removeObject:[test1 getAdapterName]]; - [[test1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } // @@ -251,7 +251,7 @@ bindingAllTests(id<ICECommunicator> communicator) for(id<TestBindingRemoteObjectAdapterPrx> a in adapters) { - [[[a getTestIntf] ice_getConnection] close:ICECloseGracefullyAndWait]; + [[[a getTestIntf] ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } } @@ -276,7 +276,7 @@ bindingAllTests(id<ICECommunicator> communicator) test([[test2 ice_getConnection] isEqual:[test3 ice_getConnection]]); [names removeObject:[test1 getAdapterName]]; - [[test1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } // @@ -320,7 +320,7 @@ bindingAllTests(id<ICECommunicator> communicator) test([[test2 ice_getConnection] isEqual:[test3 ice_getConnection]]); [names removeObject:getAdapterNameWithAMI(test1)]; - [[test1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } // @@ -342,7 +342,7 @@ bindingAllTests(id<ICECommunicator> communicator) for(id<TestBindingRemoteObjectAdapterPrx> a in adapters) { - [[[a getTestIntf] ice_getConnection] close:ICECloseGracefullyAndWait]; + [[[a getTestIntf] ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } } @@ -367,7 +367,7 @@ bindingAllTests(id<ICECommunicator> communicator) test([[test2 ice_getConnection] isEqual:[test3 ice_getConnection]]); [names removeObject:[test1 getAdapterName]]; - [[test1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } // @@ -399,7 +399,7 @@ bindingAllTests(id<ICECommunicator> communicator) while([names count] != 0) { [names removeObject:[test getAdapterName]]; - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } test = [TestBindingTestIntfPrx uncheckedCast:[test ice_endpointSelection:ICERandom]]; @@ -411,7 +411,7 @@ bindingAllTests(id<ICECommunicator> communicator) while([names count] != 0) { [names removeObject:[test getAdapterName]]; - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } deactivate(com, adapters); @@ -439,7 +439,7 @@ bindingAllTests(id<ICECommunicator> communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter31"]; i++); } #endif @@ -449,7 +449,7 @@ bindingAllTests(id<ICECommunicator> communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter32"]; i++); } #endif @@ -459,7 +459,7 @@ bindingAllTests(id<ICECommunicator> communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter33"]; i++); } #endif @@ -487,29 +487,29 @@ bindingAllTests(id<ICECommunicator> communicator) #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter36"]; i++); } #endif test(i == nRetry); - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [adapters addObject:[com createObjectAdapter:@"Adapter35" endpoints:[endpoints objectAtIndex:1]]]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter35"]; i++); #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter35"]; i++); } #endif test(i == nRetry); - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [adapters addObject:[com createObjectAdapter:@"Adapter34" endpoints:[endpoints objectAtIndex:0]]]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter34"]; i++); #if TARGET_OS_IPHONE > 0 if(i != nRetry) { - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; for(i = 0; i < nRetry && [[test getAdapterName] isEqualToString:@"Adapter34"]; i++); } #endif @@ -818,7 +818,7 @@ bindingAllTests(id<ICECommunicator> communicator) for(i = 0; i < 5; i++) { test([[test getAdapterName] isEqualToString:@"Adapter82"]); - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } id<TestBindingTestIntfPrx> testSecure = [TestBindingTestIntfPrx uncheckedCast:[test ice_secure:YES]]; @@ -834,7 +834,7 @@ bindingAllTests(id<ICECommunicator> communicator) for(i = 0; i < 5; i++) { test([[test getAdapterName] isEqualToString:@"Adapter81"]); - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } [com createObjectAdapter:@"Adapter83" endpoints:[getEndpoints(test) objectAtIndex:1]]; // Reactive tcp OA. @@ -842,7 +842,7 @@ bindingAllTests(id<ICECommunicator> communicator) for(i = 0; i < 5; i++) { test([[test getAdapterName] isEqualToString:@"Adapter83"]); - [[test ice_getConnection] close:ICECloseGracefullyAndWait]; + [[test ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } [com deactivateObjectAdapter:[adapters objectAtIndex:0]]; diff --git a/objective-c/test/Ice/metrics/AllTests.m b/objective-c/test/Ice/metrics/AllTests.m index 30e547f94ef..1134404b921 100644 --- a/objective-c/test/Ice/metrics/AllTests.m +++ b/objective-c/test/Ice/metrics/AllTests.m @@ -185,7 +185,7 @@ NSCondition* cond; { if([proxy ice_getCachedConnection]) { - [[proxy ice_getCachedConnection] close:ICECloseGracefullyAndWait]; + [[proxy ice_getCachedConnection] close:ICEConnectionCloseGracefullyWithWait]; } @try { @@ -196,7 +196,7 @@ NSCondition* cond; } if([proxy ice_getCachedConnection]) { - [[proxy ice_getCachedConnection] close:ICECloseGracefullyAndWait]; + [[proxy ice_getCachedConnection] close:ICEConnectionCloseGracefullyWithWait]; } } @end @@ -606,7 +606,7 @@ metricsAllTests(id<ICECommunicator> communicator) map = toMap([[serverMetrics getMetricsView:@"View" timestamp:×tamp] objectForKey:@"Connection"]); test([[map objectForKey:@"holding"] current] == 1); - [[metrics ice_getConnection] close:ICECloseGracefullyAndWait]; + [[metrics ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; map = toMap([[clientMetrics getMetricsView:@"View" timestamp:×tamp] objectForKey:@"Connection"]); test([[map objectForKey:@"closing"] current] == 1); @@ -621,7 +621,7 @@ metricsAllTests(id<ICECommunicator> communicator) [props setObject:@"none" forKey:@"IceMX.Metrics.View.Map.Connection.GroupBy"]; updateProps(clientProps, serverProps, update, props, @"Connection"); - [[metrics ice_getConnection] close:ICECloseGracefullyAndWait]; + [[metrics ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [[metrics ice_timeout:500] ice_ping]; [controller hold]; @@ -680,7 +680,7 @@ metricsAllTests(id<ICECommunicator> communicator) testAttribute(clientMetrics, clientProps, update, @"Connection", @"mcastHost", @"", nil); testAttribute(clientMetrics, clientProps, update, @"Connection", @"mcastPort", @"", nil); - [[m ice_getConnection] close:ICECloseGracefullyAndWait]; + [[m ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; waitForCurrent(clientMetrics, @"View", @"Connection", 0); waitForCurrent(serverMetrics, @"View", @"Connection", 0); @@ -703,7 +703,7 @@ metricsAllTests(id<ICECommunicator> communicator) test(m1.current == 0 && m1.total == 1 && [m1.id_ isEqualToString:hostAndPort]); - [[metrics ice_getConnection] close:ICECloseGracefullyAndWait]; + [[metrics ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [controller hold]; @try { @@ -758,7 +758,7 @@ metricsAllTests(id<ICECommunicator> communicator) @try { [prx ice_ping]; - [[prx ice_getConnection] close:ICECloseGracefullyAndWait]; + [[prx ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; } @catch(ICELocalException*) { diff --git a/objective-c/test/Ice/metrics/TestI.m b/objective-c/test/Ice/metrics/TestI.m index 593bbdcac3f..0b6fc3202b3 100644 --- a/objective-c/test/Ice/metrics/TestI.m +++ b/objective-c/test/Ice/metrics/TestI.m @@ -24,7 +24,7 @@ -(void) fail:(ICECurrent*)current { - [current.con close:ICECloseForcefully]; + [current.con close:ICEConnectionCloseForcefully]; } -(void) opWithUserException:(ICECurrent*)current diff --git a/objective-c/test/Ice/operations/BatchOneways.m b/objective-c/test/Ice/operations/BatchOneways.m index 5042d5cc36b..07fd78e9733 100644 --- a/objective-c/test/Ice/operations/BatchOneways.m +++ b/objective-c/test/Ice/operations/BatchOneways.m @@ -52,7 +52,7 @@ batchOneways(id<TestOperationsMyClassPrx> p) [batch1 ice_ping]; [batch2 ice_ping]; [batch1 ice_flushBatchRequests]; - [[batch1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[batch1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [batch1 ice_ping]; [batch2 ice_ping]; @@ -60,7 +60,7 @@ batchOneways(id<TestOperationsMyClassPrx> p) [batch2 ice_getConnection]; [batch1 ice_ping]; - [[batch1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[batch1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [batch1 ice_ping]; [batch2 ice_ping]; } diff --git a/objective-c/test/Ice/operations/BatchOnewaysAMI.m b/objective-c/test/Ice/operations/BatchOnewaysAMI.m index 0c6a8c9d5ba..7c9313daa62 100644 --- a/objective-c/test/Ice/operations/BatchOnewaysAMI.m +++ b/objective-c/test/Ice/operations/BatchOnewaysAMI.m @@ -48,7 +48,7 @@ batchOnewaysAMI(id<TestOperationsMyClassPrx> p) [batch1 end_ice_ping:[batch1 begin_ice_ping]]; [batch2 end_ice_ping:[batch2 begin_ice_ping]]; [batch1 end_ice_flushBatchRequests:[batch1 begin_ice_flushBatchRequests]]; - [[batch1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[batch1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [batch1 end_ice_ping:[batch1 begin_ice_ping]]; [batch2 end_ice_ping:[batch2 begin_ice_ping]]; @@ -56,7 +56,7 @@ batchOnewaysAMI(id<TestOperationsMyClassPrx> p) [batch2 ice_getConnection]; [batch1 end_ice_ping:[batch1 begin_ice_ping]]; - [[batch1 ice_getConnection] close:ICECloseGracefullyAndWait]; + [[batch1 ice_getConnection] close:ICEConnectionCloseGracefullyWithWait]; [batch1 end_ice_ping:[batch1 begin_ice_ping]]; [batch2 end_ice_ping:[batch2 begin_ice_ping]]; } diff --git a/objective-c/test/Ice/retry/TestI.m b/objective-c/test/Ice/retry/TestI.m index 47ed97d1414..9ea11bc6cff 100644 --- a/objective-c/test/Ice/retry/TestI.m +++ b/objective-c/test/Ice/retry/TestI.m @@ -28,7 +28,7 @@ { if([current con]) { - [[current con] close:ICECloseForcefully]; + [[current con] close:ICEConnectionCloseForcefully]; } else { diff --git a/objective-c/test/Ice/timeout/AllTests.m b/objective-c/test/Ice/timeout/AllTests.m index d49db7daf48..7730e194a5d 100644 --- a/objective-c/test/Ice/timeout/AllTests.m +++ b/objective-c/test/Ice/timeout/AllTests.m @@ -95,7 +95,7 @@ timeoutAllTests(id<ICECommunicator> communicator) // id<TestTimeoutTimeoutPrx> to = [TestTimeoutTimeoutPrx uncheckedCast:[obj ice_timeout:500]]; [to holdAdapter:1000]; - [[to ice_getConnection] close:ICECloseForcefully]; // Force a reconnect. + [[to ice_getConnection] close:ICEConnectionCloseForcefully]; // Force a reconnect. @try { [to op]; @@ -113,7 +113,7 @@ timeoutAllTests(id<ICECommunicator> communicator) [timeout op]; // Ensure adapter is active. id<TestTimeoutTimeoutPrx> to = [TestTimeoutTimeoutPrx uncheckedCast:[obj ice_timeout:1000]]; [to holdAdapter:500]; - [[to ice_getConnection] close:ICECloseForcefully]; // Force a reconnect. + [[to ice_getConnection] close:ICEConnectionCloseForcefully]; // Force a reconnect. @try { [to op]; diff --git a/php/test/Ice/binding/Client.php b/php/test/Ice/binding/Client.php index f465fac813e..91323907114 100644 --- a/php/test/Ice/binding/Client.php +++ b/php/test/Ice/binding/Client.php @@ -62,8 +62,8 @@ function allTests($communicator) $random = $NS ? constant("Ice\\EndpointSelectionType::Random") : constant("Ice_EndpointSelectionType::Random"); $ordered = $NS ? constant("Ice\\EndpointSelectionType::Ordered") : constant("Ice_EndpointSelectionType::Ordered"); $closeGracefullyAndWait = - $NS ? constant("Ice\\ConnectionClose::CloseGracefullyAndWait") : - constant("Ice_ConnectionClose::CloseGracefullyAndWait"); + $NS ? constant("Ice\\ConnectionClose::GracefullyWithWait") : + constant("Ice_ConnectionClose::GracefullyWithWait"); $ref = "communicator:default -p 12010"; $com = $communicator->stringToProxy($ref)->ice_uncheckedCast("::Test::RemoteCommunicator"); diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py index 78c71233218..ebcf7b3a3c2 100644 --- a/python/test/Ice/ami/AllTests.py +++ b/python/test/Ice/ami/AllTests.py @@ -769,7 +769,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = p.ice_batchOneway() b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FlushCallback() r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent) cb.check() @@ -783,7 +783,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = p.ice_batchOneway() b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FlushCallback(cookie) r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie)) cb.check() @@ -831,7 +831,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FlushExCallback() r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) cb.check() @@ -845,7 +845,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FlushExCallback(cookie) r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, lambda ex: cb.exceptionWC(ex, cookie), @@ -878,7 +878,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FlushCallback() r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) cb.check() @@ -918,7 +918,7 @@ def allTests(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FlushCallback() r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) cb.check() @@ -938,8 +938,8 @@ def allTests(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FlushCallback() r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent) cb.check() @@ -1121,24 +1121,22 @@ def allTests(communicator, collocated): print("ok") - if p.ice_getConnection(): + if p.ice_getConnection() and p.supportsAMD(): + sys.stdout.write("testing graceful close connection with wait... ") sys.stdout.flush() # - # Local case: begin several requests, close the connection gracefully, and make sure it waits - # for the requests to complete. + # Local case: begin a request, close the connection gracefully, and make sure it waits + # for the request to complete. # - results = [] - for i in range(0, 3): - results.append(p.begin_sleep(50)) - p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) - for r in results: - r.waitForCompleted() - try: - r.throwLocalException() - except: - test(False) + cb = CallbackBase() + con = p.ice_getConnection() + con.setCloseCallback(lambda con: cb.called()) + f = p.sleepAsync(100) + con.close(Ice.ConnectionClose.GracefullyWithWait) # Blocks until the request completes. + f.result() # Should complete successfully. + cb.check() # # Remote case. @@ -1163,7 +1161,7 @@ def allTests(communicator, collocated): results = [] for i in range(0, maxQueue): results.append(p.begin_opWithPayload(seq)) - if not p.begin_close(Test.CloseMode.CloseGracefullyAndWait).isSent(): + if not p.begin_close(Test.CloseMode.GracefullyWithWait).isSent(): for i in range(0, maxQueue): r = p.begin_opWithPayload(seq) results.append(r) @@ -1187,44 +1185,36 @@ def allTests(communicator, collocated): sys.stdout.flush() # - # Local case: start a lengthy operation and then close the connection gracefully on the client side + # Local case: start an operation and then close the connection gracefully on the client side # without waiting for the pending invocation to complete. There will be no retry and we expect the # invocation to fail with ConnectionManuallyClosedException. # - # This test requires two threads in the server's thread pool: one will block in sleep() and the other - # will process the CloseConnection message. - # - p.ice_ping() + p = p.ice_connectionId("CloseGracefully") # Start with a new connection. con = p.ice_getConnection() - r = p.begin_sleep(1000) - con.close(Ice.ConnectionClose.CloseGracefully) - r.waitForCompleted() + f = p.startDispatchAsync() + f.sent() # Ensure the request was sent before we close the connection. + con.close(Ice.ConnectionClose.Gracefully) try: - r.throwLocalException() + f.result() test(False) except Ice.ConnectionManuallyClosedException as ex: test(ex.graceful) + p.finishDispatch() # - # Remote case: the server closes the connection gracefully. Our call to TestIntf::close() - # completes successfully and then the connection should be closed immediately afterward, - # despite the fact that there's a pending call to sleep(). The call to sleep() should be - # automatically retried and complete successfully. + # Remote case: the server closes the connection gracefully, which means the connection + # will not be closed until all pending dispatched requests have completed. # - p.ice_ping() con = p.ice_getConnection() cb = CallbackBase() con.setCloseCallback(lambda c: cb.called()) - r = p.begin_sleep(250) - p.close(Test.CloseMode.CloseGracefully) - cb.check() - r.waitForCompleted() + f = p.sleepAsync(100) + p.close(Test.CloseMode.Gracefully) # Close is delayed until sleep completes. + cb.check() # Ensure connection was closed. try: - r.throwLocalException() + f.result() except: test(false) - p.ice_ping() - test(p.ice_getConnection() != con) print("ok") @@ -1232,19 +1222,20 @@ def allTests(communicator, collocated): sys.stdout.flush() # - # Local case: start a lengthy operation and then close the connection forcefully on the client side. + # Local case: start an operation and then close the connection forcefully on the client side. # There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. # p.ice_ping() con = p.ice_getConnection() - r = p.begin_sleep(100) - con.close(Ice.ConnectionClose.CloseForcefully) - r.waitForCompleted() + f = p.startDispatchAsync() + f.sent() # Ensure the request was sent before we close the connection. + con.close(Ice.ConnectionClose.Forcefully) try: - r.throwLocalException() + f.result() test(False) except Ice.ConnectionManuallyClosedException as ex: test(not ex.graceful) + p.finishDispatch() # # Remote case: the server closes the connection forcefully. This causes the request to fail @@ -1252,7 +1243,7 @@ def allTests(communicator, collocated): # will not retry. # try: - p.close(Test.CloseMode.CloseForcefully) + p.close(Test.CloseMode.Forcefully) test(False) except Ice.ConnectionLostException: # Expected. @@ -1501,7 +1492,7 @@ def allTestsFuture(communicator, collocated): test(p.opBatchCount() == 0) b1 = p.ice_batchOneway() b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FutureFlushCallback() f = b1.ice_flushBatchRequestsAsync() f.add_sent_callback(cb.sent) @@ -1533,7 +1524,7 @@ def allTestsFuture(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FutureFlushExCallback() f = b1.ice_getConnection().flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_done_callback(cb.exception) @@ -1570,7 +1561,7 @@ def allTestsFuture(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FutureFlushCallback() f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) @@ -1614,7 +1605,7 @@ def allTestsFuture(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FutureFlushCallback() f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) @@ -1636,8 +1627,8 @@ def allTestsFuture(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) - b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) + b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) cb = FutureFlushCallback() f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy) f.add_sent_callback(cb.sent) diff --git a/python/test/Ice/ami/Test.ice b/python/test/Ice/ami/Test.ice index a1d4367d5f1..74e8dc1728f 100644 --- a/python/test/Ice/ami/Test.ice +++ b/python/test/Ice/ami/Test.ice @@ -20,9 +20,9 @@ exception TestIntfException enum CloseMode { - CloseForcefully, - CloseGracefully, - CloseGracefullyAndWait + Forcefully, + Gracefully, + GracefullyWithWait }; interface TestIntf @@ -37,8 +37,11 @@ interface TestIntf bool waitForBatch(int count); void close(CloseMode mode); void sleep(int ms); + ["amd"] void startDispatch(); + void finishDispatch(); void shutdown(); + bool supportsAMD(); bool supportsFunctionalTests(); }; @@ -49,4 +52,3 @@ interface TestIntfController }; }; - diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py index 53585189f29..75deb1d08b6 100644 --- a/python/test/Ice/ami/TestI.py +++ b/python/test/Ice/ami/TestI.py @@ -13,6 +13,7 @@ class TestIntfI(Test._TestIntfDisp): def __init__(self): self._cond = threading.Condition() self._batchCount = 0 + self._pending = [] def op(self, current=None): pass @@ -49,9 +50,30 @@ class TestIntfI(Test._TestIntfDisp): def sleep(self, ms, current=None): time.sleep(ms / 1000.0) + def startDispatch(self, current=None): + f = Ice.Future() + with self._cond: + self._pending.append(f) + return f + + def finishDispatch(self, current=None): + with self._cond: + for f in self._pending: + f.set_result(None) + self._pending = [] + def shutdown(self, current=None): + # + # Just in case a request arrived late. + # + with self._cond: + for f in self._pending: + f.set_result(None) current.adapter.getCommunicator().shutdown() + def supportsAMD(self, current=None): + return True + def supportsFunctionalTests(self, current=None): return False diff --git a/python/test/Ice/binding/AllTests.py b/python/test/Ice/binding/AllTests.py index 5bf5a02a801..ab494610f03 100644 --- a/python/test/Ice/binding/AllTests.py +++ b/python/test/Ice/binding/AllTests.py @@ -110,7 +110,7 @@ def allTests(communicator): name = test1.getAdapterName() if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) # # Ensure that the proxy correctly caches the connection (we @@ -128,7 +128,7 @@ def allTests(communicator): test(i == nRetry) for a in adapters: - a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) # # Deactivate an adapter and ensure that we can still @@ -152,7 +152,7 @@ def allTests(communicator): name = test1.getAdapterName() if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) # # Deactivate an adapter and ensure that we can still @@ -194,7 +194,7 @@ def allTests(communicator): name = getAdapterNameWithAMI(test1) if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) # # Ensure that the proxy correctly caches the connection (we @@ -212,7 +212,7 @@ def allTests(communicator): test(i == nRetry) for a in adapters: - a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) # # Deactivate an adapter and ensure that we can still @@ -236,7 +236,7 @@ def allTests(communicator): name = getAdapterNameWithAMI(test1) if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) # # Deactivate an adapter and ensure that we can still @@ -266,7 +266,7 @@ def allTests(communicator): name = t.getAdapterName() if names.count(name) > 0: names.remove(name) - t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Random)) test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random) @@ -278,7 +278,7 @@ def allTests(communicator): name = t.getAdapterName() if names.count(name) > 0: names.remove(name) - t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) deactivate(com, adapters) @@ -337,13 +337,13 @@ def allTests(communicator): while i < nRetry and t.getAdapterName() == "Adapter36": i = i + 1 test(i == nRetry) - t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) adapters.append(com.createObjectAdapter("Adapter35", endpoints[1].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter35": i = i + 1 test(i == nRetry) - t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) adapters.append(com.createObjectAdapter("Adapter34", endpoints[0].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter34": @@ -618,7 +618,7 @@ def allTests(communicator): t = createTestIntfPrx(adapters) for i in range(0, 5): test(t.getAdapterName() == "Adapter82") - t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True)) test(testSecure.ice_isSecure()) @@ -632,13 +632,13 @@ def allTests(communicator): for i in range(0, 5): test(t.getAdapterName() == "Adapter81") - t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA. for i in range(0, 5): test(t.getAdapterName() == "Adapter83") - t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) com.deactivateObjectAdapter(adapters[0]) try: diff --git a/python/test/Ice/location/AllTests.py b/python/test/Ice/location/AllTests.py index 205ae91329d..25713744778 100644 --- a/python/test/Ice/location/AllTests.py +++ b/python/test/Ice/location/AllTests.py @@ -200,7 +200,7 @@ def allTests(communicator, ref): sys.stdout.flush() hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("hello")) obj.migrateHello() - hello.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) hello.sayHello() obj.migrateHello() hello.sayHello() diff --git a/python/test/Ice/operations/BatchOneways.py b/python/test/Ice/operations/BatchOneways.py index 3b17cd89954..7670db510ba 100644 --- a/python/test/Ice/operations/BatchOneways.py +++ b/python/test/Ice/operations/BatchOneways.py @@ -85,7 +85,7 @@ def batchOneways(p): batch1.ice_ping() batch2.ice_ping() batch1.ice_flushBatchRequests() - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) batch1.ice_ping() batch2.ice_ping() @@ -93,7 +93,7 @@ def batchOneways(p): batch2.ice_getConnection() batch1.ice_ping() - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) batch1.ice_ping() batch2.ice_ping() diff --git a/python/test/Ice/operations/BatchOnewaysAMI.py b/python/test/Ice/operations/BatchOnewaysAMI.py index f750b3eb02d..1b65d0973e8 100644 --- a/python/test/Ice/operations/BatchOnewaysAMI.py +++ b/python/test/Ice/operations/BatchOnewaysAMI.py @@ -61,14 +61,14 @@ def batchOneways(p): batch1.end_ice_ping(batch1.begin_ice_ping()) batch2.end_ice_ping(batch2.begin_ice_ping()) batch1.end_ice_flushBatchRequests(batch1.begin_ice_flushBatchRequests()) - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) batch1.end_ice_ping(batch1.begin_ice_ping()) batch2.end_ice_ping(batch2.begin_ice_ping()) batch1.ice_getConnection() batch2.ice_getConnection() - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) batch1.end_ice_ping(batch1.begin_ice_ping()) batch2.end_ice_ping(batch2.begin_ice_ping()) diff --git a/python/test/Ice/operations/BatchOnewaysFuture.py b/python/test/Ice/operations/BatchOnewaysFuture.py index ea1c70bcf94..7f2b89cfc81 100644 --- a/python/test/Ice/operations/BatchOnewaysFuture.py +++ b/python/test/Ice/operations/BatchOnewaysFuture.py @@ -63,14 +63,14 @@ def batchOneways(p): batch1.ice_pingAsync() batch2.ice_pingAsync() batch1.ice_flushBatchRequestsAsync().result() - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) batch1.ice_pingAsync() batch2.ice_pingAsync() batch1.ice_getConnection() batch2.ice_getConnection() - batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait) test(not batch1.ice_pingAsync().done()) test(not batch2.ice_pingAsync().done()) diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py index 9f4fda18962..22469287a2c 100644 --- a/python/test/Ice/timeout/AllTests.py +++ b/python/test/Ice/timeout/AllTests.py @@ -155,7 +155,7 @@ def allTests(communicator): to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(100)) connection = to.ice_getConnection() timeout.holdAdapter(500) - connection.close(Ice.ConnectionClose.CloseGracefullyAndWait) + connection.close(Ice.ConnectionClose.GracefullyWithWait) try: connection.getInfo(); # getInfo() doesn't throw in the closing state. except Ice.LocalException: diff --git a/ruby/test/Ice/binding/AllTests.rb b/ruby/test/Ice/binding/AllTests.rb index 605063c96e4..e6a500a85f9 100644 --- a/ruby/test/Ice/binding/AllTests.rb +++ b/ruby/test/Ice/binding/AllTests.rb @@ -92,7 +92,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - test1.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + test1.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end # @@ -113,7 +113,7 @@ def allTests(communicator) test(i == nRetry) for a in adapters - a.getTestIntf().ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + a.getTestIntf().ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end # @@ -139,7 +139,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - test1.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + test1.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end # @@ -171,7 +171,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + t.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end t = Test::TestIntfPrx::uncheckedCast(t.ice_endpointSelection(Ice::EndpointSelectionType::Random)) @@ -185,7 +185,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + t.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end deactivate(com, adapters) @@ -250,14 +250,14 @@ def allTests(communicator) i = i + 1 end test(i == nRetry) - t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + t.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) adapters.push(com.createObjectAdapter("Adapter35", endpoints[1].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter35" i = i + 1 end test(i == nRetry) - t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + t.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) adapters.push(com.createObjectAdapter("Adapter34", endpoints[0].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter34" @@ -442,7 +442,7 @@ def allTests(communicator) t = createTestIntfPrx(adapters) for i in 0...5 test(t.getAdapterName() == "Adapter82") - t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + t.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end testSecure = Test::TestIntfPrx::uncheckedCast(t.ice_secure(true)) @@ -457,14 +457,14 @@ def allTests(communicator) for i in 0...5 test(t.getAdapterName() == "Adapter81") - t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + t.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA. for i in 0...5 test(t.getAdapterName() == "Adapter83") - t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + t.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) end com.deactivateObjectAdapter(adapters[0]) diff --git a/ruby/test/Ice/operations/BatchOneways.rb b/ruby/test/Ice/operations/BatchOneways.rb index 1935c52f1e8..e5a15b23702 100644 --- a/ruby/test/Ice/operations/BatchOneways.rb +++ b/ruby/test/Ice/operations/BatchOneways.rb @@ -35,7 +35,7 @@ def batchOneways(p) batch.ice_ping() batch2.ice_ping() batch.ice_flushBatchRequests() - batch.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + batch.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) batch.ice_ping() batch2.ice_ping() @@ -43,7 +43,7 @@ def batchOneways(p) batch2.ice_getConnection() batch.ice_ping() - batch.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) + batch.ice_getConnection().close(Ice::ConnectionClose::GracefullyWithWait) batch.ice_ping() batch2.ice_ping() diff --git a/ruby/test/Ice/timeout/AllTests.rb b/ruby/test/Ice/timeout/AllTests.rb index 6c9ccc7ea55..9a65cdd39b8 100644 --- a/ruby/test/Ice/timeout/AllTests.rb +++ b/ruby/test/Ice/timeout/AllTests.rb @@ -98,7 +98,7 @@ def allTests(communicator) to = Test::TimeoutPrx.checkedCast(obj.ice_timeout(100)) connection = to.ice_getConnection() timeout.holdAdapter(500) - connection.close(Ice::ConnectionClose::CloseGracefullyAndWait) + connection.close(Ice::ConnectionClose::GracefullyWithWait) begin connection.getInfo() # getInfo() doesn't throw in the closing state. rescue Ice::LocalException diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice index c044f056581..014f7e93c23 100644 --- a/slice/Ice/Connection.ice +++ b/slice/Ice/Connection.ice @@ -130,7 +130,6 @@ local interface HeartbeatCallback void heartbeat(Connection con); }; - local enum ACMClose { CloseOff, @@ -158,21 +157,23 @@ local struct ACM /** * Determines the behavior when manually closing a connection. **/ +["cpp:scoped", "objc:scoped"] local enum ConnectionClose { /** * Close the connection immediately without sending a close connection protocol message to the peer * and waiting for the peer to acknowledge it. **/ - CloseForcefully, + Forcefully, /** - * Close the connection by notifying the peer but do not wait for pending invocations to complete. + * Close the connection by notifying the peer but do not wait for pending outgoing invocations to complete. + * On the server side, the connection will not be closed until all incoming invocations have completed. **/ - CloseGracefully, + Gracefully, /** * Wait for all pending invocations to complete before closing the connection. **/ - CloseGracefullyAndWait + GracefullyWithWait }; /** |