equal
deleted
inserted
replaced
18 |
18 |
19 // INCLUDES |
19 // INCLUDES |
20 #include "musmanagerserverstarter.h" |
20 #include "musmanagerserverstarter.h" |
21 #include "musmanageripccommon.h" |
21 #include "musmanageripccommon.h" |
22 #include "muslogger.h" |
22 #include "muslogger.h" |
|
23 |
|
24 const TInt KMusServerClosingWaitTimeoutInMicrosecs = 10000000; // 10 secs |
23 |
25 |
24 // ---------------------------------------------------------------------------- |
26 // ---------------------------------------------------------------------------- |
25 // MusManagerServerStarter::Start |
27 // MusManagerServerStarter::Start |
26 // ---------------------------------------------------------------------------- |
28 // ---------------------------------------------------------------------------- |
27 // |
29 // |
57 MUS_LOG( "mus: [MUSCLI] -> MusManagerServerStarter::Start()" ); |
59 MUS_LOG( "mus: [MUSCLI] -> MusManagerServerStarter::Start()" ); |
58 TFindServer findServer( KMusManagerServerName ); |
60 TFindServer findServer( KMusManagerServerName ); |
59 TFullName name; |
61 TFullName name; |
60 if (findServer.Next(name) == KErrNone) |
62 if (findServer.Next(name) == KErrNone) |
61 { |
63 { |
62 MUS_LOG( "mus: [MUSCLI] <- MusManagerServerStarter::Start()" ); |
64 MUS_LOG( "mus: [MUSCLI] <- MusManagerServerStarter::Start()" ); |
63 return ETrue; // Server already running |
65 |
|
66 // Server may be running but already doing destruction, report |
|
67 // it as not running in such case. |
|
68 RSemaphore closingSemaphore; |
|
69 TBool closingCurrently( |
|
70 closingSemaphore.OpenGlobal( KMusManagerServerClosingSemaphoreName ) == KErrNone ); |
|
71 closingSemaphore.Close(); |
|
72 return !closingCurrently; |
64 } |
73 } |
65 MUS_LOG( "mus: [MUSCLI] <- MusManagerServerStarter::Start()" ); |
74 MUS_LOG( "mus: [MUSCLI] <- MusManagerServerStarter::Start()" ); |
66 return EFalse; |
75 return EFalse; |
67 } |
76 } |
68 |
77 |
71 // ---------------------------------------------------------------------------- |
80 // ---------------------------------------------------------------------------- |
72 // |
81 // |
73 TInt MusManagerServerStarter::CreateServerProcess( RSemaphore& aSemaphore ) |
82 TInt MusManagerServerStarter::CreateServerProcess( RSemaphore& aSemaphore ) |
74 { |
83 { |
75 TInt err = KErrNone; |
84 TInt err = KErrNone; |
|
85 |
|
86 RSemaphore closingSemaphore; |
|
87 if ( closingSemaphore.OpenGlobal( KMusManagerServerClosingSemaphoreName ) == KErrNone ) |
|
88 { |
|
89 MUS_LOG( "mus: [MUSCLI] CreateServerProcess, wait for server closing" ); |
|
90 // Don't wait forever if server is somehow horribly jammed |
|
91 |
|
92 TInt waitErr = closingSemaphore.Wait( KMusServerClosingWaitTimeoutInMicrosecs ); |
|
93 MUS_LOG1( "mus: [MUSCLI] CreateServerProcess, waitErr( %d )", |
|
94 waitErr ); |
|
95 closingSemaphore.Close(); |
|
96 if ( waitErr != KErrNone ) |
|
97 { |
|
98 return waitErr; |
|
99 } |
|
100 } |
|
101 |
76 const TUidType serverUid( KNullUid, KNullUid, KServerUid3 ); |
102 const TUidType serverUid( KNullUid, KNullUid, KServerUid3 ); |
77 RProcess server; |
103 RProcess server; |
78 err = server.Create( KMusManagerServerName, KNullDesC() ,serverUid ); |
104 err = server.Create( KMusManagerServerName, KNullDesC() ,serverUid ); |
79 if ( err ) |
105 if ( err ) |
80 { |
106 { |