diff options
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/allTests.py | 69 | ||||
-rw-r--r-- | cpp/include/Ice/OutgoingAsync.h | 15 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 122 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Freeze/dbmap/Client.cpp | 17 |
5 files changed, 84 insertions, 141 deletions
diff --git a/cpp/allTests.py b/cpp/allTests.py index 210b340456c..0155c356dbd 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -14,6 +14,7 @@ # ********************************************************************** import os, sys +import optparse for toplevel in [".", "..", "../..", "../../..", "../../../.."]: toplevel = os.path.normpath(toplevel) @@ -25,6 +26,31 @@ else: sys.path.append(os.path.join(toplevel, "config")) import TestUtil +def runTests(tests, num = 0): + + # + # Run each of the tests. + # + for i in tests: + + i = os.path.normpath(i) + dir = os.path.join(toplevel, "test", i) + + print + if(num > 0): + print "[" + str(num) + "]", + print "*** running tests in " + dir, + print + + try: + execfile(os.path.join(dir, "run.py")) + except SystemExit, (status,): + if status: + if(num > 0): + print "[" + str(num) + "]", + print "test in " + dir + " failed with exit status", status, + sys.exit(status) + # # List of all basic tests. # @@ -58,37 +84,20 @@ tests = [ \ "IceStorm/federation2", \ "FreezeScript/dbmap", \ "FreezeScript/evictor", \ -# "IcePack/simple", \ -# "IcePack/deployer", \ + "IcePack/simple", \ + "IcePack/deployer", \ "Glacier/starter", \ ] -# -# The user can supply a subset of tests on the command line. -# -if sys.argv[1:]: - print "limiting tests" - newtests = [] - for i in tests: - if i in sys.argv[1:]: - newtests.append(i) - tests = newtests - -# -# Run each of the tests. -# -for i in tests: +parser = optparse.OptionParser() +parser.add_option("-l", "--loop", action="store_true", dest="loop", default=False, + help="run tests continously in an endless loop") +(options, args) = parser.parse_args() - i = os.path.normpath(i) - dir = os.path.join(toplevel, "test", i) - - print - print "*** running tests in " + dir + ":" - print - - try: - execfile(os.path.join(dir, "run.py")) - except SystemExit, (status,): - if status: - print "test failed with exit status", status - sys.exit(status) +if options.loop: + num = 1 + while 1: + runTests(tests, num) + num += 1 +else: + runTests(tests) diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index d4ed36215d2..809e05aee44 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -15,8 +15,6 @@ #ifndef ICE_OUTGOING_ASYNC_H #define ICE_OUTGOING_ASYNC_H -#include <IceUtil/Mutex.h> -#include <IceUtil/Monitor.h> #include <IceUtil/Time.h> #include <Ice/OutgoingAsyncF.h> #include <Ice/ReferenceF.h> @@ -69,19 +67,6 @@ private: Ice::OperationMode _mode; IceUtil::Time _absoluteTimeout; - - // - // We don't want to derive from a mutex, because this would be too - // intrusive for user code, i.e., classes that derive from this - // one in order to implement ice_exception() and ice_response(). - // - IceUtil::Monitor<IceUtil::Mutex> _monitor; - - enum - { - StateUnsent, - StateSent - } _state; }; } diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 13640e70677..a4ac2f3e7ae 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -35,42 +35,34 @@ void IceInternal::decRef(AMI_Object_ice_invoke* p) { p->__decRef(); } IceInternal::OutgoingAsync::OutgoingAsync() : __is(0), - __os(0), - _state(StateUnsent) + __os(0) { } IceInternal::OutgoingAsync::~OutgoingAsync() { - assert(!_reference); - assert(!_connection); - assert(!__is); - assert(!__os); + delete __is; + delete __os; } void IceInternal::OutgoingAsync::__finished(BasicStream& is) { // - // Wait until sending has completed. + // No mutex protection necessary, this function can only be called + // after __send() and __prepare() have completed. // - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - while(_state < StateSent) - { - _monitor.wait(); - } - } assert(_reference); assert(_connection); - assert(__is); - assert(__os); DispatchStatus status; try { + delete __is; + __is = new BasicStream(_reference->instance.get()); + __is->swap(is); Byte b; @@ -171,20 +163,12 @@ void IceInternal::OutgoingAsync::__finished(const LocalException& exc) { // - // Wait until sending has completed. + // No mutex protection necessary, this function can only be called + // after __send() and __prepare() have completed. // - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - while(_state < StateSent) - { - _monitor.wait(); - } - } assert(_reference); - assert(_connection); - assert(__is); - assert(__os); + //assert(_connection); // Might be null, if getConnection() failed. if(_reference->locatorInfo) { @@ -224,11 +208,6 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc) if(doRetry) { - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - assert(_state == StateSent); - _state = StateUnsent; - } _connection = 0; __send(); } @@ -236,7 +215,6 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc) { try { - __cleanup(); ice_exception(exc); } catch(const Exception& ex) @@ -257,7 +235,14 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc) bool IceInternal::OutgoingAsync::__timedOut() const { - if(_connection && _connection->timeout() >= 0) + // + // No mutex protection necessary, this function can only be called + // after __send() and __prepare() have completed. + // + + assert(_connection); + + if(_connection->timeout() >= 0) { return IceUtil::Time::now() >= _absoluteTimeout; } @@ -271,20 +256,20 @@ void IceInternal::OutgoingAsync::__prepare(const ReferencePtr& ref, const string& operation, OperationMode mode, const Context& context) { - assert(!_reference); - assert(!_connection); - assert(!__is); - assert(!__os); - assert(_state == StateUnsent); + // + // No mutex protection necessary, using this object for a new AMI + // call while another one is in progress is not allowed and leads + // to undefined behavior. + // _reference = ref; _connection = _reference->getConnection(); - __is = new BasicStream(_reference->instance.get()); - __os = new BasicStream(_reference->instance.get()); - _cnt = 0; _mode = mode; + delete __os; + __os = new BasicStream(_reference->instance.get()); + _connection->prepareRequest(__os); _reference->identity.__write(__os); __os->write(_reference->facet); @@ -305,10 +290,7 @@ void IceInternal::OutgoingAsync::__send() { assert(_reference); - //assert(_connection); // Might be 0, in case we retry from __finished(). - assert(__is); - assert(__os); - assert(_state == StateUnsent); + //assert(_connection); // Might be null, if called from __finished() for retry. try { @@ -327,7 +309,15 @@ IceInternal::OutgoingAsync::__send() try { _connection->sendAsyncRequest(__os, this); - break; + + // + // Don't do anything after sendAsyncRequest() returned + // without an exception. I such case, there will be + // callbacks, i.e., calls to the __finished() + // functions. Since there is no mutex protection, we + // cannot modify state here and in such callbacks. + // + return; } catch(const LocalException& ex) { @@ -352,44 +342,7 @@ IceInternal::OutgoingAsync::__send() } catch(const LocalException& ex) { - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - assert(_state == StateUnsent); - _state = StateSent; - _monitor.notify(); - } - __finished(ex); - return; - } - - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - assert(_state == StateUnsent); - _state = StateSent; - _monitor.notify(); - } -} - -void -IceInternal::OutgoingAsync::__cleanup() -{ - assert(_reference); - assert(_connection); - assert(__is); - assert(__os); - - _reference = 0; - _connection = 0; - delete __is; - __is = 0; - delete __os; - __os = 0; - - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - assert(_state == StateSent); - _state = StateUnsent; } } @@ -455,6 +408,5 @@ Ice::AMI_Object_ice_invoke::__response(bool ok) // ok == true means no user exce __finished(ex); return; } - __cleanup(); ice_response(ok, outParams); } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index b5c5f1f4c8a..acb44b529af 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -3453,11 +3453,9 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) C << eb; C << nl << "catch(const ::Ice::UserException& __ex)"; C << sb; - C << nl << "__cleanup();"; C << nl << "ice_exception(__ex);"; C << nl << "return;"; C << eb; - C << nl << "__cleanup();"; C << nl << "ice_response" << spar << args << epar << ';'; C << eb; } diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp index c528d18c7e8..7c24ed7abcb 100644 --- a/cpp/test/Freeze/dbmap/Client.cpp +++ b/cpp/test/Freeze/dbmap/Client.cpp @@ -215,7 +215,7 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN ByteIntMap::iterator p; ByteIntMap::const_iterator cp; - cout << " testing populate... "; + cout << "testing populate... "; // // First try non-const iterator // @@ -239,7 +239,7 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN test(m.size() == alphabet.size()); cout << "ok" << endl; - cout << " testing map::find... "; + cout << "testing map::find... "; j = find(alphabet.begin(), alphabet.end(), 'n'); cp = m.find(*j); @@ -247,7 +247,7 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN test(cp->first == 'n' && cp->second == j - alphabet.begin()); cout << "ok" << endl; - cout << " testing erase... "; + cout << "testing erase... "; // // erase first offset characters (first offset characters is @@ -289,12 +289,12 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN // // Get an iterator for the deleted element - this should fail. // - cout << " testing map::find (again)... "; + cout << "testing map::find (again)... "; cp = m.find('a'); test(cp == m.end()); cout << "ok" << endl; - cout << " testing iterators... "; + cout << "testing iterators... "; p = m.begin(); ByteIntMap::iterator p2 = p; @@ -354,7 +354,7 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN // // Test writing into an iterator. // - cout << " testing iterator.set... "; + cout << "testing iterator.set... "; p = m.find('d'); test(p != m.end() && p->second == 3); @@ -430,7 +430,7 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN // populateDB(connection, m); - cout << " testing algorithms... "; + cout << "testing algorithms... "; for_each(m.begin(), m.end(), ForEachTest); @@ -490,7 +490,7 @@ run(const CommunicatorPtr& communicator, const string& envName, const string&dbN } cout << "ok" << endl; - cout << " testing concurrent access... " << flush; + cout << "testing concurrent access... " << flush; m.clear(); populateDB(connection, m); @@ -529,7 +529,6 @@ main(int argc, char* argv[]) envName += "db"; } - cout << "testing encoding..." << endl; status = run(communicator, envName, "binary"); } catch(const Ice::Exception& ex) |