summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-06-10 12:09:55 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-06-10 12:09:55 +0200
commita248a9a3e8a9495d439d1c6ecfc991eb2494e7d0 (patch)
tree71a263eb13515e9dc7243a90349893870e9d2556 /cpp
parentUpdate valgrind suppressions file (diff)
downloadice-a248a9a3e8a9495d439d1c6ecfc991eb2494e7d0.tar.bz2
ice-a248a9a3e8a9495d439d1c6ecfc991eb2494e7d0.tar.xz
ice-a248a9a3e8a9495d439d1c6ecfc991eb2494e7d0.zip
Fixed Glacier2 session helper and optional test leak
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Glacier2Lib/SessionHelper.cpp20
-rw-r--r--cpp/test/Ice/optional/AllTests.cpp37
2 files changed, 35 insertions, 22 deletions
diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp
index 1a9ba94809c..9dc2d51e99c 100644
--- a/cpp/src/Glacier2Lib/SessionHelper.cpp
+++ b/cpp/src/Glacier2Lib/SessionHelper.cpp
@@ -144,11 +144,12 @@ public:
virtual void run()
{
_session->destroyInternal(_disconnected);
+ _session = 0;
}
private:
- const SessionHelperIPtr _session;
+ SessionHelperIPtr _session;
const Ice::DispatcherCallPtr _disconnected;
};
@@ -549,12 +550,13 @@ public:
_session->dispatchCallback(new ConnectFailed(_callback, _session, ex), 0);
}
+ _session = 0;
}
private:
const Glacier2::SessionCallbackPtr _callback;
- const SessionHelperIPtr _session;
+ SessionHelperIPtr _session;
const ConnectStrategyPtr _factory;
const Ice::CommunicatorPtr _communicator;
const string _finder;
@@ -577,11 +579,12 @@ public:
virtual void run()
{
_session->dispatchCallback(_call, _conn);
+ _session = 0;
}
private:
- const SessionHelperIPtr _session;
+ SessionHelperIPtr _session;
const Ice::DispatcherCallPtr _call;
const Ice::ConnectionPtr _conn;
};
@@ -867,7 +870,16 @@ Glacier2::SessionFactoryHelper::addThread(const SessionHelper* session, const Ic
// we just replace it.
//
IceUtil::Mutex::Lock sync(_mutex);
- _threads.insert(make_pair(session, thread));
+ map<const SessionHelper*, IceUtil::ThreadPtr>::iterator p = _threads.find(session);
+ if(p != _threads.end())
+ {
+ p->second->getThreadControl().join();
+ p->second = thread;
+ }
+ else
+ {
+ _threads.insert(make_pair(session, thread));
+ }
}
void
diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp
index fe504c3c255..df84e0a0fde 100644
--- a/cpp/test/Ice/optional/AllTests.cpp
+++ b/cpp/test/Ice/optional/AllTests.cpp
@@ -121,7 +121,7 @@ public:
test(s == "test");
IceUtil::Optional<vector<string> > o;
in->read(1, o);
- test(o && o->size() == 4 &&
+ test(o && o->size() == 4 &&
(*o)[0] == "test1" && (*o)[1] == "test2" && (*o)[2] == "test3" && (*o)[3] == "test4");
in->read(1000, a);
in->endSlice();
@@ -166,7 +166,7 @@ public:
in->endObject(false);
}
- FPtr
+ FPtr
getF()
{
return _f;
@@ -188,7 +188,7 @@ public:
}
Ice::ObjectPtr
- create(const string& typeId)
+ create(const string& typeId)
{
if(!_enabled)
{
@@ -219,7 +219,7 @@ public:
{
return new FObjectReader;
}
-
+
return 0;
}
@@ -237,7 +237,7 @@ typedef IceUtil::Handle<FactoryI> FactoryIPtr;
InitialPrx
allTests(const Ice::CommunicatorPtr& communicator, bool)
-{
+{
FactoryIPtr factory = new FactoryI();
communicator->addObjectFactory(factory, "");
@@ -286,7 +286,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
mo1->i = Test::MyEnumMember;
mo1->j = MultiOptionalPrx::uncheckedCast(communicator->stringToProxy("test"));
mo1->k = mo1;
- mo1->bs = ByteSeq();
+ mo1->bs = ByteSeq();
(*mo1->bs).push_back(5);
mo1->ss = StringSeq();
mo1->ss->push_back("test");
@@ -332,6 +332,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
mo1->bos->push_back(false);
mo1->bos->push_back(true);
mo1->bos->push_back(false);
+ mo1->ice_collectable(true);
MultiOptionalPtr mo2 = new MultiOptional(*mo1);
@@ -429,7 +430,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
test(!mo4->ioopd);
test(!mo4->bos);
-
+
mo1->k = mo1;
MultiOptionalPtr mo5 = MultiOptionalPtr::dynamicCast(initial->pingPong(mo1));
test(mo5->a == mo1->a);
@@ -620,7 +621,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
RecursivePtr outer = new Recursive();
outer->value = recursive1;
initial->pingPong(outer);
-
+
cout << "ok" << endl;
cout << "testing marshalling of large containers with fixed size elements..." << flush;
@@ -673,7 +674,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
test(!b2->ma);
test(!b2->mb);
test(!b2->mc);
-
+
b->ma = 10;
b->mb = 11;
b->mc = 12;
@@ -757,7 +758,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
in->startEncapsulation();
in->read(obj);
in->endEncapsulation();
- test(dynamic_cast<CObjectReader*>(obj.get()));
+ test(dynamic_cast<CObjectReader*>(obj.get()));
factory->setEnabled(false);
factory->setEnabled(true);
@@ -775,7 +776,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
test(obj && dynamic_cast<DObjectReader*>(obj.get()));
dynamic_cast<DObjectReader*>(obj.get())->check();
factory->setEnabled(false);
- }
+ }
cout << "ok" << endl;
cout << "testing optionals with unknown classes..." << flush;
@@ -818,10 +819,10 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
in->startEncapsulation();
in->read(1, p2);
in->read(3, p3);
-
+
IceUtil::Optional<Ice::Byte> p4 = 0x08;
in->read(89, p4);
-
+
in->endEncapsulation();
test(p2 == 56 && p3 == 56 && !p4);
@@ -1033,7 +1034,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
IceUtil::Optional<string> p3;
IceUtil::Optional<string> p2 = initial->opCustomString(p1, p3);
test(!p2 && !p3);
-
+
p1 = "test";
p2 = initial->opString("test", p3);
test(p2 == "test" && p3 == "test");
@@ -1246,7 +1247,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
IceUtil::Optional<APtr> a;
in->read(2, a);
in->endEncapsulation();
- test(a && *a && (*a)->requiredA == 56);
+ test(a && *a && (*a)->requiredA == 56);
}
cout << "ok" << endl;
@@ -1321,7 +1322,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
in = Ice::createInputStream(communicator, outEncaps);
in->startEncapsulation();
- in->endEncapsulation();
+ in->endEncapsulation();
}
{
@@ -1588,7 +1589,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
in = Ice::createInputStream(communicator, outEncaps);
in->startEncapsulation();
- in->endEncapsulation();
+ in->endEncapsulation();
}
{
@@ -1687,7 +1688,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool)
in->startEncapsulation();
in->endEncapsulation();
}
-
+
{
if(supportsCppStringView)
{