networkcontrol/ipnetworklayer/src/flow.cpp
changeset 14 b33c3d136b7e
parent 0 af10295192d8
--- a/networkcontrol/ipnetworklayer/src/flow.cpp	Tue Feb 02 01:27:53 2010 +0200
+++ b/networkcontrol/ipnetworklayer/src/flow.cpp	Fri Apr 16 16:36:59 2010 +0300
@@ -341,25 +341,33 @@
 
 		if (proto.Length() > 0)
 			{
-			CIPProtoBinder* protoBinder = CIPProtoBinder::NewL(*this, proto);
-			CleanupStack::PushL(protoBinder);
+            CIPProtoBinder* protoBinder = FindBinderForProto(proto); 
+            if (!protoBinder)
+                {
+                protoBinder = CIPProtoBinder::NewL(*this, proto);
+                CleanupStack::PushL(protoBinder);
 
-			CIPShimIfBase* nif = ProtocolIntf()->FindOrCreateNifL(proto,
-				reinterpret_cast<const TConnectionInfo&>(*iConnectionInfo.Ptr()));
-			TCleanupNifPair cleanuppair(nif);
-			CleanupStack::PushL(TCleanupItem(TCleanupNifPair::CleanupReleaseNif, &cleanuppair));
+                CIPShimIfBase* nif = ProtocolIntf()->FindOrCreateNifL(proto,
+                    reinterpret_cast<const TConnectionInfo&>(*iConnectionInfo.Ptr()));
+                TCleanupNifPair cleanuppair(nif);
+                CleanupStack::PushL(TCleanupItem(TCleanupNifPair::CleanupReleaseNif, &cleanuppair));
 
-			__CFLOG_VAR((KIPProtoTag1, KIPProtoTag2, _L8("CIPShimSubConnectionFlow %08x:\tBindToL(): nif 0x%08x, binder 0x%08x"), this, nif, protoBinder));
-			nif->BindToL(protoBinder);
-			cleanuppair.iBinder = protoBinder;
-
-			protoBinder->BindToLowerFlowL(*binderControl);
+                __CFLOG_VAR((KIPProtoTag1, KIPProtoTag2, _L8("CIPShimSubConnectionFlow %08x:\tBindToL(): nif 0x%08x, binder 0x%08x"), this, nif, protoBinder));
+                nif->BindToL(protoBinder);
+                cleanuppair.iBinder = protoBinder;
+    
+                protoBinder->BindToLowerFlowL(*binderControl);
+    
+                iBinderList.AppendL(protoBinder);
 
-			iBinderList.AppendL(protoBinder);
+                CleanupStack::Pop(2);
 
-			CleanupStack::Pop(2);
-
-			InitialiseDataMonitoringL(nif);
+                InitialiseDataMonitoringL(nif);
+                }
+            else
+                {
+                InitialiseDataMonitoringL(protoBinder->iNif);
+                }
 			}
 		}
 	while (pos != KErrNotFound);
@@ -373,7 +381,22 @@
 		}
 	}
 
-
+CIPProtoBinder* CIPShimSubConnectionFlow::FindBinderForProto(const TDesC8& aProtocol)
+    {
+    TInt i = iBinderList.Count();
+    while (--i >= 0)
+        {
+        if (iBinderList[i]->iProtocolName == aProtocol)
+            {
+            __CFLOG_VAR((KIPProtoTag1, KIPProtoTag2, _L8("CIPShimSubConnectionFlow %08x:\tFindBinderForProto(): Found existing binder for proto '%S'"),
+                this, &aProtocol));
+            return iBinderList[i];
+            }
+        }
+    __CFLOG_VAR((KIPProtoTag1, KIPProtoTag2, _L8("CIPShimSubConnectionFlow %08x:\tFindBinderForProto(): No binder for proto '%S'"),
+        this, &aProtocol));
+    return NULL;
+    }
 
 void CIPShimSubConnectionFlow::StartFlowL()
 /**