summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2011-04-19 16:49:43 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2011-04-19 16:49:43 +0200
commit398dbd1a4f1712dcea12f90fc6a9737fdf8845c2 (patch)
tree16f24b889ec095b484c61d9acd88495287dc7ab0
parent14c8cc42193723bed64424409c37d0462ceceb86 (diff)
server progress events: report stable sync mode
In a client, PEV_ALERTED was reported to the app with the final sync mode. On the server, that was missing, partly because the determination of the final sync mode has to be delayed a bit. This patch moves the progress event into the one place that is called in all cases: TLocalEngineDS::changeState() for aNewState == dssta_syncmodestable. There it is executed for client and server.
-rw-r--r--src/sysync/localengineds.cpp36
-rw-r--r--src/sysync_SDK/Sources/engine_defs.h12
2 files changed, 37 insertions, 11 deletions
diff --git a/src/sysync/localengineds.cpp b/src/sysync/localengineds.cpp
index bb4ecfe..b8289c6 100644
--- a/src/sysync/localengineds.cpp
+++ b/src/sysync/localengineds.cpp
@@ -2730,16 +2730,6 @@ TAlertCommand *TLocalEngineDS::engProcessSyncAlert(
fSlowSync ? "slow" : "normal",
fFirstTimeSync ? " first time" : ""
));
- #ifdef PROGRESS_EVENTS
- // - progress event
- DB_PROGRESS_EVENT(
- this,
- pev_alerted,
- fSlowSync ? (fFirstTimeSync ? 2 : 1) : 0,
- fResuming ? 1 : 0,
- fSyncMode
- );
- #endif // PROGRESS_EVENTS
} // client Case
#endif // SYSYNC_CLIENT
}
@@ -4189,6 +4179,32 @@ localstatus TLocalEngineDS::changeState(TLocalEngineDSState aNewState, bool aFor
if (!aForceOnError && err1) goto endchange;
// switch state
fLocalDSState = aNewState;
+
+ if (aNewState == dssta_syncmodestable) {
+ // There are multiple places where the sync mode is frozen. Ensure
+ // that this change is reported in all of them by putting the code
+ // here.
+ PDEBUGPRINTFX(DBG_HOT,(
+ "executing %s%s%s Sync%s",
+ fResuming ? "resumed " : "",
+ fSlowSync ? "slow" : "normal",
+ fFirstTimeSync ? " first time" : "",
+ fSyncMode == smo_twoway ? ", two-way" :
+ fSyncMode == smo_fromclient ? " from client" :
+ fSyncMode == smo_fromserver ? " from server" :
+ " in unknown direction?!"
+ ));
+#ifdef PROGRESS_EVENTS
+ // progress event
+ DB_PROGRESS_EVENT(this,
+ pev_alerted,
+ fSlowSync ? (fFirstTimeSync ? 2 : 1) : 0,
+ fResuming ? 1 : 0,
+ fSyncMode
+ );
+#endif // PROGRESS_EVENTS
+ }
+
// now give logic opportunity to react again
err2 = dsAfterStateChange(oldState,aNewState);
endchange:
diff --git a/src/sysync_SDK/Sources/engine_defs.h b/src/sysync_SDK/Sources/engine_defs.h
index 3b0246b..5dabfb0 100644
--- a/src/sysync_SDK/Sources/engine_defs.h
+++ b/src/sysync_SDK/Sources/engine_defs.h
@@ -367,7 +367,17 @@ enum TProgressEventEnum {
/** deleting (zapping datastore), extra1=progress, extra2=total */
PEV_DELETING = 18,
/** datastore alerted (extra1=0 for normal, 1 for slow, 2 for first time slow,
- extra2=1 for resumed session, extra3=syncmode: 0=twoway, 1=fromserver, 2=fromclient) */
+ extra2=1 for resumed session, extra3=syncmode: 0=twoway, 1=fromserver, 2=fromclient)
+
+ This used to be reported only in client mode, directly after receiving and checking
+ the ALERT command from the server. Now this event is also reported in server mode
+ at that point in time where the final sync mode is known (in other words, after
+ the client acknowledged the alerted sync mode).
+
+ Note that a server cannot reliably distinguish between "refresh-from-server" and
+ "slow" sync. A client might delete all its data and then do a "slow" sync - the
+ Synthesis engine itself does that.
+ */
PEV_ALERTED = 19,
/** sync started */
PEV_SYNCSTART = 20,