genericopenlibs/openenvcore/backend/src/corebackend/localif.cpp
changeset 63 a117ad66e027
parent 52 bf6a71c50e42
child 68 ff3fc7722556
equal deleted inserted replaced
59:09fa7c3c5079 63:a117ad66e027
    80 #endif
    80 #endif
    81 		}
    81 		}
    82 
    82 
    83 // 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
    84 EXPORT_C CLocalSystemInterface::CLocalSystemInterface() : iOpenDirList(CLocalSystemInterface::KDirGran),
    84 EXPORT_C CLocalSystemInterface::CLocalSystemInterface() : iOpenDirList(CLocalSystemInterface::KDirGran),
    85 iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran), iDefConnPref(NULL)
    85 iTLDInfoList(CLocalSystemInterface::KTLDInfoListGran), iDefConnResurrect(ETrue), iDefConnPref(NULL)
    86 		{
    86 		{
    87 #ifdef SYMBIAN_OE_POSIX_SIGNALS
    87 #ifdef SYMBIAN_OE_POSIX_SIGNALS
    88 		iSignalsInitialized = EFalse;
    88 		iSignalsInitialized = EFalse;
    89 		iSigInitWaitCount = 0;
    89 		iSigInitWaitCount = 0;
    90 		iSigInitWaitMutex.CreateLocal();
    90 		iSigInitWaitMutex.CreateLocal();
  1586 	TInt err=iFids.Asynch(fid,f);
  1586 	TInt err=iFids.Asynch(fid,f);
  1587 	TInt mapErr = err;
  1587 	TInt mapErr = err;
  1588 
  1588 
  1589 	if(!err)
  1589 	if(!err)
  1590 		{
  1590 		{
  1591 		// Check if a connection request is already in progress
  1591 		// Check if a connection request is already in progress for a non-blocking socket.
  1592 		// for a non-blocking socket.
  1592 		if (f->GetConnectionProgress())
  1593 		if(f->GetConnectionProgress())
  1593 			{
  1594 			{
  1594 			mapErr = f->iPollErr;
  1595 			// Poll to see if the connect() is completed
  1595 			
  1596 			err = f->Poll( EReadyForWriting );
  1596 			if (f->iPollErr < 0)
  1597 
  1597 			    {
  1598 			// The above Poll is common for all descriptors. 
  1598                 mapErr = f->iPollErr;
  1599 			// In case of socket-descriptors, Poll will either return "KErrNone"
  1599                 f->iPollErr = 0;
  1600 			// or any of the requested events. To check for Poll error in case of 
  1600                 f->SetConnectionProgress(EFalse);
  1601 			// socket-descriptors, "iPollErr" should be checked.			
  1601                 }
  1602 			if( (err < 0) || (f->iPollErr < 0) ) //Error in poll
  1602 			else
  1603 				(err < 0) ? (mapErr = err):(mapErr = f->iPollErr);
  1603 			    {
  1604 			else if( err == 0 ) //Connect still in progress
  1604                 // Poll to see if the connect() is completed
  1605 				mapErr = EALREADY;
  1605                 err = f->Poll(EReadyForWriting);
  1606 			else if( err & EReadyForWriting ) //Connect has completed
  1606                 // The above Poll is common for all descriptors. 
  1607 				f->SetConnectionProgress(EFalse);
  1607                 // In case of socket-descriptors, Poll will either return "KErrNone"
       
  1608                 // or any of the requested events. To check for Poll error in case of 
       
  1609                 // socket-descriptors, "iPollErr" should be checked.
       
  1610                 if (f->iPollErr < 0)
       
  1611                     {
       
  1612                     mapErr = f->iPollErr;
       
  1613                     f->iPollErr = 0;
       
  1614                     }
       
  1615                 else if (err == 0) //Connect still in progress
       
  1616                     mapErr = EALREADY;
       
  1617                 else if (err & EReadyForWriting)
       
  1618                     {
       
  1619                     mapErr = EISCONN; 
       
  1620                     }
       
  1621 			    }
  1608 			}
  1622 			}
  1609 
  1623 
  1610 		if(!mapErr)
  1624 		if(!mapErr)
  1611 			{
  1625 			{
  1612 			TRequestStatus status;
  1626 			TRequestStatus status;
  1613 			f->Connect(addr,size,status);
  1627 			f->Connect(addr,size,status);
  1614 			err=status.Int();
  1628 			err = status.Int();
  1615 
  1629 
  1616 			if (err == KErrWouldBlock)
  1630 			if (err == KErrWouldBlock)
  1617 				{
  1631 				{
  1618 				f->SetConnectionProgress(ETrue);
       
  1619 				mapErr = EINPROGRESS;
  1632 				mapErr = EINPROGRESS;
  1620 				}
  1633 				}
  1621 			else if(err == KErrAlreadyExists)
  1634 			else if (err == KErrAlreadyExists)
  1622 				{
  1635 				{
  1623 				mapErr = EISCONN;
  1636 				mapErr = EISCONN;
  1624 				}
  1637 				}
  1625 			else
  1638 			else
  1626 				mapErr = err;
  1639 				mapErr = err;
  1784 	}
  1797 	}
  1785 // -----------------------------------------------------------------------------
  1798 // -----------------------------------------------------------------------------
  1786 // CLocalSystemInterface::aselect
  1799 // CLocalSystemInterface::aselect
  1787 // -----------------------------------------------------------------------------
  1800 // -----------------------------------------------------------------------------
  1788 //
  1801 //
  1789 int CLocalSystemInterface::cancelaselect(TRequestStatus* requeststatus,int& anErrno,int performcleanup)
  1802 int CLocalSystemInterface::cancelaselect(TRequestStatus* requeststatus, int& anErrno, TBool perform_cleanup)
  1790 	{
  1803 	{
  1791 	iASelectLock.Wait();
  1804 	iASelectLock.Wait();
  1792 	// Search for the aselect request entry in the aselect request array
  1805 	// Search for the aselect request entry in the aselect request array
  1793 	for ( TInt i=0; i<iASelectRequest.Count(); i++ )
  1806 	for (TInt i = 0; i < iASelectRequest.Count(); ++i)
  1794 		{
  1807 		{
  1795 		if( (iASelectRequest[i].iRequestStatus == requeststatus) || performcleanup )
  1808 		if (iASelectRequest[i].iRequestStatus == requeststatus || perform_cleanup)
  1796 			{
  1809 			{
  1797 			// The specified request exists
  1810 			// The specified request exists
  1798 			RThread threadHandle;
  1811 			RThread thread;
  1799 			// Open a handle to the service thread
  1812 			// Open a handle to the service thread
  1800 			TInt res = threadHandle.Open(iASelectRequest[i].iThreadId,EOwnerThread);
  1813 			TInt res = thread.Open(iASelectRequest[i].iThreadId,EOwnerThread);
  1801 			if( res == KErrNone )
  1814 			if (res == KErrNone)
  1802 				{
  1815 				{
  1803 				// Kill the service thread
  1816 				// Kill the service thread
  1804 				threadHandle.Kill(KErrCancel);
  1817 				thread.Kill(KErrCancel);
  1805 				threadHandle.Close();
  1818 				thread.Close();
  1806 				if( !performcleanup )
  1819 				if (!perform_cleanup)
  1807 					{
  1820 					{
  1808 					// Complete the request with KErrcancel
       
  1809 					User::RequestComplete(iASelectRequest[i].iRequestStatus,KErrCancel);
  1821 					User::RequestComplete(iASelectRequest[i].iRequestStatus,KErrCancel);
  1810 					}
  1822 					}
  1811 				// Switch to backend heap
  1823 				// Switch to backend heap
  1812 				RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
  1824 				RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
  1813 				// Remove the request details from the array
  1825 				// Remove the request details from the array
  1814 				iASelectRequest.Remove(i);
  1826 				iASelectRequest.Remove(i);
  1815 				// Switch back to old heap
  1827 				// Switch back to old heap
  1816 				User::SwitchHeap(oldHeap);
  1828 				User::SwitchHeap(oldHeap);
  1817 				if( !performcleanup )
  1829 				if (!perform_cleanup)
  1818 					{
  1830 					{
  1819 					iASelectLock.Signal();
  1831 					iASelectLock.Signal();
  1820 					return MapError(KErrNone, anErrno);
  1832 					return KErrNone;
  1821 					}
  1833 					}
  1822 				}
  1834 				}
  1823 			else
  1835 			else
  1824 				{
  1836 				{
  1825 				if( !performcleanup )
  1837 				if (!perform_cleanup)
  1826 					{
  1838 					{
  1827 					iASelectLock.Signal();
  1839 					iASelectLock.Signal();
  1828 					// unable to open a handle to the service thread
  1840 					// unable to open a handle to the service thread
  1829 					return MapError(res, anErrno);
  1841 					return MapError(res, anErrno);
  1830 					}
  1842 					}
  1831 				}
  1843 				}
  1832 			}
  1844 			}
  1833 		}
  1845 		}
  1834 	iASelectLock.Signal();
  1846 	iASelectLock.Signal();
  1835 	// No request found with the specified TRequestStatus object
  1847 	// No request found with the specified TRequestStatus object
  1836 	if( !performcleanup )
  1848 	return MapError((!perform_cleanup ? KErrNotFound : KErrNone), anErrno);
  1837 		{
       
  1838 		return MapError(KErrNotFound, anErrno);
       
  1839 		}
       
  1840 	else
       
  1841 		{
       
  1842 		return MapError(KErrNone, anErrno);
       
  1843 		}
       
  1844 	}
  1849 	}
  1845 // -----------------------------------------------------------------------------
  1850 // -----------------------------------------------------------------------------
  1846 // CLocalSystemInterface::ASelectRequest
  1851 // CLocalSystemInterface::ASelectRequest
  1847 // -----------------------------------------------------------------------------
  1852 // -----------------------------------------------------------------------------
  1848 //
  1853 //
  2193             }
  2198             }
  2194 
  2199 
  2195         if ( (*reqarray[i]).Int() != KRequestPending ) 
  2200         if ( (*reqarray[i]).Int() != KRequestPending ) 
  2196             {
  2201             {
  2197             TInt readyevents = fdesc->TweakReadyEvents((*reqarray[i]).Int());
  2202             TInt readyevents = fdesc->TweakReadyEvents((*reqarray[i]).Int());
  2198             if (readfds && FD_ISSET(reqfds[i], readfds) && (readyevents & EReadyForReading) ) 
  2203             TInt event_marked = EFalse;
       
  2204             if (readfds && FD_ISSET(reqfds[i], readfds) && (readyevents & EReadyForReading)) 
  2199                 { 
  2205                 { 
  2200                 FD_SET(reqfds[i], &retreadfds); 
  2206                 FD_SET(reqfds[i], &retreadfds); 
  2201                 ++nDescriptorsSet; 
  2207                 ++nDescriptorsSet;
       
  2208                 event_marked = ETrue;
       
  2209 
  2202                 }
  2210                 }
  2203             if(writefds && FD_ISSET(reqfds[i], writefds) && (readyevents & EReadyForWriting) ) 
  2211             if(writefds && FD_ISSET(reqfds[i], writefds) && (readyevents & EReadyForWriting) ) 
  2204                 { 
  2212                 { 
  2205                 FD_SET(reqfds[i], &retwritefds); 
  2213                 FD_SET(reqfds[i], &retwritefds); 
       
  2214 
       
  2215                 event_marked = ETrue;
  2206                 ++nDescriptorsSet; 
  2216                 ++nDescriptorsSet; 
  2207                 }
  2217                 }
  2208             if(exceptfds && FD_ISSET(reqfds[i], exceptfds) && (readyevents & EAnyException))
  2218             if(exceptfds && FD_ISSET(reqfds[i], exceptfds) && (readyevents & EAnyException))
  2209                 {
  2219                 {
       
  2220                 if (!fdesc->GetConnectionProgress() || !event_marked)
       
  2221                     {
  2210                 FD_SET(reqfds[i], &retexceptfds); 
  2222                 FD_SET(reqfds[i], &retexceptfds); 
  2211                 ++nDescriptorsSet;
  2223                 ++nDescriptorsSet;
       
  2224                     }
  2212                 }
  2225                 }
  2213             }
  2226             }
  2214         else
  2227         else
  2215             {
  2228             {
  2216             //Cancel all other requests.
  2229             //Cancel all other requests.
  3769 	}
  3782 	}
  3770 
  3783 
  3771 // -----------------------------------------------------------------------------
  3784 // -----------------------------------------------------------------------------
  3772 // CLocalSystemInterface::StartDefConnection
  3785 // CLocalSystemInterface::StartDefConnection
  3773 //
  3786 //
  3774 // Helper function for the setdefaultif() API to restart the 
  3787 // Helper function for the setdefaultif() API to start the 
  3775 // default RConnection with the new settings.
  3788 // default RConnection with/without preferences
  3776 // -----------------------------------------------------------------------------
  3789 // -----------------------------------------------------------------------------
  3777 //
  3790 //
  3778 TInt CLocalSystemInterface::StartDefConnection()
  3791 TInt CLocalSystemInterface::StartDefConnection()
  3779 	{
  3792 	{
  3780 	TInt err = iDefConnection.Open(iSs);
  3793 	TInt err = iDefConnection.Open(iSs);
  3792 	if (err != KErrNone)
  3805 	if (err != KErrNone)
  3793 		iDefConnection.Close();
  3806 		iDefConnection.Close();
  3794 	return err;
  3807 	return err;
  3795 	}
  3808 	}
  3796 
  3809 
  3797 // -----------------------------------------------------------------------------
  3810 TInt CLocalSystemInterface::unsetdefaultif(TBool allow_bringup)
  3798 // CLocalSystemInterface::setdefaultif
       
  3799 //
       
  3800 // Set the default interface for network operations
       
  3801 // -----------------------------------------------------------------------------
       
  3802 //
       
  3803 int CLocalSystemInterface::setdefaultif(const struct ifreq* aIfReq)
       
  3804     {
  3811     {
  3805     //If the argument is NULL, close the existing connection
  3812     iDefConnLock.Wait();
  3806     if(aIfReq == NULL )
       
  3807         {
       
  3808         // Obtain lock on the iDefConnection
       
  3809         iDefConnLock.Wait();
       
  3810 
       
  3811     if (iDefConnection.SubSessionHandle() != 0)
  3813     if (iDefConnection.SubSessionHandle() != 0)
  3812         {
  3814         {
  3813         TUint count = iSocketArray.Count();
  3815         TUint count = iSocketArray.Count();            
  3814         for (TInt i = 0; i < count; ++i)
  3816         for (TInt i = 0; i < count; ++i)
  3815             {                
  3817             {                
  3816             iSocketArray[i]->TempClose();
  3818             iSocketArray[i]->TempClose();
  3817             }
  3819             }
  3818         iDefConnection.Close();        
  3820         iDefConnection.Close();
  3819         RHeap* oheap = User::SwitchHeap(iPrivateHeap);
       
  3820         iSocketArray.Reset();
       
  3821         User::SwitchHeap(oheap);
       
  3822         }
  3821         }
  3823 
  3822     
  3824         if( iDefConnPref )
  3823     RHeap* oheap = User::SwitchHeap(iPrivateHeap);
       
  3824     iSocketArray.Reset();
       
  3825     
       
  3826     if (iDefConnPref)
       
  3827         {
       
  3828         if (iDefConnPref->ExtensionId() == TConnPref::EConnPrefSnap)
  3825             {
  3829             {
  3826             switch( iDefConnPref->ExtensionId() )
  3830             delete (TCommSnapPref*)iDefConnPref;
  3827                 {
       
  3828                 case TConnPref::EConnPrefSnap:
       
  3829                     {                    
       
  3830                     RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
  3831                     delete (TCommSnapPref*)iDefConnPref;
       
  3832                     // Switch back to old heap
       
  3833                     User::SwitchHeap(oldHeap);
       
  3834                     iDefConnPref = NULL;		        
       
  3835                     }
       
  3836                     break;
       
  3837 
       
  3838                 case TConnPref::EConnPrefCommDb:
       
  3839                     {
       
  3840                     RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
  3841                     delete (TCommDbConnPref*)iDefConnPref;
       
  3842                     // Switch back to old heap
       
  3843                     User::SwitchHeap(oldHeap);
       
  3844                     iDefConnPref = NULL;
       
  3845                     }
       
  3846                     break;		        
       
  3847 
       
  3848                 default:
       
  3849                     {
       
  3850                     iDefConnLock.Signal();
       
  3851                     // Unknown type of Connection Pref
       
  3852                     return KErrUnknown;
       
  3853                     }
       
  3854                 }
       
  3855             }
  3831             }
  3856         // Release lock on the iDefConnection
  3832         else
  3857         iDefConnLock.Signal();
  3833             {
  3858         return KErrNone;
  3834             delete (TCommDbConnPref*)iDefConnPref;
       
  3835             }
       
  3836         }
       
  3837     User::SwitchHeap(oheap);
       
  3838     
       
  3839     iDefConnPref = NULL;
       
  3840     iDefConnResurrect = allow_bringup;
       
  3841     iDefConnLock.Signal();
       
  3842     return KErrNone;
       
  3843     }
       
  3844 
       
  3845 
       
  3846 // -----------------------------------------------------------------------------
       
  3847 // CLocalSystemInterface::setdefaultif
       
  3848 //
       
  3849 // Set the default interface for network operations
       
  3850 // -----------------------------------------------------------------------------
       
  3851 //
       
  3852 int CLocalSystemInterface::setdefaultif(const struct ifreq* aIfReq)
       
  3853     {
       
  3854     // Do this in any case - whether the argument be a valid pref or NULL
       
  3855     iDefConnResurrect = ETrue;
       
  3856     
       
  3857     // If the argument is NULL, tear down existing connection
       
  3858     if (aIfReq == NULL)
       
  3859         {
       
  3860         return unsetdefaultif();
  3859         }
  3861         }
  3860 
  3862 
  3861     TPtrC8 namePtr((TText8*)aIfReq->ifr_name);
  3863     TPtrC8 namePtr((TText8*)aIfReq->ifr_name);
  3862     TBuf<KCommsDbSvrMaxColumnNameLength> name;
  3864     TBuf<KCommsDbSvrMaxColumnNameLength> name;
  3863     TInt err  = CnvUtfConverter::ConvertToUnicodeFromUtf8(name,namePtr);
  3865     
  3864     if( err != KErrNone )
  3866     TInt err = CnvUtfConverter::ConvertToUnicodeFromUtf8(name, namePtr);
       
  3867     if (err != KErrNone)
  3865         return err;
  3868         return err;
  3866 
  3869     
  3867     if( iDefConnPref )
  3870     if (name.Length() == 0)
  3868         {
  3871         {
  3869         switch( iDefConnPref->ExtensionId() )
  3872         // interface name is an empty string, SNAP id is specified in ifr_ifru.snap_id
       
  3873         if (iDefConnPref && iDefConnPref->ExtensionId() == TConnPref::EConnPrefSnap)
  3870             {
  3874             {
  3871             case TConnPref::EConnPrefSnap:
  3875             ((TCommSnapPref*)iDefConnPref)->SetSnap(aIfReq->ifr_ifru.snap_id);
  3872                 {
  3876             return KErrNone;
  3873                 RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
  3874                 delete (TCommSnapPref*)iDefConnPref;
       
  3875                 // Switch back to old heap
       
  3876                 User::SwitchHeap(oldHeap);
       
  3877                 iDefConnPref = NULL;              
       
  3878                 }
       
  3879                 break;
       
  3880 
       
  3881             case TConnPref::EConnPrefCommDb:
       
  3882                 {
       
  3883                 RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
  3884                 delete (TCommDbConnPref*)iDefConnPref;
       
  3885                 // Switch back to old heap
       
  3886                 User::SwitchHeap(oldHeap);
       
  3887                 iDefConnPref = NULL;
       
  3888                 }
       
  3889                 break;              
       
  3890 
       
  3891             default:
       
  3892                 {
       
  3893                 // Unknown type of Connection Pref
       
  3894                 return KErrUnknown;
       
  3895                 }
       
  3896             }
  3877             }
  3897         }
  3878         
  3898 
       
  3899     // If the interface name is an empty string, the SNAP id is to be set 
       
  3900     if(name.Length() == 0)
       
  3901         {
       
  3902         // Switch to backend heap
       
  3903         RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
  3879         RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
  3880         delete (TCommDbConnPref*)iDefConnPref; // may be a delete(NULL)
  3904         iDefConnPref = new TCommSnapPref;
  3881         iDefConnPref = new TCommSnapPref;
  3905         // Switch back to old heap
       
  3906         User::SwitchHeap(oldHeap);
  3882         User::SwitchHeap(oldHeap);
  3907         if( iDefConnPref == NULL )
  3883 
       
  3884         if (!iDefConnPref)
  3908             {
  3885             {
  3909             return KErrNoMemory;
  3886             return KErrNoMemory;
  3910             }
  3887             }
  3911         TCommSnapPref* snapprefptr = (TCommSnapPref*)iDefConnPref;
  3888         
  3912         snapprefptr->SetSnap(aIfReq->ifr_ifru.snap_id);
  3889         ((TCommSnapPref*)iDefConnPref)->SetSnap(aIfReq->ifr_ifru.snap_id);
  3913         return KErrNone;
  3890         return KErrNone;
  3914         }
  3891         }
  3915     else //Set the IAP name
  3892     
       
  3893     CTrapCleanup *cleanupStack = NULL;
       
  3894     
       
  3895     // Create a cleanup stack if one doesn't exist
       
  3896     if (User::TrapHandler() == NULL)
  3916         {
  3897         {
  3917         CTrapCleanup *cleanupStack = NULL;
  3898         cleanupStack = CTrapCleanup::New();
  3918         //Create a clean up stack if it is not existing.
  3899         if (cleanupStack == NULL)
  3919         if(User::TrapHandler() == NULL)
  3900             return KErrNoMemory;
       
  3901         }
       
  3902     
       
  3903     if (iDefConnPref && iDefConnPref->ExtensionId() == TConnPref::EConnPrefCommDb)
       
  3904         {
       
  3905         TRAP(err, (err = GetConnectionPreferencesL(name, *(TCommDbConnPref*)iDefConnPref)));
       
  3906         }
       
  3907     else
       
  3908         {
       
  3909         RHeap *oldHeap = User::SwitchHeap(iPrivateHeap);
       
  3910         delete (TCommSnapPref*)iDefConnPref;
       
  3911         iDefConnPref = new TCommDbConnPref;
       
  3912         User::SwitchHeap(oldHeap);
       
  3913         
       
  3914         if (iDefConnPref)
  3920             {
  3915             {
  3921             cleanupStack = CTrapCleanup::New(); //This will be deleted after use
  3916             TRAP(err, (err = GetConnectionPreferencesL(name, *(TCommDbConnPref*)iDefConnPref)));
  3922             if(cleanupStack == NULL)
       
  3923                 return KErrNoMemory;
       
  3924             }
  3917             }
  3925 
       
  3926         // Switch to backend heap
       
  3927         RHeap* oldHeap = User::SwitchHeap(iPrivateHeap);
       
  3928         iDefConnPref = new TCommDbConnPref;
       
  3929         // Switch back to old heap
       
  3930         User::SwitchHeap(oldHeap);
       
  3931         if( iDefConnPref == NULL )
       
  3932             {
       
  3933             if( cleanupStack != NULL )
       
  3934                 delete cleanupStack;
       
  3935             return KErrNoMemory;
       
  3936             }
       
  3937         TRAP(err, (err = GetConnectionPreferencesL(name,*(TCommDbConnPref*)iDefConnPref)))
       
  3938 
       
  3939         if( cleanupStack != NULL )
       
  3940             delete cleanupStack;
       
  3941 
       
  3942         return err;
       
  3943         }
  3918         }
       
  3919     
       
  3920     delete cleanupStack;
       
  3921     
       
  3922     return (iDefConnPref ? KErrNone : KErrNoMemory);
  3944     }
  3923     }
       
  3924 
  3945 
  3925 
  3946 // -----------------------------------------------------------------------------
  3926 // -----------------------------------------------------------------------------
  3947 // CLocalSystemInterface::GetDefaultConnection
  3927 // CLocalSystemInterface::GetDefaultConnection
  3948 //
  3928 //
  3949 // Function to get the default connection instance from backend.
  3929 // Function to get the default connection instance from backend.
  3951 // -----------------------------------------------------------------------------
  3931 // -----------------------------------------------------------------------------
  3952 //
  3932 //
  3953 RConnection& CLocalSystemInterface::GetDefaultConnection()
  3933 RConnection& CLocalSystemInterface::GetDefaultConnection()
  3954     {
  3934     {
  3955     // If GetDefaultConnection is called without calling
  3935     // If GetDefaultConnection is called without calling
  3956     // setdefaultif then the connection started without any preferences
  3936     // setdefaultif then the connection is started without any preferences
  3957     // Obtain lock on the iDefConnection
  3937     // Obtain lock on the iDefConnection
  3958     iDefConnLock.Wait();
  3938     iDefConnLock.Wait();
  3959     if(iDefConnection.SubSessionHandle() == 0)
  3939     if(iDefConnection.SubSessionHandle() == 0 && iDefConnResurrect)
  3960         {
  3940         {
  3961         StartDefConnection();
  3941         StartDefConnection();
  3962         }
  3942         }
  3963     // Release lock on the iDefConnection
  3943     // Release lock on the iDefConnection
  3964     iDefConnLock.Signal();
  3944     iDefConnLock.Signal();
  3965     return iDefConnection;
  3945    return iDefConnection;
  3966     }
  3946     }
  3967 
  3947 
  3968 // -----------------------------------------------------------------------------
  3948 // -----------------------------------------------------------------------------
  3969 // CLocalSystemInterface::GetSessionPath
  3949 // CLocalSystemInterface::GetSessionPath
  3970 //
  3950 //