--- a/genericopenlibs/openenvcore/backend/inc/fdesc.h Wed Jun 09 11:33:19 2010 +0300
+++ b/genericopenlibs/openenvcore/backend/inc/fdesc.h Thu Jul 15 20:34:46 2010 +0300
@@ -604,7 +604,7 @@
TInt Poll(TPollMode aMode,TBool& aReadyStatus,TInt& aErrno);
TInt Poll(TUint aEvents);
void CancelNotify();
-
+ void TempClose();
void SetFids(void *aFids);
virtual TInt Type()
--- a/genericopenlibs/openenvcore/backend/inc/sysif.h Wed Jun 09 11:33:19 2010 +0300
+++ b/genericopenlibs/openenvcore/backend/inc/sysif.h Thu Jul 15 20:34:46 2010 +0300
@@ -58,7 +58,7 @@
class CFileDescBase;
/* TODO: We don't have to do this in CFileTable. Move to methods */
class CFileSocketDesc;
-
+class CSocketDesc;
struct TChild
/*
@internalComponent
@@ -515,6 +515,29 @@
RArray<TASelectRequest>& ASelectRequest();
RFastLock& ASelectLock();
+
+ inline RFastLock& DefConnLock() { return iDefConnLock; }
+
+ inline TInt AddSocket(CSocketDesc* aPtr)
+ {
+ RHeap* oheap = User::SwitchHeap(iPrivateHeap);
+ TInt ret = iSocketArray.InsertInAddressOrder(aPtr);
+ User::SwitchHeap(oheap);
+ return ret;
+ }
+
+ inline void RemoveSocket(CSocketDesc* aPtr)
+ {
+ TInt index = iSocketArray.FindInAddressOrder(aPtr);
+ if (index != -1)
+ {
+ RHeap* oheap = User::SwitchHeap(iPrivateHeap);
+ iSocketArray.Remove(index);
+ iSocketArray.Compress();
+ User::SwitchHeap(oheap);
+ }
+ }
+
int system (const wchar_t* aCmd, const wchar_t* aCmdArg, int& anErrno );
const wchar_t* GetDirName (int aFid);
IMPORT_C int Truncate (int aFid, off_t anOffset, int& anErrno);
@@ -655,6 +678,7 @@
// Default connection settings, set/cleared using setdefaultif
TConnPref* iDefConnPref;
RTz iTzServer;
+ RPointerArray<CSocketDesc> iSocketArray;
#ifdef SYMBIAN_OE_POSIX_SIGNALS
// Signal handler thread
RThread iSignalHandlerThread;
--- a/genericopenlibs/openenvcore/backend/src/corebackend/localif.cpp Wed Jun 09 11:33:19 2010 +0300
+++ b/genericopenlibs/openenvcore/backend/src/corebackend/localif.cpp Thu Jul 15 20:34:46 2010 +0300
@@ -82,7 +82,7 @@
// Construction of Backend Object which is going to be singleton object for the process
EXPORT_C CLocalSystemInterface::CLocalSystemInterface() : iOpenDirList(CLocalSystemInterface::KDirGran),
-iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran)
+iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran), iDefConnPref(NULL)
{
#ifdef SYMBIAN_OE_POSIX_SIGNALS
iSignalsInitialized = EFalse;
@@ -184,9 +184,7 @@
}
iCleanup.StorePtrs(iPrivateHeap, &iFs, &iSs, &iCs, &iSSLock, &iCSLock);
-
- // No connection settings by default
- iDefConnPref = NULL;
+
}
EXPORT_C CLocalSystemInterface::~CLocalSystemInterface()
@@ -3771,7 +3769,7 @@
}
// -----------------------------------------------------------------------------
-// CLocalSystemInterface::RestartDefConnection
+// CLocalSystemInterface::StartDefConnection
//
// Helper function for the setdefaultif() API to restart the
// default RConnection with the new settings.
@@ -3779,18 +3777,20 @@
//
TInt CLocalSystemInterface::StartDefConnection()
{
- //Close the connection and re-open it with the new preferences
- if(iDefConnection.SubSessionHandle() != 0)
- iDefConnection.Close();
-
TInt err = iDefConnection.Open(iSs);
if( err != KErrNone )
return err;
-
- err = iDefConnection.Start(*iDefConnPref);
- if( err != KErrNone )
+ // If connection preference is set
+ if (iDefConnPref)
+ {
+ err = iDefConnection.Start(*iDefConnPref);
+ }
+ else // No connection preference available
+ {
+ err = iDefConnection.Start();
+ }
+ if (err != KErrNone)
iDefConnection.Close();
-
return err;
}
@@ -3807,8 +3807,20 @@
{
// Obtain lock on the iDefConnection
iDefConnLock.Wait();
- if(iDefConnection.SubSessionHandle() != 0)
- iDefConnection.Close();
+
+ if (iDefConnection.SubSessionHandle() != 0)
+ {
+ TUint count = iSocketArray.Count();
+ for (TInt i = 0; i < count; ++i)
+ {
+ iSocketArray[i]->TempClose();
+ }
+ iDefConnection.Close();
+ RHeap* oheap = User::SwitchHeap(iPrivateHeap);
+ iSocketArray.Reset();
+ User::SwitchHeap(oheap);
+ }
+
if( iDefConnPref )
{
switch( iDefConnPref->ExtensionId() )
@@ -3941,16 +3953,12 @@
RConnection& CLocalSystemInterface::GetDefaultConnection()
{
// If GetDefaultConnection is called without calling
- // setdefaultif then the connection is not started
+ // setdefaultif then the connection started without any preferences
// Obtain lock on the iDefConnection
iDefConnLock.Wait();
if(iDefConnection.SubSessionHandle() == 0)
{
- // iDefConnPref should not be NULL for starting the connection
- if( iDefConnPref )
- {
- StartDefConnection();
- }
+ StartDefConnection();
}
// Release lock on the iDefConnection
iDefConnLock.Signal();
--- a/genericopenlibs/openenvcore/backend/src/corebackend/usocket.cpp Wed Jun 09 11:33:19 2010 +0300
+++ b/genericopenlibs/openenvcore/backend/src/corebackend/usocket.cpp Thu Jul 15 20:34:46 2010 +0300
@@ -343,15 +343,19 @@
TInt CSocketDesc::FinalClose()
{
- RHeap* oheap = User::SwitchHeap(Backend()->Heap());
+ CLocalSystemInterface* backend = Backend();
+ backend->DefConnLock().Wait();
+ RHeap* oheap = User::SwitchHeap(backend->Heap());
if (iSocketPtr != NULL)
{
iSocketPtr = NULL;
StopInterface(NULL); // Checks for RConnection as well as RSubConnection
+ backend->RemoveSocket(this);
}
CSockDescBase::FinalClose();
User::SwitchHeap(oheap);
+ backend->DefConnLock().Signal();
return KErrNone;
}
@@ -1744,54 +1748,35 @@
TInt CSocketDesc::OpenUsingPreference()
{
TInt ret = 0;
- RConnection defConnection = Backend()->GetDefaultConnection();
-
+ // Update when supporting INET6
+ TInt addrfamily = (iAddrFamily == AF_INET6 ? KAfInet : iAddrFamily);
if (iConnectionPtr != NULL) // iConnection initialized
{
- if (iAddrFamily == AF_INET6)
- {
- ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol,iConnection);
- }
- else
- {
- ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol,iConnection);
- }
+ ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol,iConnection);
}
else if (iSubConnectionPtr != NULL) // iSubConnection initialized
{
- if (iAddrFamily == AF_INET6)
- {
- ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol,iSubConnection);
- }
- else
- {
- ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol,iSubConnection);
- }
+ ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol,iSubConnection);
}
- //Now check if the default connection is intialized. This is given lesser
- //priority than the socket specific preferences checked above.
- else if(defConnection.SubSessionHandle() != 0)
- {
- if (iAddrFamily == AF_INET6)
- {
- ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol,defConnection);
- }
- else
- {
- ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol,defConnection);
- }
- }
- else // No connection preference is set
- {
- if (iAddrFamily == AF_INET6)
- {
- ret = iSocket.Open(*iSockServPtr,KAfInet,iStyle,iProtocol);
- }
- else
- {
- ret = iSocket.Open(*iSockServPtr,iAddrFamily,iStyle,iProtocol);
- }
- }
+ else
+ {
+ RConnection& defConnection = Backend()->GetDefaultConnection();
+ //Now check if the default connection is intialized. This is given lesser
+ //priority than the socket specific preferences checked above.
+ if(defConnection.SubSessionHandle() != 0)
+ {
+ ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol,defConnection);
+ if (!ret)
+ {
+ Backend()->AddSocket(this);
+ }
+ }
+ else // No connection preference is set
+ {
+ ret = iSocket.Open(*iSockServPtr,addrfamily,iStyle,iProtocol);
+ }
+ }
+
if(KErrNone == ret)
{
iSocketPtr = &iSocket;
@@ -1800,6 +1785,19 @@
return ret;
}
+void CSocketDesc::TempClose()
+ {
+ if (iSocket.SubSessionHandle() != 0)
+ {
+ iSocketPtr = NULL;
+ iSocket.CancelAll();
+ TRequestStatus status;
+ iSocket.Shutdown(RSocket::EImmediate, status);
+ User::WaitForRequest(status);
+ iSocket.Close();
+ }
+ }
+
void CSocketDesc::AccessPointListL(CArrayFixFlat<TAccessPointRecord> *&aRecordPtr,
TInt &aCount)
{
--- a/genericopenlibs/openenvcore/backend/src/syscall/handlenms.cpp Wed Jun 09 11:33:19 2010 +0300
+++ b/genericopenlibs/openenvcore/backend/src/syscall/handlenms.cpp Thu Jul 15 20:34:46 2010 +0300
@@ -146,7 +146,7 @@
/* Get the default RConnection instance and use it if configured.
NOTE: This RConnection, if configured, would be created using the
socket server on backend. The same server has to be used here */
- RConnection defConnection = Backend()->GetDefaultConnection();
+ RConnection& defConnection = Backend()->GetDefaultConnection();
if(defConnection.SubSessionHandle() != 0)
{
err = hr.Open(ss, AF_INET, IPPROTO_UDP,defConnection);
@@ -324,7 +324,7 @@
/* Get the default RConnection instance and use it if configured.
NOTE: This RConnection, if configured, would be created using the
socket server on backend. The same server has to be used here */
- RConnection defConnection = Backend()->GetDefaultConnection();
+ RConnection& defConnection = Backend()->GetDefaultConnection();
if(defConnection.SubSessionHandle() != 0)
{
err=r.Open(ss, format, IPPROTO_UDP, defConnection);
@@ -418,7 +418,7 @@
/* Get the default RConnection instance and use it if configured.
NOTE: This RConnection, if configured, would be created using the
socket server on backend. The same server has to be used here */
- RConnection defConnection = Backend()->GetDefaultConnection();
+ RConnection& defConnection = Backend()->GetDefaultConnection();
if (defConnection.SubSessionHandle() != 0)
{
err = r.Open(ss, AF_INET, IPPROTO_UDP, defConnection);
@@ -637,7 +637,7 @@
/* Get the default RConnection instance and use it if configured.
NOTE: This RConnection, if configured, would be created using the
socket server on backend. The same server has to be used here */
- RConnection defConnection = Backend()->GetDefaultConnection();
+ RConnection& defConnection = Backend()->GetDefaultConnection();
if(defConnection.SubSessionHandle() != 0)
err = resolver.Open(sockServ, KAfInet, KProtocolInetUdp, defConnection);
else