1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-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 "Eclipse Public License v1.0" |
4 // under the terms of "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". |
25 |
25 |
26 #include "shmadebug.h" |
26 #include "shmadebug.h" |
27 #include "shmapanic.h" |
27 #include "shmapanic.h" |
28 #include <u32hal.h> |
28 #include <u32hal.h> |
29 |
29 |
|
30 #ifdef _DEBUG |
|
31 #include <e32property.h> |
|
32 #endif // _DEBUG |
|
33 |
30 const TInt CMonitor::iOffset = _FOFF(CMonitor, iSglQueLink); |
34 const TInt CMonitor::iOffset = _FOFF(CMonitor, iSglQueLink); |
31 const TInt KDelayRequiredForRestartSys = 5000000; // required by RestartSys API, see comments in RestartSys::RestartSystem() |
35 const TInt KDelayRequiredForRestartSys = 5000000; // required by RestartSys API, see comments in RestartSys::RestartSystem() |
32 |
36 |
33 #ifdef SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
37 #ifdef SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
34 _LIT(KRestartSysProxyDLL, "restartsys.dll"); |
38 _LIT(KRestartSysProxyDLL, "restartsys.dll"); |
143 void CMonitor::RestartProcessL() |
147 void CMonitor::RestartProcessL() |
144 { |
148 { |
145 #ifdef _DEBUG |
149 #ifdef _DEBUG |
146 TPtrC fileName = iStartupProperties->FileName(); |
150 TPtrC fileName = iStartupProperties->FileName(); |
147 #endif |
151 #endif |
148 DEBUGPRINT3(_L("SysMonMonitor: Going to restart %S, old process id=%u"), &fileName, iProcessId.Id()); |
152 DEBUGPRINT3(_L("SysMonMonitor: Going to restart %S, old process id=%u"), &fileName, iProcessId.Id()); |
149 |
153 |
150 CStartSafe* startSafe = CStartSafe::NewL(); |
154 CStartSafe* startSafe = CStartSafe::NewL(); |
151 CleanupStack::PushL(startSafe); |
155 CleanupStack::PushL(startSafe); |
152 |
156 |
153 // As the retries are now counted(after PREQ1871) over a period of time it does make sense for fire and forget processes to have a non-zero retries count. |
157 // As the retries are now counted(after PREQ1871) over a period of time it does make sense for fire and forget processes to have a non-zero retries count. |
176 |
180 |
177 User::LeaveIfError(err); |
181 User::LeaveIfError(err); |
178 CleanupStack::PopAndDestroy(startSafe); |
182 CleanupStack::PopAndDestroy(startSafe); |
179 DEBUGPRINT3(_L("SysMonMonitor: %S restarted, new iProcessId=%u. Logon to monitor again"), &fileName, iProcess.Id().Id()); |
183 DEBUGPRINT3(_L("SysMonMonitor: %S restarted, new iProcessId=%u. Logon to monitor again"), &fileName, iProcess.Id().Id()); |
180 |
184 |
|
185 #ifdef _DEBUG |
|
186 TInt restartExeCount = 0; |
|
187 // The argument passed to the process is converted into an integer and is used as the key to set the RProperty. |
|
188 // This way each process' restart count is stored in a unique key. |
|
189 TPtrC processArgs = iStartupProperties->Args(); |
|
190 TLex processArgsToInt(processArgs); |
|
191 err = processArgsToInt.Val(restartExeCount); |
|
192 if( KErrNone == err ) |
|
193 { |
|
194 err = RProperty::Set(RProcess().SecureId(), restartExeCount, ++iRestartCount); |
|
195 DEBUGPRINT4(_L("SysMonMonitor: Setting Test Property with key %d to %d completed with error %d"), restartExeCount, iRestartCount, err); |
|
196 } |
|
197 #endif // _DEBUG |
|
198 |
181 iProcessId = iProcess.Id(); |
199 iProcessId = iProcess.Id(); |
182 iReLaunchAttempts++; // Increment after each re-launch attempt. |
200 iReLaunchAttempts++; // Increment after each re-launch attempt. |
183 if (!iReLaunchIntervalTimer->IsActive()) |
201 if (!iReLaunchIntervalTimer->IsActive()) |
184 { |
202 { |
185 DEBUGPRINT3(_L("SysMonMonitor: ReLaunch Interval Timer is started for %S with processId %u"), &fileName, iProcessId.Id()); |
203 DEBUGPRINT3(_L("SysMonMonitor: ReLaunch Interval Timer is started for %S with processId %u"), &fileName, iProcessId.Id()); |