userlibandfileserver/fileserver/shostmassstorage/server/src/cusbhostmssession.cpp
equal
deleted
inserted
replaced
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
112 { |
112 { |
113 aMessage.Complete(r); |
113 aMessage.Complete(r); |
114 return; |
114 return; |
115 } |
115 } |
116 break; |
116 break; |
117 case EUsbHostMsUnRegisterInterface: |
117 case EUsbHostMsUnRegisterInterface: |
118 iCleanupInProgress = ETrue; |
118 if(iCleanupInProgress) |
|
119 { |
|
120 aMessage.Complete(KErrInUse); |
|
121 return; |
|
122 } |
|
123 else |
|
124 { |
|
125 iCleanupInProgress = ETrue; |
|
126 } |
119 break; |
127 break; |
120 /* If it is a cleanup then we need to delete the iDeviceThread */ |
128 /* If it is a cleanup then we need to delete the iDeviceThread */ |
121 case EUsbHostMsFinalCleanup: |
129 case EUsbHostMsFinalCleanup: |
122 delete iDeviceThread; |
130 delete iDeviceThread; |
123 iDeviceThread = NULL; |
131 iDeviceThread = NULL; |
126 return; |
134 return; |
127 default: |
135 default: |
128 break; |
136 break; |
129 } |
137 } |
130 |
138 |
131 if (iDeviceThread == NULL || iCleanupInProgress ) |
139 if (iDeviceThread == NULL) |
132 { |
140 { |
133 aMessage.Complete(KErrBadHandle); |
141 aMessage.Complete(KErrBadHandle); |
134 return; |
142 return; |
135 } |
143 } |
136 |
144 |
|
145 if (iCleanupInProgress && aMessage.Function() != EUsbHostMsUnRegisterInterface) |
|
146 { |
|
147 aMessage.Complete(KErrBadHandle); |
|
148 return; |
|
149 } |
137 |
150 |
138 r = iDeviceThread->QueueMsg(aMessage); |
151 r = iDeviceThread->QueueMsg(aMessage); |
139 if (r != KErrNone) |
152 if (r != KErrNone) |
140 { |
153 { |
141 aMessage.Complete(r); |
154 aMessage.Complete(r); |
172 { |
185 { |
173 delete iDeviceThread; |
186 delete iDeviceThread; |
174 iDeviceThread = NULL; |
187 iDeviceThread = NULL; |
175 User::Leave(r); |
188 User::Leave(r); |
176 } |
189 } |
177 iThread.SetPriority(EPriorityAbsoluteBackgroundNormal); |
190 iThread.SetPriority(EPriorityAbsoluteForeground); |
178 TRequestStatus status; |
191 TRequestStatus status; |
179 iThread.Rendezvous(status); |
192 iThread.Rendezvous(status); |
180 iThread.Resume(); |
193 iThread.Resume(); |
181 User::WaitForRequest(status); |
194 User::WaitForRequest(status); |
182 if(status != KErrNone) |
195 if(status != KErrNone) |