mmserv/tms/tmsserver/src/tmsserver.cpp
branchRCL_3
changeset 18 2eb3b066cc7d
parent 17 3570217d8c21
child 40 60e492b28869
--- a/mmserv/tms/tmsserver/src/tmsserver.cpp	Tue May 11 16:42:02 2010 +0300
+++ b/mmserv/tms/tmsserver/src/tmsserver.cpp	Tue May 25 13:16:00 2010 +0300
@@ -42,12 +42,11 @@
 //
 // -----------------------------------------------------------------------------
 //
-TMSServer* TMSServer::NewL()
+TMSServer* TMSServer::NewLC()
     {
     TMSServer* self = new (ELeave) TMSServer;
     CleanupStack::PushL(self);
     self->ConstructL();
-    CleanupStack::Pop(self);
     return self;
     }
 
@@ -860,21 +859,24 @@
     }
 
 // -----------------------------------------------------------------------------
-// RunServerL
+// TMSServer::RunServerL
 //
 // -----------------------------------------------------------------------------
 //
-static void RunServerL()
+void TMSServer::RunServerL()
     {
     TRACE_PRN_N(_L("TMS->RunServerL"));
 
+    // Naming the server thread after the server helps to debug panics
+    User::LeaveIfError(User::RenameThread(KTMSServerName));
+
     // Create and install the active scheduler we need
     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
     CleanupStack::PushL(scheduler);
     CActiveScheduler::Install(scheduler);
 
     // Create the server (leave it on the cleanup stack)
-    TMSServer* server = TMSServer::NewL();
+    TMSServer* server = TMSServer::NewLC();
 
     // Initialisation complete, now signal the client
     RProcess::Rendezvous(TMS_RESULT_SUCCESS);
@@ -884,7 +886,7 @@
 
     // Ready to exit.
     // Cleanup scheduler and delete the server
-    delete server;
+    CleanupStack::PopAndDestroy(server);
     CleanupStack::PopAndDestroy(scheduler);
 
     TRACE_PRN_N(_L("TMS->RunServerL - TMS server closed"));
@@ -1133,7 +1135,7 @@
     TInt r = KErrNoMemory;
     if (cleanup)
         {
-        TRAP(r, RunServerL());
+        TRAP(r, TMSServer::RunServerL());
         delete cleanup;
         }
     __UHEAP_MARKEND;