mmsharing/mmshmanagersrv/src/musmanagerservermain.cpp
changeset 34 01f0bb65bcf1
parent 0 f0cf47e981f9
--- a/mmsharing/mmshmanagersrv/src/musmanagerservermain.cpp	Wed Aug 18 09:46:00 2010 +0300
+++ b/mmsharing/mmshmanagersrv/src/musmanagerservermain.cpp	Thu Sep 02 20:23:40 2010 +0300
@@ -70,9 +70,21 @@
 
 	// Start handling requests
 	CActiveScheduler::Start();
+	
+	// Open semaphore for destruction phase as it may take several seconds.
+	// Client can then interpret that it needs to soon start the server again.
+	// Even if creation of semaphore fails it is better to continue with gracefull shutdown.
+    RSemaphore closingSemaphore;
+    TInt err = closingSemaphore.CreateGlobal( KMusManagerServerClosingSemaphoreName, 0 );
 
     // This will be executed after the active scheduler has been stopped:
     CleanupStack::PopAndDestroy(server); 
+    
+    if ( err == KErrNone )
+        {
+        closingSemaphore.Signal();
+        }
+    closingSemaphore.Close();
 	}
 
 // -----------------------------------------------------------------------------