userlibandfileserver/fileserver/shostmassstorage/server/src/cusbhostmssession.cpp
branchRCL_3
changeset 268 345b1ca54e88
parent 248 0ffb4e86fcc9
child 294 039a3e647356
--- a/userlibandfileserver/fileserver/shostmassstorage/server/src/cusbhostmssession.cpp	Tue Sep 14 23:56:21 2010 +0300
+++ b/userlibandfileserver/fileserver/shostmassstorage/server/src/cusbhostmssession.cpp	Wed Sep 15 13:42:27 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of the License "Eclipse Public License v1.0"
@@ -114,8 +114,16 @@
 			return;
 			}
 		break;
-	case EUsbHostMsUnRegisterInterface:
-		iCleanupInProgress = ETrue;
+    case EUsbHostMsUnRegisterInterface:
+        if(iCleanupInProgress)
+            {
+            aMessage.Complete(KErrInUse);
+            return;
+            }
+        else
+            {
+            iCleanupInProgress = ETrue;
+            }
 		break;
 	/* If it is a cleanup then we need to delete the iDeviceThread */
 	case EUsbHostMsFinalCleanup:	
@@ -128,12 +136,17 @@
 		break;
 		}
 
-	if (iDeviceThread == NULL || iCleanupInProgress ) 
+	if (iDeviceThread == NULL) 
 		{
 		aMessage.Complete(KErrBadHandle);
 		return;
 		}
 
+    if (iCleanupInProgress && aMessage.Function() != EUsbHostMsUnRegisterInterface) 
+        {
+        aMessage.Complete(KErrBadHandle);
+        return;
+        }
 
 	r = iDeviceThread->QueueMsg(aMessage);
 	if (r != KErrNone)