77 return &TheBackend; |
77 return &TheBackend; |
78 #else |
78 #else |
79 return &backend; |
79 return &backend; |
80 #endif |
80 #endif |
81 } |
81 } |
82 |
|
83 EXPORT_C RTz& CLocalSystemInterface::TZServer(TInt &aStatus) |
|
84 { |
|
85 aStatus = OnDemandTZServerConnection(); |
|
86 return iTzServer; |
|
87 } |
|
88 |
|
89 TInt CLocalSystemInterface::OnDemandTZServerConnection() |
|
90 { |
|
91 TInt v = EFalse; |
|
92 TInt err = KErrNone; |
|
93 |
|
94 if(__e32_atomic_load_acq32(&iIsRTzConnected)) |
|
95 return err; |
|
96 |
|
97 iTzServerLock.Wait(); |
|
98 if (!iIsRTzConnected) |
|
99 { |
|
100 err = iTzServer.Connect(); |
|
101 if ( err == KErrNone ) |
|
102 { |
|
103 err = iTzServer.ShareAuto(); |
|
104 if( err == KErrNone) { |
|
105 v = ETrue; |
|
106 } |
|
107 } |
|
108 __e32_atomic_store_rel32(&iIsRTzConnected, v); |
|
109 } |
|
110 iTzServerLock.Signal(); |
|
111 |
|
112 return err; |
|
113 } |
|
114 |
82 |
115 // Construction of Backend Object which is going to be singleton object for the process |
83 // Construction of Backend Object which is going to be singleton object for the process |
116 EXPORT_C CLocalSystemInterface::CLocalSystemInterface() : iOpenDirList(CLocalSystemInterface::KDirGran), |
84 EXPORT_C CLocalSystemInterface::CLocalSystemInterface() : iOpenDirList(CLocalSystemInterface::KDirGran), |
117 iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran), iDefConnResurrect(ETrue), iDefConnPref(NULL), iIsRTzConnected(EFalse) |
85 iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran), iDefConnResurrect(ETrue), iDefConnPref(NULL) |
118 { |
86 { |
119 #ifdef SYMBIAN_OE_POSIX_SIGNALS |
87 #ifdef SYMBIAN_OE_POSIX_SIGNALS |
120 iSignalsInitialized = EFalse; |
88 iSignalsInitialized = EFalse; |
121 iSigInitWaitCount = 0; |
89 iSigInitWaitCount = 0; |
122 iSigInitWaitMutex.CreateLocal(); |
90 iSigInitWaitMutex.CreateLocal(); |
186 if(err == KErrNone) |
154 if(err == KErrNone) |
187 { |
155 { |
188 //Create Server Locks |
156 //Create Server Locks |
189 err |= iSSLock.CreateLocal(); |
157 err |= iSSLock.CreateLocal(); |
190 err |= iCSLock.CreateLocal(); |
158 err |= iCSLock.CreateLocal(); |
191 err |= iIpcS.iLock.CreateLocal(); |
|
192 //Create TLDList Lock |
159 //Create TLDList Lock |
193 err |= iTLDListLock.CreateLocal(); |
160 err |= iTLDListLock.CreateLocal(); |
194 //Create the lock for Session Path |
161 //Create the lock for Session Path |
195 err |= iSessionPathLock.CreateLocal(); |
162 err |= iSessionPathLock.CreateLocal(); |
196 //Lock for protecting iASelectRequest across threads |
163 //Lock for protecting iASelectRequest across threads |
197 err |= iASelectLock.CreateLocal(); |
164 err |= iASelectLock.CreateLocal(); |
198 //Protect the iDefConnection from concurrent GetDefaultConnection calls |
165 //Protect the iDefConnection from concurrent GetDefaultConnection calls |
199 err |= iDefConnLock.CreateLocal(); |
166 err |= iDefConnLock.CreateLocal(); |
200 //Protect the time zone server while connecting |
167 } |
201 err |= iTzServerLock.CreateLocal(); |
168 |
202 } |
169 if(err == KErrNone) |
|
170 { |
|
171 err = iTzServer.Connect(); |
|
172 if(!err) |
|
173 { |
|
174 err = iTzServer.ShareAuto(); |
|
175 } |
|
176 } |
|
177 |
203 |
178 |
204 //Panic if any of the above operation returns with error |
179 //Panic if any of the above operation returns with error |
205 if (err) |
180 if (err) |
206 { |
181 { |
207 User::Panic(KEstlibInit, err); |
182 User::Panic(KEstlibInit, err); |
208 } |
183 } |
209 |
184 |
210 iCleanup.StorePtrs(iPrivateHeap, &iFs, &iSs, &iCs, &iSSLock, &iCSLock,&iDefConnLock,&iASelectLock,&iTzServerLock); |
185 iCleanup.StorePtrs(iPrivateHeap, &iFs, &iSs, &iCs, &iSSLock, &iCSLock,&iDefConnLock,&iASelectLock); |
211 |
186 |
212 } |
187 } |
213 |
188 |
214 EXPORT_C CLocalSystemInterface::~CLocalSystemInterface() |
189 EXPORT_C CLocalSystemInterface::~CLocalSystemInterface() |
215 // |
190 // |
1761 f->Close(); // balances the Dup() in CFileTable::Asynch() - live dangerously! |
1737 f->Close(); // balances the Dup() in CFileTable::Asynch() - live dangerously! |
1762 } |
1738 } |
1763 return MapError(err,anErrno); |
1739 return MapError(err,anErrno); |
1764 } |
1740 } |
1765 |
1741 |
1766 EXPORT_C void CLocalSystemInterface::freednssuffixes(if_dns_suffixes * suffixes) |
|
1767 { |
|
1768 CSocketDesc::FreeDNSSuffixes(suffixes->suffixes); |
|
1769 } |
|
1770 |
|
1771 int CLocalSystemInterface::ioctl_complete (int fid, int cmd, void* param, TRequestStatus& aStatus, int& anErrno) |
1742 int CLocalSystemInterface::ioctl_complete (int fid, int cmd, void* param, TRequestStatus& aStatus, int& anErrno) |
1772 { |
1743 { |
1773 return iFids.ioctlcomplete(fid,cmd,param,aStatus,anErrno); |
1744 return iFids.ioctlcomplete(fid,cmd,param,aStatus,anErrno); |
1774 } |
1745 } |
1775 |
1746 |
2192 |
2163 |
2193 if (timeout) |
2164 if (timeout) |
2194 { |
2165 { |
2195 timer.After(*reqarray[numReqs+arraycount], timeout); |
2166 timer.After(*reqarray[numReqs+arraycount], timeout); |
2196 // Wait for any request to complete |
2167 // Wait for any request to complete |
2197 CLocalSystemInterface::WaitForNRequest(reqarray, numReqs+arraycount+1); |
2168 CLocalSystemInterface::WaitForNRequest(*reqarray, numReqs+arraycount+1); |
2198 if( (*reqarray[numReqs+arraycount]).Int() == KRequestPending) |
2169 if( (*reqarray[numReqs+arraycount]).Int() == KRequestPending) |
2199 { |
2170 { |
2200 // The timer hasn't fired yet. |
2171 // The timer hasn't fired yet. |
2201 timer.Cancel(); |
2172 timer.Cancel(); |
2202 } |
2173 } |
2207 timer.Close(); |
2178 timer.Close(); |
2208 // No need to set onedown to True as numReqs does not include the Timer request |
2179 // No need to set onedown to True as numReqs does not include the Timer request |
2209 } |
2180 } |
2210 else |
2181 else |
2211 { |
2182 { |
2212 CLocalSystemInterface::WaitForNRequest(reqarray, numReqs+arraycount); |
2183 CLocalSystemInterface::WaitForNRequest(*reqarray, numReqs+arraycount); |
2213 // Completion Status of one request has been gathered |
2184 // Completion Status of one request has been gathered |
2214 onedown = ETrue; |
2185 onedown = ETrue; |
2215 } |
2186 } |
2216 |
2187 |
2217 for (int i = 0; i < numReqs; ++i) |
2188 for (int i = 0; i < numReqs; ++i) |
3646 // |
3617 // |
3647 const CFileTable& CLocalSystemInterface::FileTable() const |
3618 const CFileTable& CLocalSystemInterface::FileTable() const |
3648 { |
3619 { |
3649 return iFids; |
3620 return iFids; |
3650 } |
3621 } |
3651 |
|
3652 // --------------------------------------------------------------------------------- |
|
3653 // CLocalSystemInterface::WaitForNRequest |
|
3654 // Wait for any one of the input asynchronous requests to complete |
|
3655 // Used in lieu of User::WaitForNRequest because of need to support pre-Argus builds |
|
3656 // --------------------------------------------------------------------------------- |
|
3657 // |
|
3658 void CLocalSystemInterface::WaitForNRequest(TRequestStatus **aStatusArray, TInt aNum) |
|
3659 { |
|
3660 if (aNum) |
|
3661 { |
|
3662 // used to keep count of requests we have not been asked to wait for |
|
3663 TInt nOther = -1; |
|
3664 TBool done = EFalse; |
|
3665 |
|
3666 do |
|
3667 { |
|
3668 ++nOther; |
|
3669 User::WaitForAnyRequest(); |
|
3670 for (TInt i = 0; i < aNum; ++i) |
|
3671 { |
|
3672 if ((*aStatusArray[i]).Int() != KRequestPending) |
|
3673 { |
|
3674 done = ETrue; |
|
3675 break; |
|
3676 } |
|
3677 } |
|
3678 } while (!done); |
|
3679 |
|
3680 if (nOther) |
|
3681 { |
|
3682 // Adjust the thread's signal semaphore to account for the requests |
|
3683 // we were not asked to wait for. |
|
3684 RThread thrd; |
|
3685 for (TInt i = 0; i < nOther; ++i) |
|
3686 { |
|
3687 thrd.RequestSignal(); |
|
3688 } |
|
3689 } |
|
3690 } |
|
3691 } |
|
3692 |
3622 |
3693 // --------------------------------------------------------------------------------- |
3623 // --------------------------------------------------------------------------------- |
3694 // CLocalSystemInterface::WaitForNRequest |
3624 // CLocalSystemInterface::WaitForNRequest |
3695 // Wait for any one of the input asynchronous requests to complete |
3625 // Wait for any one of the input asynchronous requests to complete |
3696 // Used in lieu of User::WaitForNRequest because of need to support pre-Argus builds |
3626 // Used in lieu of User::WaitForNRequest because of need to support pre-Argus builds |