38 const TUid& aServerUid2, |
38 const TUid& aServerUid2, |
39 const TUid& aServerUid3) |
39 const TUid& aServerUid3) |
40 { |
40 { |
41 MPMLOGSTRING("MPMLauncher::LaunchServer") |
41 MPMLOGSTRING("MPMLauncher::LaunchServer") |
42 const TUidType serverUid(KNullUid,aServerUid2,aServerUid3); |
42 const TUidType serverUid(KNullUid,aServerUid2,aServerUid3); |
|
43 RSemaphore semaphore; |
|
44 TInt err( KErrNone ); |
43 |
45 |
44 // We just create a new server process. Simultaneous |
46 err = semaphore.CreateGlobal( KMPMLauncherSemaphore, 0 ); |
45 // launching of two such processes should be detected when the second one |
47 if ( err != KErrNone ) |
46 // attempts to create the server object, failing with KErrAlreadyExists. |
48 { |
47 // |
49 // Creating semaphore failed, which means some other thread is |
|
50 // creating the server right. Propagate error KErrServerBusy |
|
51 // to inform the client it should try connecting again. |
|
52 return KErrServerBusy; |
|
53 } |
|
54 |
48 MPMLOGSTRING("Create a new server process") |
55 MPMLOGSTRING("Create a new server process") |
49 RProcess server; |
56 RProcess server; |
50 TInt r=server.Create(aServerFileName,KNullDesC,serverUid); |
57 TInt r=server.Create(aServerFileName,KNullDesC,serverUid); |
51 |
58 |
52 if ( r != KErrNone ) |
59 if ( r != KErrNone ) |
53 { |
60 { |
54 MPMLOGSTRING2("Server process creation returned error: %d", r) |
61 MPMLOGSTRING2("Server process creation returned error: %d", r) |
|
62 semaphore.Close(); |
55 return r; |
63 return r; |
56 } |
64 } |
57 TRequestStatus stat; |
65 TRequestStatus stat; |
58 server.Rendezvous(stat); |
66 server.Rendezvous(stat); |
59 if ( stat != KRequestPending ) |
67 if ( stat != KRequestPending ) |
68 // we can't use the 'exit reason' if the server panicked as this |
76 // we can't use the 'exit reason' if the server panicked as this |
69 // is the panic 'reason' and may be '0' which cannot be distinguished |
77 // is the panic 'reason' and may be '0' which cannot be distinguished |
70 // from KErrNone |
78 // from KErrNone |
71 r = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int(); |
79 r = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int(); |
72 server.Close(); |
80 server.Close(); |
|
81 semaphore.Close(); |
73 return r; |
82 return r; |
74 } |
83 } |
75 |
84 |
76 |
85 |
77 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
86 // ========================== OTHER EXPORTED FUNCTIONS ========================= |