datacommsserver/esockserver/ssock/ss_mmcommsprov.cpp
branchRCL_3
changeset 29 9644881fedd0
parent 14 8b5d60ce1e94
child 66 cbb19216b74d
--- a/datacommsserver/esockserver/ssock/ss_mmcommsprov.cpp	Tue May 11 17:20:19 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_mmcommsprov.cpp	Tue May 25 14:00:39 2010 +0300
@@ -19,7 +19,8 @@
 
 #include "ss_mmcommsprov.h"
 #include <elements/nm_messages_child.h>
-#include <elements/mm_activities.h> 
+#include <elements/mm_activities.h>
+#include <comms-infras/corecpractivities.h> 
 #include "ss_nodemessages_internal.h"
 #include "ss_internal_activities.h"
 
@@ -32,6 +33,10 @@
 using namespace ESock;
 using namespace Messages;
 
+//We reserve space for two preallocated activities that may start concurrently on the connection
+//node: destroy (connection close) and connection stop.
+static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>);
+
 CMMCommsProviderBase::CMMCommsProviderBase(CCommsFactoryBase& aFactory,
                                     const MeshMachine::TNodeActivityMap& aActivityMap)
 :	ACommsFactoryNodeId(aFactory),
@@ -112,6 +117,23 @@
 	aInterface = this;
 	}
 
+EXPORT_C RNodeInterface* CMMCommsProviderBase::AddClientL(const Messages::TNodeId& aClientId, const Messages::TClientType& aClientType, TAny* aClientInfo)
+	{
+	RNodeInterface* nodeInterface = ANodeBase::AddClientL(aClientId, aClientType, aClientInfo);
+
+	if(aClientType.Type() == TCFClientType::ECtrl)
+		{
+		TRAPD(err, nodeInterface->PreAllocL(KMaxPreallocatedActivitySize));
+		if(err!=KErrNone)
+			{
+			RemoveClient(nodeInterface->RecipientId());
+			User::Leave(err);
+			}
+		}
+
+	return nodeInterface;
+	}
+
 void CMMCommsProviderBase::DestroyOrphanedDataClients()
 	{
     // Note: If PRDataClientStopActivity is running, it will call PRStates::TDestroyOrphanedDataClients