|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <ss_std.h> |
|
17 #include <ss_glob.h> |
|
18 #include <comms-infras/ss_log.h> |
|
19 //#include <comms-infras/ss_thread.h> |
|
20 #include <comms-infras/ss_roles.h> |
|
21 #include <es_ini.h> |
|
22 #include <f32file.h> |
|
23 #include <commdb.h> |
|
24 #include <ss_subconnprov.h> |
|
25 #include <ss_protprov.h> |
|
26 #include <ss_connprov.h> |
|
27 #include <comms-infras/ss_metaconnprov.h> |
|
28 #include <comms-infras/ss_subconnflow.h> |
|
29 #ifdef SYMBIAN_ZERO_COPY_NETWORKING |
|
30 #include <comms-infras/commsbufpondop.h> |
|
31 #else |
|
32 #include <es_mbman.h> |
|
33 #endif // SYMBIAN_ZERO_COPY_NETWORKING |
|
34 |
|
35 |
|
36 using namespace Den; |
|
37 |
|
38 void SocketServer::InitL(CWorkerThread* aWorker) |
|
39 { |
|
40 if(aWorker->WorkerId() == TWorkerThreadPublicInfo::EMainThread) |
|
41 { |
|
42 // ESock Startup |
|
43 // Check for the existence of ESock sub-directories |
|
44 |
|
45 TAutoClose<RFs> fs; |
|
46 User::LeaveIfError(fs.iObj.Connect()); |
|
47 fs.PushL(); |
|
48 |
|
49 // Create Private Path for ESock in system drive |
|
50 TInt retCode = 0; |
|
51 if(fs.iObj.CreatePrivatePath(RFs::GetSystemDrive()) != KErrNone) |
|
52 { |
|
53 // Error creating Private Path |
|
54 User::Leave(retCode); |
|
55 } |
|
56 |
|
57 // Create ESock Directories in the system drive if they're not already there.. |
|
58 // We rely on undocumented behavior that the default path is on the system drive |
|
59 retCode = fs.iObj.MkDirAll(KEsockIniFileDir); |
|
60 if(retCode != KErrNone && retCode != KErrAlreadyExists) |
|
61 { |
|
62 // Error creating \esock Directory |
|
63 User::Leave(retCode); |
|
64 } |
|
65 |
|
66 retCode = fs.iObj.MkDirAll(KEsockNoBackupDir); |
|
67 if(retCode != KErrNone && retCode != KErrAlreadyExists) |
|
68 { |
|
69 // Error creating \nobackup directory |
|
70 User::Leave(retCode); |
|
71 } |
|
72 |
|
73 fs.Pop(); |
|
74 } |
|
75 |
|
76 LOG( ESockLog::Printf(_L("SocketServer::InitL() Done!")); ) |
|
77 } |
|
78 |
|
79 void SocketServer::ShutDown() |
|
80 /** |
|
81 free data structures and close the protocol manager |
|
82 */ |
|
83 { |
|
84 // Mark ourself as on the way out |
|
85 CSockManData* globals=SockManGlobals::Get(); |
|
86 LOG( ESockLog::Printf(_L("--------------- SocketServer W%d starting shutdown ---------------"), globals->iWorkerThread->WorkerId()) ); |
|
87 |
|
88 // The sub-connection and connection (specially) factories needs to be deleted |
|
89 // before ShutdownExtensions() is called since connection factories may hold a |
|
90 // valid NifSession ref which may become invalid if Nifman is unloaded through |
|
91 // ShutdownExtensions() |
|
92 //destroy factories before anything else gets destroyed |
|
93 globals->UninstallFactoryContainers(); |
|
94 |
|
95 ShutdownExtensions(); // including Nifman |
|
96 |
|
97 ProtocolManager::ShutDown(); |
|
98 |
|
99 __CFLOG_STMT(TInt id = globals->iWorkerThread->WorkerId()); |
|
100 |
|
101 __CFLOG_1(KESockComponentTag, KESockServerTag, _L8("SocketServer W%d: objects destroyed, waiting to drop Scheduler"), id); |
|
102 } |
|
103 |
|
104 void SocketServer::ShutdownExtensions() |
|
105 /** |
|
106 Shutdown extention DLLs |
|
107 */ |
|
108 { |
|
109 TDblQue<CSocketServExtRef>& list = SockManGlobals::Get()->iExtensions; |
|
110 CSocketServExtRef *xref; |
|
111 TDblQueIter<CSocketServExtRef> iter(list); |
|
112 iter.SetToLast(); |
|
113 while (xref = iter--, xref!=NULL) |
|
114 { |
|
115 xref->Remove(); |
|
116 } |
|
117 |
|
118 while (!list.IsEmpty()) |
|
119 { |
|
120 xref = list.Last(); |
|
121 xref->Close(); |
|
122 delete xref; |
|
123 } |
|
124 } |
|
125 |
|
126 TBool SocketServer::IsShuttingDown() |
|
127 /** |
|
128 Used for Protocol shutdown to tell us whether protocols must be closed |
|
129 immediately. |
|
130 */ |
|
131 { |
|
132 return (SockManGlobals::Get()->SelfWorker()->ShuttingDown()); |
|
133 } |
|
134 #ifdef SYMBIAN_ZERO_COPY_NETWORKING |
|
135 RCommsBufPond SocketServer::GetCommsBufPond() |
|
136 /** |
|
137 return context for the Mbuf manager. |
|
138 */ |
|
139 { |
|
140 return TCommsBufPondTLSOp::Get(); |
|
141 } |
|
142 #else |
|
143 CMBufManager* SocketServer::GetMBufManager() |
|
144 /** |
|
145 return context for the Mbuf manager. |
|
146 */ |
|
147 { |
|
148 return CMBufManager::Context(); |
|
149 } |
|
150 #endif |
|
151 |
|
152 CDeltaTimer* SocketServer::GetTimer() |
|
153 /** |
|
154 return context for the global timer. |
|
155 */ |
|
156 { |
|
157 // PERF: doesn't appear to be used by us now? switched to just-in-time addition |
|
158 CDeltaTimer* timer = SockManGlobals::Get()->iTimer; |
|
159 if(!timer->IsAdded()) |
|
160 { |
|
161 LOG( ESockLog::Printf(_L8("SocketServer::GetTimer() - adding upon first use")); ) |
|
162 CActiveScheduler::Add(timer); |
|
163 } |
|
164 return timer; |
|
165 } |
|
166 |
|
167 CSocketServer* SocketServer::GetSocketServer() |
|
168 /** |
|
169 return context for the CServer |
|
170 |
|
171 */ |
|
172 { |
|
173 return SockManGlobals::Get()->iSocketServer; |
|
174 } |
|
175 |
|
176 #if defined(_DEBUG_SOCKET_FUNCTIONS) |
|
177 EXPORT_C void SocketServer::__DbgForceLoadMBufManagerL() |
|
178 /** |
|
179 Force loading the MBuf manager and, just in case it gets lonely, make a timer. |
|
180 DEPRECATED |
|
181 */ |
|
182 { |
|
183 } |
|
184 |
|
185 EXPORT_C void SocketServer::__DbgForceKillMBufManager() |
|
186 /** |
|
187 Force unloading the MBuf manager |
|
188 DEPRECATED |
|
189 */ |
|
190 { |
|
191 } |
|
192 #else |
|
193 EXPORT_C void SocketServer::__DbgForceLoadMBufManagerL() |
|
194 /** |
|
195 do nothing for UREL builds |
|
196 */ |
|
197 { |
|
198 } |
|
199 |
|
200 EXPORT_C void SocketServer::__DbgForceKillMBufManager() |
|
201 /** |
|
202 do nothing for UREL builds |
|
203 */ |
|
204 { |
|
205 } |
|
206 |
|
207 #endif |
|
208 |
|
209 void SocketServer::InstallExtensionL(const TDesC& aDllName, const TDesC& aArgs) |
|
210 /** |
|
211 Installs an Esock extension dll |
|
212 |
|
213 */ |
|
214 { |
|
215 CSocketServExtRef* xr = new (ELeave) CSocketServExtRef; |
|
216 CleanupStack::PushL(xr); |
|
217 xr->InstallL(aDllName, aArgs); |
|
218 CSockManData* globals = SockManGlobals::Get(); |
|
219 globals->iExtensions.AddLast(*xr); //lint -e429 // extension list does have ownership |
|
220 CleanupStack::Pop(); |
|
221 } |
|
222 |
|
223 void SocketServer::NewSession() |
|
224 /** |
|
225 Increment the session counter - if we were about to shutdown, stop. |
|
226 */ |
|
227 { |
|
228 LOG( ESockLog::Printf(_L8("SocketServer::NewSession()")) ); |
|
229 } |
|
230 |
|
231 void SocketServer::SessionClosing() |
|
232 /** |
|
233 A session is closing, if it's the last one take our stumps home. |
|
234 */ |
|
235 { |
|
236 LOG( ESockLog::Printf(_L8("SocketServer::SessionClosing()")) ); |
|
237 } |