29 Or decreased . If request exceeds this number then that particular |
29 Or decreased . If request exceeds this number then that particular |
30 Request will be considered as part of the global pool of request |
30 Request will be considered as part of the global pool of request |
31 */ |
31 */ |
32 #define ASYNCHRONOUS_MESSAGE_SLOTS 255 |
32 #define ASYNCHRONOUS_MESSAGE_SLOTS 255 |
33 |
33 |
|
34 const TInt KMusServerSessionCreationWaitTimeoutInMicrosecs = 10000000; // 10 secs |
|
35 |
34 // ======== LOCAL FUNCTIONS ======== |
36 // ======== LOCAL FUNCTIONS ======== |
35 |
37 |
36 // --------------------------------------------------------------------------- |
38 // --------------------------------------------------------------------------- |
37 // |
39 // |
38 // --------------------------------------------------------------------------- |
40 // --------------------------------------------------------------------------- |
39 // |
41 // |
40 RMusManagerClientSession::RMusManagerClientSession() |
42 RMusManagerClientSession::RMusManagerClientSession() |
41 : RSessionBase () |
43 : RSessionBase () |
42 { |
44 { |
43 |
45 } |
44 } |
46 |
45 |
47 |
46 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
47 // |
49 // Use timeout mechanism for session creation as otherwise it can block |
|
50 // so long that WServ terminates the process. There's no way to cancel |
|
51 // session creation other than destuction of client session. Therefore, in case |
|
52 // of timeout, leave and let creation finish silently or get canceled when |
|
53 // user of client session object deletes us. |
48 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
49 // |
55 // |
50 void RMusManagerClientSession::ConnectL() |
56 void RMusManagerClientSession::ConnectL() |
51 { |
57 { |
52 MUS_LOG( "mus: [MUSCLI] -> RMusManagerClientSession::ConnectL()" ); |
58 MUS_LOG( "mus: [MUSCLI] -> RMusManagerClientSession::ConnectL(), with timeout" ); |
53 TRequestStatus s; |
59 |
|
60 if ( iSessionCreationStatus.Int() == KRequestPending ) |
|
61 { |
|
62 // Previous creation still pending |
|
63 User::Leave( KErrNotReady ); |
|
64 } |
|
65 |
|
66 RTimer timer; |
|
67 CleanupClosePushL( timer ); |
|
68 User::LeaveIfError( timer.CreateLocal() ); |
|
69 |
54 User::LeaveIfError( CreateSession( KMusManagerServerName(), Version(), |
70 User::LeaveIfError( CreateSession( KMusManagerServerName(), Version(), |
55 ASYNCHRONOUS_MESSAGE_SLOTS, &s ) ); |
71 ASYNCHRONOUS_MESSAGE_SLOTS, &iSessionCreationStatus) ); |
56 |
72 TRequestStatus timeoutStatus; |
57 User::WaitForRequest( s ); |
73 timer.After( timeoutStatus, KMusServerSessionCreationWaitTimeoutInMicrosecs ); |
|
74 User::WaitForRequest( iSessionCreationStatus, timeoutStatus ); |
|
75 if ( timeoutStatus.Int() != KRequestPending ) |
|
76 { |
|
77 MUS_LOG( "mus: [MUSCLI] RMusManagerClientSession::ConnectL, timeout" ); |
|
78 User::Leave( KErrTimedOut ); |
|
79 } |
|
80 else |
|
81 { |
|
82 MUS_LOG( "mus: [MUSCLI] RMusManagerClientSession::ConnectL, no timeout" ); |
|
83 timer.Cancel(); |
|
84 User::WaitForRequest( timeoutStatus ); |
|
85 } |
|
86 CleanupStack::PopAndDestroy( &timer ); |
|
87 |
58 MUS_LOG( "mus: [MUSCLI] <- RMusManagerClientSession::ConnectL()" ); |
88 MUS_LOG( "mus: [MUSCLI] <- RMusManagerClientSession::ConnectL()" ); |
59 } |
89 } |
60 |
90 |
61 |
91 |
62 // --------------------------------------------------------------------------- |
92 // --------------------------------------------------------------------------- |