diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2014-07-02 13:12:58 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2014-07-03 09:09:55 +0200 |
commit | 7b636720a46699e82c7caadf4550a0cd23571465 (patch) | |
tree | 03207d39a9ffe6c75d910e39e86c1ffe6c3ff997 | |
parent | c647f276b3f7171201a1b4dec33eb5c6925774c0 (diff) |
fix asynchronous item update
gcc 4.9 found a flaw in the code path for updating an item when the DB
detects a duplicate: some variables where not preserved across
function restarts.
-rwxr-xr-x | src/sysync/customimplds.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/sysync/customimplds.cpp b/src/sysync/customimplds.cpp index b8b75d0..695e8b9 100755 --- a/src/sysync/customimplds.cpp +++ b/src/sysync/customimplds.cpp @@ -2748,6 +2748,8 @@ struct TCustomItemAux : public TSyncItemAux TSyncOperation fSop; bool fRemoteHasLatestData; CustomItemOp fOp; + bool fChangedDBVersion; + bool fChangedNewVersion; }; /// process item (according to operation: add/delete/replace - and for future: copy/move) @@ -2775,6 +2777,7 @@ bool TCustomImplDS::implProcessItem( TMultiFieldItem *augmentedItemP = NULL; bool remoteHasLatestData; CustomItemOp op; + bool changedDBVersion, changedNewVersion; TP_DEFIDX(li); TP_SWITCH(li,fSessionP->fTPInfo,TP_database); @@ -2799,6 +2802,8 @@ bool TCustomImplDS::implProcessItem( sop = aux->fSop; remoteHasLatestData = aux->fRemoteHasLatestData; op = aux->fOp; + changedDBVersion = aux->fChangedDBVersion; + changedNewVersion = aux->fChangedNewVersion; // Stripped down logic from normal code path below. // We can't save/restore mapppos because it points into @@ -2850,6 +2855,10 @@ bool TCustomImplDS::implProcessItem( aux->fRemoteHasLatestData = remoteHasLatestData; // cppcheck-suppress uninitvar aux->fOp = op; + // cppcheck-suppress uninitvar + aux->fChangedDBVersion = changedDBVersion; + // cppcheck-suppress uninitvar + aux->fChangedNewVersion = changedNewVersion; aStatusCommand.setStatusCode(LOCERR_AGAIN); goto error; @@ -2912,7 +2921,6 @@ bool TCustomImplDS::implProcessItem( if (sta==DB_Conflict) { // DB has detected item conflicts with data already stored in the database and // request merging current data from the backend with new data before storing. - bool changedDBVersion, changedNewVersion; augmentedItemP = mergeWithDatabaseVersion(myitemP, changedDBVersion, changedNewVersion); if (augmentedItemP==NULL) sta = DB_Error; // no item found, DB error @@ -3046,7 +3054,6 @@ bool TCustomImplDS::implProcessItem( if (sta==DB_Conflict) { // DB has detected item conflicts with data already stored in the database and // request merging current data from the backend with new data before storing. - bool changedDBVersion, changedNewVersion; augmentedItemP = mergeWithDatabaseVersion(myitemP, changedDBVersion, changedNewVersion); if (augmentedItemP==NULL) sta = DB_Error; // no item found, DB error |