telephonyprotocols/rawipnif/src/Receiver.cpp
branchRCL_3
changeset 83 ea777f234bd4
parent 82 042fd2753b8f
--- a/telephonyprotocols/rawipnif/src/Receiver.cpp	Fri Sep 17 17:35:51 2010 +0100
+++ b/telephonyprotocols/rawipnif/src/Receiver.cpp	Fri Oct 22 16:04:25 2010 +0100
@@ -124,25 +124,36 @@
 	else
 	    {
         _LOG_L1C1(_L8("CReceiver: Data Packet Received"));
-    
-        iRMBufPacket.CreateL(iData);
         
-        // Immediately execute new read request.
+        // Trap the leave to prevent the flow from being stopped if 
+        // the MBuf pool is temporarily exhausted.
+        TRAPD(err,iRMBufPacket.CreateL(iData));
+        
+        // Immediately execute new read request, regardless of whether MBufs are
+        // exhausted or not.
         (iObserver.Bca())->Read(iStatus, iData);
-    
+     
         SetActive();
-        
-        iRMBufPacket.Pack();
     
-#ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
-        TUint16 protocolCode = iObserver.RemoveHeader(iRMBufPacket);
-#else
-        TUint16 protocolCode = 0;
-#endif // RAWIP_HEADER_APPENDED_TO_PACKETS
-    
-        // Process the packet
-        iObserver.GetObserver().Process(iRMBufPacket, protocolCode);
-        iRMBufPacket.Free();
+        if (err == KErrNone)
+             {
+             iRMBufPacket.Pack();
+     
+    #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
+             TUint16 protocolCode = iObserver.RemoveHeader(iRMBufPacket);
+    #else
+             TUint16 protocolCode = 0;
+    #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
+     
+             // Process the packet
+             iObserver.GetObserver().Process(iRMBufPacket, protocolCode);
+             iRMBufPacket.Free();
+             }
+        else
+             {
+             // If MBuff Allocation failed then dont process the packet, rely on layers above for recovery
+             _LOG_L2C2(_L8("CReceiver::RunL MBuff Allocation Failure [err=%d]"), err);
+             }
 	    }
 	}