37 #include <stdlib.h> |
37 #include <stdlib.h> |
38 #include <signal.h> |
38 #include <signal.h> |
39 #include "tsignalmessage.h" |
39 #include "tsignalmessage.h" |
40 #endif // SYMBIAN_OE_POSIX_SIGNALS |
40 #endif // SYMBIAN_OE_POSIX_SIGNALS |
41 |
41 |
|
42 |
42 #ifdef SYMBIAN_OE_POSIX_SIGNALS |
43 #ifdef SYMBIAN_OE_POSIX_SIGNALS |
43 #define SIG_SIGNAL_PRESENT_IN_SIGSET(sig,set) ((set & (1ULL << (sig-1))) != 0x0000000000000000ULL) |
44 #define SIG_SIGNAL_PRESENT_IN_SIGSET(sig,set) ((set & (1ULL << (sig-1))) != 0x0000000000000000ULL) |
44 #define SIG_ISEMPTY_SIGSET(set) (set == 0x0000000000000000ULL) |
45 #define SIG_ISEMPTY_SIGSET(set) (set == 0x0000000000000000ULL) |
45 #define SIG_EMPTY_SIGSET(set) {set = 0x0000000000000000ULL;} |
46 #define SIG_EMPTY_SIGSET(set) {set = 0x0000000000000000ULL;} |
46 #define SIG_FILL_SIGSET(set) {set = 0xFFFFFFFFFFFFFFFFULL;} |
47 #define SIG_FILL_SIGSET(set) {set = 0xFFFFFFFFFFFFFFFFULL;} |
77 return &TheBackend; |
78 return &TheBackend; |
78 #else |
79 #else |
79 return &backend; |
80 return &backend; |
80 #endif |
81 #endif |
81 } |
82 } |
|
83 |
|
84 EXPORT_C RTz& CLocalSystemInterface::TZServer(TInt &aStatus) |
|
85 { |
|
86 aStatus = OnDemandTZServerConnection(); |
|
87 return iTzServer; |
|
88 } |
|
89 |
|
90 TInt CLocalSystemInterface::OnDemandTZServerConnection() |
|
91 { |
|
92 TInt v = EFalse; |
|
93 TInt err = KErrNone; |
|
94 |
|
95 if(__e32_atomic_load_acq32(&iIsRTzConnected)) |
|
96 return err; |
|
97 |
|
98 iTzServerLock.Wait(); |
|
99 if (!iIsRTzConnected) |
|
100 { |
|
101 err = iTzServer.Connect(); |
|
102 if ( err == KErrNone ) |
|
103 { |
|
104 err = iTzServer.ShareAuto(); |
|
105 if( err == KErrNone) { |
|
106 v = ETrue; |
|
107 } |
|
108 } |
|
109 __e32_atomic_store_rel32(&iIsRTzConnected, v); |
|
110 } |
|
111 iTzServerLock.Signal(); |
|
112 |
|
113 return err; |
|
114 } |
82 |
115 |
83 // Construction of Backend Object which is going to be singleton object for the process |
116 // Construction of Backend Object which is going to be singleton object for the process |
84 EXPORT_C CLocalSystemInterface::CLocalSystemInterface() : iOpenDirList(CLocalSystemInterface::KDirGran), |
117 EXPORT_C CLocalSystemInterface::CLocalSystemInterface() : iOpenDirList(CLocalSystemInterface::KDirGran), |
85 iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran), iDefConnResurrect(ETrue), iDefConnPref(NULL) |
118 iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran), iDefConnResurrect(ETrue), iDefConnPref(NULL), iIsRTzConnected(EFalse) |
86 { |
119 { |
87 #ifdef SYMBIAN_OE_POSIX_SIGNALS |
120 #ifdef SYMBIAN_OE_POSIX_SIGNALS |
88 iSignalsInitialized = EFalse; |
121 iSignalsInitialized = EFalse; |
89 iSigInitWaitCount = 0; |
122 iSigInitWaitCount = 0; |
90 iSigInitWaitMutex.CreateLocal(); |
123 iSigInitWaitMutex.CreateLocal(); |
163 err |= iSessionPathLock.CreateLocal(); |
196 err |= iSessionPathLock.CreateLocal(); |
164 //Lock for protecting iASelectRequest across threads |
197 //Lock for protecting iASelectRequest across threads |
165 err |= iASelectLock.CreateLocal(); |
198 err |= iASelectLock.CreateLocal(); |
166 //Protect the iDefConnection from concurrent GetDefaultConnection calls |
199 //Protect the iDefConnection from concurrent GetDefaultConnection calls |
167 err |= iDefConnLock.CreateLocal(); |
200 err |= iDefConnLock.CreateLocal(); |
168 } |
201 //Protect the time zone server while connecting |
169 |
202 err |= iTzServerLock.CreateLocal(); |
170 if(err == KErrNone) |
203 } |
171 { |
|
172 err = iTzServer.Connect(); |
|
173 if(!err) |
|
174 { |
|
175 err = iTzServer.ShareAuto(); |
|
176 } |
|
177 } |
|
178 |
|
179 |
204 |
180 //Panic if any of the above operation returns with error |
205 //Panic if any of the above operation returns with error |
181 if (err) |
206 if (err) |
182 { |
207 { |
183 User::Panic(KEstlibInit, err); |
208 User::Panic(KEstlibInit, err); |
184 } |
209 } |
185 |
210 |
186 iCleanup.StorePtrs(iPrivateHeap, &iFs, &iSs, &iCs, &iSSLock, &iCSLock); |
211 iCleanup.StorePtrs(iPrivateHeap, &iFs, &iSs, &iCs, &iSSLock, &iCSLock,&iDefConnLock,&iASelectLock,&iTzServerLock); |
187 |
212 |
188 } |
213 } |
189 |
214 |
190 EXPORT_C CLocalSystemInterface::~CLocalSystemInterface() |
215 EXPORT_C CLocalSystemInterface::~CLocalSystemInterface() |
191 // |
216 // |
192 // Shut down all server connections in use |
217 // Shut down all server connections in use |
193 // |
218 // |
194 { |
219 { |
195 iTLDListLock.Close(); |
220 iTLDListLock.Close(); |
196 iSessionPathLock.Close(); |
221 iSessionPathLock.Close(); |
197 // Close the aselect lock |
|
198 iASelectLock.Close(); |
|
199 // Close the default connection lock |
|
200 iDefConnLock.Close(); |
|
201 |
222 |
202 //close the default RConnection |
223 //close the default RConnection |
203 if(iDefConnection.SubSessionHandle() != 0) |
224 if(iDefConnection.SubSessionHandle() != 0) |
204 { |
225 { |
205 iDefConnection.Close(); |
226 iDefConnection.Close(); |