--- a/tcpiputils/dnd/src/dns.cpp Wed Sep 15 13:53:10 2010 +0300
+++ b/tcpiputils/dnd/src/dns.cpp Wed Oct 13 16:17:27 2010 +0300
@@ -285,19 +285,7 @@
TBool ret = FALSE;
if (iCurrentServer == 0)
- {
ret = iOwner->iServerManager.OpenList(iFilter, this) > 0;
- // if suffix support is enabled in the resolver.ini
- // and query request had been initiated from a implicitly connected host resolver
- // Perform checks to find appropriate interface that can support the domain name
- // and update the server filter for the network id it should forward its request to
- if (iSuffixSupportEnabled && iFlowReqType == 0)
- iOwner->iServerManager.UpdateDomain(iFilter);
-#ifdef _LOG
- if (iNetworkId != iFilter.iLockId)
- Log::Printf(_L("\t\tDNS session [%u] domain suffix match resulted in change of net id from %d to %d"), (TInt)this, iNetworkId, iFilter.iLockId);
-#endif
- }
iOwner->iCache->GetServerAddress(iOwner->iServerManager.NameSpace(iFilter, iCurrentServer), tmp);
iFilter.iServerId = iOwner->iServerManager.ServerId(tmp);
iCurrentServer = iOwner->iServerManager.Next(iFilter, 0);
@@ -338,7 +326,7 @@
{
if (PickDefaultServer())
{
- iOwner->ReSend(*this);
+ iOwner->ReSend(*this, NULL);
aResult = KDnsNotify_HAVE_SERVERLIST;
}
else
@@ -374,7 +362,11 @@
TDndReqData &rq = iDndReqData[i];
rq.iCallback = aCallback;
rq.iOwner = this;
- iActivityCount++; // Count each open session as "activity".
+
+ iSessionCount++; // Count each open session as "activity".*/
+ #ifdef _LOG
+ Log::Printf(_L("\t\tDNS session [%u] CDndDnsclient::OpenSession Session count is %d"), (TInt)this,iSessionCount);
+ #endif
return &rq;
}
@@ -415,14 +407,27 @@
iOwner->iServerManager.CloseList(iFilter);
// If this was the last active session, then
// cancel all requests
- ASSERT(iOwner->iActivityCount > 0);
- if (--iOwner->iActivityCount == 0)
- iOwner->DeactivateSocket();
+ // Also deactivate sockets based on session, e.f query is ongoing and session comes to an end
+ ASSERT(iOwner->iSessionCount > 0);
+ if(iOwner->iSessionCount > 0)
+ {
+ if (--iOwner->iSessionCount == 0)
+ {
+ LOG(Log::Printf(_L("TDndReqData::Close - session count zero deactivating socket = %d, "), iOwner->iSessionCount));
+ iOwner->DeactivateSocket();
+ }
+ }
+ else
+ {
+ // For safety and cleaning purpose
+ iOwner->DeactivateSocket();
+ }
+ LOG(Log::Printf(_L("TDndReqData::Close - current session count = %d"), iOwner->iSessionCount));
}
// TDndReqData::NewQuery
// ***********************
-TInt TDndReqData::NewQuery(const TDnsMessage &aQuery, TDnsServerScope aServerScope, TUint32 aFlags, TBool aSuffixSupportEnabled)
+TInt TDndReqData::NewQuery(const TDnsMessage &aQuery, TDnsServerScope aServerScope, TUint32 aFlags)
{
iIsReqPending = FALSE;
iIsNewQuery = TRUE;
@@ -431,14 +436,7 @@
iFlags = aFlags;
iFilter.iServerScope = aServerScope;
iFilter.iServerId = 0;
- iNetworkId = aQuery.iId; // Get the networkId information from the Query.
- iFlowReqType = aQuery.iFlowRequestType; // Get the IMPLICIT/EXPLICIT differentiation from the Query
- iSuffixSupportEnabled = aSuffixSupportEnabled; // Whether suffix support enabled in the resolver.ini
- iIsIncompleteHostName = FALSE; // Whether the query name is not fully qualified name
- iCanResolveIncompleteName = TRUE; // Flag to confirm incomplete name without domain suffix tried for resolution as it is
- iPendingSuffixExist = FALSE; // Identifies whether all of the available suffixes has been tried out
- iFilter.iDomainName.FillZ();
- iFilter.iDomainName.SetLength(0);
+ iNetworkId = aQuery.iId; // Get the networkId information from the Query.
#ifdef SYMBIAN_DNS_PUNYCODE
if( (aQuery.iScope & 0x80) == 0x80 )
@@ -462,28 +460,16 @@
if (aQuery.iType == KDnsRequestType_GetByName)
{
- THostName queryName(query.iName);
-
- // if the query is a qualified name, pick the domain name from the query
- // and update the server filter for the performing interface selection
- TInt posOfDomainNameStart = queryName.Locate('.');
- if (posOfDomainNameStart != KErrNotFound)
- {
- iFilter.iDomainName = queryName.Mid(posOfDomainNameStart+1);
- }
-
iFilter.iLockId = aQuery.iId;
iFilter.iLockType = KIp6AddrScopeNetwork;
#ifdef SYMBIAN_DNS_PUNYCODE
- TInt err = iQuestion.SetName(queryName);
+ TInt err = iQuestion.SetName(query.iName);
if( err != KErrNone)
{
return err;
}
- iActualQueryName.Copy(queryName);
#else
- iQuestion.SetName(queryName);
- iActualQueryName.Copy(queryName);
+ iQuestion.SetName(query.iName);
#endif // SYMBIAN_DNS_PUNYCODE
}
else
@@ -687,10 +673,6 @@
iQuestion.SetQType(aQType);
// -- only IN class queries are supported
iQuestion.SetQClass(EDnsQClass_IN);
- // Possible that the there is a different interface (other than the default)
- // that can resolve the domain name we are interested at.
- // By this time, we would have updated the netid in the filter, if at all
- iNetworkId = iFilter.iLockId;
if (iRecord)
{
@@ -722,22 +704,7 @@
SendResponse(KErrDndServerUnusable);
return 0;
}
-
-
- // Check to see if the query is not fully qualified
- THostName queryName;
- iQuestion.GetName(queryName);
- if (queryName.Locate('.') == KErrNotFound)
- {
- // If query is not fully qualified, set flags to mark this for further processing
- iIsIncompleteHostName = TRUE;
- // Pick the domain suffix list on the interface
- iOwner->iServerManager.InterfaceSuffixList(iCurrentServer, iSuffixList);
- // If count of suffices is 0, mark this, so that we do not have to perform any special processing
- if (iSuffixList.Count() > 0)
- iPendingSuffixExist = TRUE;
- }
-
+
// Check in the cache first. If the record does not exist
// in the cache, it will be created now (empty with KErrNotFound).
iRecord = iOwner->iCache->FindL(
@@ -783,7 +750,7 @@
}
// Automatic restart of DNS socket, if closed for some reason
- iOwner->ActivateSocketL(iNetworkId); // pass on the networkId information
+ CDnsSocketWriter *writerInstance = iOwner->ActivateSocketL(iNetworkId); // pass on the networkId information
iIsReqPending = TRUE;
// If the query is probe, do not AssignWork but continue..
@@ -833,13 +800,13 @@
// For link local multicast, use TTL = 1 (otherwise, system default is used)
const TInt ttl = iFilter.iServerScope == EDnsServerScope_MC_LOCAL ? 1 : -1;
- if (iOwner->Queue(*this, server, -1, ttl) != KErrNone)
+ if (iOwner->Queue(*this, server, writerInstance, -1, ttl) != KErrNone)
break;
iIsUsingTCP = 1;
SendResponse(KDnsNotify_USING_TCP);
return 1;
}
- iOwner->ReSend(*this); // (uses old ID, if request queued already)
+ iOwner->ReSend(*this, writerInstance); // (uses old ID, if request queued already)
return 1;
}
@@ -941,15 +908,30 @@
void CDndDnsclient::QueryBegin()
{
- ++iActivityCount;
+ // Query is going on
+ iQueryCount++;
+ LOG(Log::Printf(_L("CDndDnsclient::QueryBegin current query count = %d"), iQueryCount));
}
void CDndDnsclient::QueryEnd()
{
- ASSERT(iActivityCount > 0);
- if (--iActivityCount == 0)
- DeactivateSocket();
+ // if query has ended deactivate the associated sockets.
+ ASSERT(iQueryCount > 0);
+ if(iQueryCount > 0)
+ {
+ if (--iQueryCount == 0 )
+ {
+ LOG(Log::Printf(_L("CDndDnsclient::QueryEnd query count zero deactivating socket = %d"), iQueryCount));
+ DeactivateSocket();
+ }
+ }
+ else
+ {
+ // Call deactivate socket for safety purpose to release the sockets, no effect if already done
+ DeactivateSocket();
+ }
+ LOG(Log::Printf(_L("CDndDnsclient::QueryEnd current query count = %d"), iQueryCount));
}
@@ -985,7 +967,8 @@
return KErrDndFormat;
case EDnsRcode_SERVER_FAILURE:
/*
- In case the server returns the server failure, we just ignore the error code and treat it as server unusable. so that the query is sent to the other available servers for resolution. Need more reasonable solution ???--
+ In case the server returns the server failure, we just ignore the error code and
+ treat it as server unusable. so that the query is sent to the other available servers for resolution. Need more reasonable solution ???--
return KErrDndServerFailure; */
return KErrDndServerUnusable;
case EDnsRcode_NAME_ERROR:
@@ -1117,90 +1100,6 @@
return 0;
ASSERT(aServer.Port() != 0);
- // If the query us incomplete and we have pending domain suffix that can be applied
- // lets try to update the query name and forward it to the next level
- if ( iIsIncompleteHostName )
- {
- if ( iPendingSuffixExist )
- {
- THostName queryName;
- iQuestion.GetName(queryName);
-
- if ( queryName.Locate('.') == KErrNotFound )
- {
- // If the query does not have a '.', we understand that the query has not tried
- // any of the suffixes. So, lets apply the first domain suffix from the interface
- TInt newLength = queryName.Length() + iSuffixList[0].Length();
- THostName qName(queryName);
- qName.Append(_L("."));
-
- // If the query name + suffix name exceeds allowed limit for length (256)
- // truncate the suffix name while appending to the min possible length
- // this automagically skips from getting resolved as the buffer does not have
- // enough space to append configuration msg along with it
- if (newLength < KMaxHostNameLength)
- qName.Append(iSuffixList[0]);
- else
- qName.Append(iSuffixList[0].Mid(0, KMaxHostNameLength - qName.Length()));
-
- iQuestion.SetName(qName);
-
- if ( iSuffixList.Count() == 1 )
- iPendingSuffixExist = FALSE;
-
- LOG(Log::Printf(_L("\t\t Query name after appending suffix = %S"), &qName));
- }
- else
- {
- // As we dont have a '.', we understand that there is some domain suffix already tried
- // and we have reached here because, we were not able to resolve with that domain suffix
- // Now, lets figure out in sequence, as to which one was applied previously
- // so that we shall apply the next one in the list and forward it for resolution
- for (TInt index=0; /*iPendingSuffixExist*/ ; index++ )
- {
- // Crop the leadng query name and '.' from the previous query and check to see
- // which suffix in the list was earlier applied
-
- TSuffixName queryNameSuffix( queryName.Mid( iActualQueryName.Length()+1 ) );
- TSuffixName domainSuffix(iSuffixList[index]);
- TInt suffixLength = domainSuffix.Length();
- TInt completeLength = suffixLength + iActualQueryName.Length() + 1;
-
- if (completeLength > KMaxHostNameLength)
- suffixLength = KMaxHostNameLength - (iActualQueryName.Length() + 1);
-
- if ( queryNameSuffix.Compare( domainSuffix.Mid( 0, suffixLength ) ) != KErrNone )
- continue;
-
- index++;
- TInt newLength = iActualQueryName.Length() + iSuffixList[index].Length();
- THostName qName(iActualQueryName);
- qName.Append(_L("."));
-
- if (newLength < KMaxHostNameLength)
- qName.Append(iSuffixList[index]);
- else
- qName.Append(iSuffixList[index].Mid(0, KMaxHostNameLength - qName.Length()));
-
- iQuestion.SetName(qName);
-
- if ( iSuffixList.Count() == index+1 )
- iPendingSuffixExist = FALSE;
-
- LOG(Log::Printf(_L("\t\t Query name after appending suffix = %S"), &qName));
- break;
- }
- }
- }
- else /* if ( iCanResolveIncompleteName )*/
- {
- iQuestion.SetName(iActualQueryName);
- LOG(Log::Printf(_L("\t\t Query name after appending suffix = %S"), &iActualQueryName));
- iCanResolveIncompleteName = FALSE;
- }
- }
-
-
aMsg.SetLength(sizeof(TDndHeader));
TDndHeader &hdr = (TDndHeader &)aMsg.Header();
if (aServer.IsMulticast())
@@ -1302,7 +1201,7 @@
ASSERT(aServer.IsUnicast()); // Should always be true.
if (aServer.IsUnicast())
{
- if (iOwner->Queue(*this, aServer, hdr.ID()) == KErrNone)
+ if (iOwner->Queue(*this, aServer, NULL, hdr.ID()) == KErrNone)
{
iIsUsingTCP = 1;
SendResponse(KDnsNotify_USING_TCP);
@@ -1312,17 +1211,6 @@
// If cannot use the TCP, then just use the trunctated
// answer as is...
}
-
- // If a incomplete query has failed to resolve after application of a domain suffix
- // and we know that we still have some pending suffix that can be applied
- // let us retry with the available suffices
- LOG(Log::Printf(_L("Error from name resolution is %d"),err));
- if( err == KErrDndBadName && iIsIncompleteHostName && (iPendingSuffixExist || iCanResolveIncompleteName))
- {
- iOwner->ReSend(*this, ETrue); // Set the retryWithSuffix flag to TRUE so that a new request ID is assigned
- return 1;
- }
-
//
// UpdateCacheData updates data in cache only, if err is KErrNone, or
// updates error status for some specific err codes,