userlibandfileserver/fileserver/shostmassstorage/server/protocol/cscsiprotocol.cpp
branchanywhere
changeset 41 d32f34975bbf
parent 33 0173bcd7697c
child 62 4a8fed1c0ef6
--- a/userlibandfileserver/fileserver/shostmassstorage/server/protocol/cscsiprotocol.cpp	Mon Feb 01 19:40:00 2010 +0100
+++ b/userlibandfileserver/fileserver/shostmassstorage/server/protocol/cscsiprotocol.cpp	Mon Feb 01 19:49:38 2010 +0100
@@ -70,6 +70,11 @@
 	__MSFNLOG
     iFsm = CMassStorageFsm::NewL(*this);
 	iState = EDisconnected;
+
+    const TInt blockLength = 0x200;
+
+    iHeadbuf.CreateL(blockLength);
+    iTailbuf.CreateL(blockLength);
     }
 
 
@@ -85,6 +90,8 @@
     {
 	__MSFNLOG
     delete iFsm;
+    iHeadbuf.Close();
+    iTailbuf.Close();
     delete iSbcInterface;
     }
 
@@ -253,7 +260,15 @@
 	TLba lastLba;
 	TUint32 blockLength;
 
-	TInt err = iSbcInterface->ReadCapacity10L(lastLba, blockLength);
+    // Retry ReadCapacity10L if stalled
+    TInt stallCounter = 4;
+    TInt err = KErrNone;
+    do
+        {
+        err = iSbcInterface->ReadCapacity10L(lastLba, blockLength);
+        } while (err == KErrCommandStalled && stallCounter-- > 0);
+
+
     if (err)
         {
         if (err == KErrCommandFailed)
@@ -351,6 +366,7 @@
 
     // SCSI Block device
     iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport());
+    iSbcInterface->InitBuffers(&iHeadbuf, &iTailbuf);
 
     return KErrNone;
     }
@@ -653,7 +669,8 @@
     // SCSI Block device
     ASSERT(iSbcInterface == NULL);
     iSbcInterface = new (ELeave) TSbcClientInterface(iSpcInterface.Transport());
-    iSbcInterface->SetCapacity(aBlockLen, aLastLba);
+    iSbcInterface->InitBuffers(&iHeadbuf, &iTailbuf);
+    iSbcInterface->SetCapacityL(aBlockLen, aLastLba);
     }