summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Zeller <luz@plan44.ch>2010-12-18 17:54:42 +0100
committerLukas Zeller <luz@synthesis.ch>2011-01-20 17:19:05 +0100
commit1a69b782d58dbbd8f0971f548833a2b21074f33e (patch)
treea1cd1f7487f8b24b72280d1739e28ee935a6897d
parenteffb9fe0c6ba3a486df84251a6193d4e81e97586 (diff)
engine: server: optimized tempGUIDs - only generate them when needed.
Before, all items that had a localID (=all) were run through adjustLocalIDforSize(), so even if <alwayssendlocalid> was configured to off, even replace and delete items received a tempGUID, which then was removed in newSyncOpCommand() again. This is rather inefficient as it causes map items to be generated and even made persistent in the DB that are never used at all. The solution was to move both tempGUID checking/generating and ID prefixing (needed for superdatastores) into newSyncOpCommand() after the point where the decision for including a localID or not is made.
-rw-r--r--src/sysync/localengineds.cpp15
-rwxr-xr-xsrc/sysync/localengineds.h3
-rw-r--r--src/sysync/stdlogicds.cpp19
-rwxr-xr-xsrc/sysync/stdlogicds.h4
4 files changed, 22 insertions, 19 deletions
diff --git a/src/sysync/localengineds.cpp b/src/sysync/localengineds.cpp
index b084cb4..42483f7 100644
--- a/src/sysync/localengineds.cpp
+++ b/src/sysync/localengineds.cpp
@@ -4554,7 +4554,8 @@ void TLocalEngineDS::showStatistics(void)
// create a new syncop command for sending to remote
TSyncOpCommand *TLocalEngineDS::newSyncOpCommand(
TSyncItem *aSyncItemP, // the sync item
- TSyncItemType *aSyncItemTypeP // the sync item type
+ TSyncItemType *aSyncItemTypeP, // the sync item type
+ cAppCharP aLocalIDPrefix
)
{
// get operation
@@ -4583,6 +4584,18 @@ TSyncOpCommand *TLocalEngineDS::newSyncOpCommand(
// Client: all commands only have local IDs
aSyncItemP->clearRemoteID(); // no remote ID
}
+ // add the localID prefix if we do have a localID to send
+ if (aSyncItemP->hasLocalID()) {
+ if (IS_SERVER) {
+ #ifdef SYSYNC_SERVER
+ // make sure GUID (plus prefixes) is not exceeding allowed size
+ adjustLocalIDforSize(aSyncItemP->fLocalID,getRemoteDatastore()->getMaxGUIDSize(),aLocalIDPrefix ? strlen(aLocalIDPrefix) : 0);
+ #endif
+ }
+ // add local ID prefix, if any
+ if (aLocalIDPrefix && *aLocalIDPrefix)
+ aSyncItemP->fLocalID.insert(0,aLocalIDPrefix);
+ }
#ifdef SYSYNC_TARGET_OPTIONS
// init item generation variables
fItemSizeLimit=fSizeLimit;
diff --git a/src/sysync/localengineds.h b/src/sysync/localengineds.h
index 20c16e6..2ca36d6 100755
--- a/src/sysync/localengineds.h
+++ b/src/sysync/localengineds.h
@@ -1131,7 +1131,8 @@ protected:
/// helper for derived classes to generate sync op commands
TSyncOpCommand *newSyncOpCommand(
TSyncItem *aSyncItemP, // the sync item
- TSyncItemType *aSyncItemTypeP // the sync item type
+ TSyncItemType *aSyncItemTypeP, // the sync item type
+ cAppCharP aLocalIDPrefix // prefix for localID (can be NULL for none)
);
/// return pure relative (item) URI (removes absolute part or ./ prefix)
/// @note this one is virtual because it is defined in TSyncDataStore
diff --git a/src/sysync/stdlogicds.cpp b/src/sysync/stdlogicds.cpp
index 2ffefae..c3e4513 100644
--- a/src/sysync/stdlogicds.cpp
+++ b/src/sysync/stdlogicds.cpp
@@ -746,7 +746,7 @@ bool TStdLogicDS::MapFinishAsServer(
bool TStdLogicDS::logicGenerateSyncCommandsAsServer(
TSmlCommandPContainer &aNextMessageCommands,
TSmlCommand * &aInterruptedCommandP,
- const char *aLocalIDPrefix
+ cAppCharP aLocalIDPrefix
)
{
bool alldone=false;
@@ -841,16 +841,8 @@ bool TStdLogicDS::logicGenerateSyncCommandsAsServer(
// test next
continue;
}
- // add prefixes to ID
- if (syncitemP->hasLocalID()) {
- // make sure GUID (plus prefixes) is not exceeding allowed size
- adjustLocalIDforSize(syncitemP->fLocalID,getRemoteDatastore()->getMaxGUIDSize(),aLocalIDPrefix ? strlen(aLocalIDPrefix) : 0);
- // add local ID prefix, if any
- if (aLocalIDPrefix && *aLocalIDPrefix)
- syncitemP->fLocalID.insert(0,aLocalIDPrefix);
- }
// create sync op command (may return NULL in case command cannot be created, e.g. for MaxObjSize limitations)
- TSyncOpCommand *syncopcmdP = newSyncOpCommand(syncitemP,itemtypeP);
+ TSyncOpCommand *syncopcmdP = newSyncOpCommand(syncitemP,itemtypeP,aLocalIDPrefix);
// erase item from list
delete syncitemP;
pos = fItems.erase(pos);
@@ -936,7 +928,7 @@ localstatus TStdLogicDS::startDataAccessForClient(void)
bool TStdLogicDS::logicGenerateSyncCommandsAsClient(
TSmlCommandPContainer &aNextMessageCommands,
TSmlCommand * &aInterruptedCommandP,
- const char *aLocalIDPrefix
+ cAppCharP aLocalIDPrefix
)
{
localstatus sta = LOCERR_OK;
@@ -1004,11 +996,8 @@ bool TStdLogicDS::logicGenerateSyncCommandsAsClient(
}
// set final syncop now
syncitemP->setSyncOp(syncop);
- // add local ID prefix, if any
- if (aLocalIDPrefix && *aLocalIDPrefix && syncitemP->hasLocalID())
- syncitemP->fLocalID.insert(0,aLocalIDPrefix);
// create sync op command
- TSyncOpCommand *syncopcmdP = newSyncOpCommand(syncitemP,itemtypeP);
+ TSyncOpCommand *syncopcmdP = newSyncOpCommand(syncitemP,itemtypeP,aLocalIDPrefix);
#ifdef CLIENT_USES_SERVER_DB
// save item, we need it later for post-processing and Map simulation
fItems.push_back(syncitemP);
diff --git a/src/sysync/stdlogicds.h b/src/sysync/stdlogicds.h
index 75828a8..19cc2be 100755
--- a/src/sysync/stdlogicds.h
+++ b/src/sysync/stdlogicds.h
@@ -296,7 +296,7 @@ private:
virtual bool logicGenerateSyncCommandsAsServer(
TSmlCommandPContainer &aNextMessageCommands,
TSmlCommand * &aInterruptedCommandP,
- const char *aLocalIDPrefix
+ cAppCharP aLocalIDPrefix
);
/// called for servers when receiving map from client
/// @note aLocalID or aRemoteID can be NULL - which signifies deletion of a map entry
@@ -309,7 +309,7 @@ private:
virtual bool logicGenerateSyncCommandsAsClient(
TSmlCommandPContainer &aNextMessageCommands,
TSmlCommand * &aInterruptedCommandP,
- const char *aLocalIDPrefix
+ cAppCharP aLocalIDPrefix
);
#endif // SYSYNC_CLIENT