diff -r 3cebc1a84278 -r 50de4d668bb6 metadataengine/server/src/mdsserversession.cpp --- a/metadataengine/server/src/mdsserversession.cpp Mon Mar 15 12:42:24 2010 +0200 +++ b/metadataengine/server/src/mdsserversession.cpp Wed Mar 31 22:19:07 2010 +0300 @@ -115,6 +115,12 @@ return; } + if( iServer.ShutdownInProgress() ) + { + aMessage.Complete( KErrServerTerminated ); + return; + } + TRAPD( err, ServiceFunctionL( aMessage ) ); if( err != KErrNone ) { @@ -951,30 +957,42 @@ CMdSNotifier::TEntry& entry = iServer.Notifier().FindEntryL( notifierId ); entry.SetupForCallback( aMsg, 1 ); + + const TInt entryId = entry.Id(); + + TInt low( 0 ); + TInt high( iNotificationCache.Count() ); - const TInt count = iNotificationCache.Count(); - for( TInt i = 0; i < count; ++i ) - { - const TInt notificationCacheId = iNotificationCache[i]->iId; - const TInt entryId = entry.Id(); + while( low < high ) + { + TInt mid( (low+high)>>1 ); + + const TInt compare( entryId - iNotificationCache[mid]->iId ); + if( compare == 0 ) + { + // The cache holds a new notification for this notifier, trigger it + CNotificationCacheItem* item = iNotificationCache[mid]; + iNotificationCache.Remove(mid); - if( notificationCacheId == entryId ) - { - // The cache holds a new notification for this notifier, trigger it - CNotificationCacheItem* item = iNotificationCache[i]; - iNotificationCache.Remove(i); - - CleanupStack::PushL( item ); + CleanupStack::PushL( item ); - entry.TriggerCachedL( item->iCode, item->iData ); - - // take ownership of iData from item and delete it - item->iData = NULL; - CleanupStack::PopAndDestroy( item ); - - return; - } - } + entry.TriggerCachedL( item->iCode, item->iData ); + + // take ownership of iData from item and delete it + item->iData = NULL; + CleanupStack::PopAndDestroy( item ); + + return; + } + else if( compare > 0 ) + { + low = mid + 1; + } + else + { + high = mid; + } + } } // --------------------------------------------------------------------------- @@ -1174,7 +1192,8 @@ CleanupStack::Pop( aData ); CleanupStack::PushL( item ); - iNotificationCache.AppendL( item ); + iNotificationCache.InsertInOrderAllowRepeats( item, + TLinearOrder(CMdSServerSession::ComparePropertiesCacheItem)); CleanupStack::Pop( item ); } @@ -1634,3 +1653,8 @@ return KErrNone; } +TInt CMdSServerSession::ComparePropertiesCacheItem(const CNotificationCacheItem& aFirst, const CNotificationCacheItem& aSecond) + { + return aFirst.iId - aSecond.iId; + } +