database comparison: also delay it in clients (MB #7710)

Delaying the database comparison was done initially for servers to
limit it to the sources really used by the client. In a client the
same delay makes sense for syncs which fail because the peer cannot be
reached. It is possible to delay the dump because starting the session
no longer depends on it thanks to the m_isEmpty() operation.
This commit is contained in:
Patrick Ohly 2010-02-16 17:15:46 +01:00
parent 7a819be97e
commit 49c123a09c
3 changed files with 25 additions and 13 deletions

View file

@ -1714,11 +1714,11 @@ void SyncContext::initSources(SourceList &sourceList)
void SyncContext::startSourceAccess(SyncSource *source)
{
if (m_serverMode) {
// source is active in sync, now open it and dump
// database
// source is active in sync, now open it
source->open();
m_sourceListPtr->syncPrepare(source->getName());
}
// database dumping is delayed in both client and server
m_sourceListPtr->syncPrepare(source->getName());
}
bool SyncContext::transport_cb (void *udata)
@ -2490,12 +2490,7 @@ SyncMLStatus SyncContext::sync(SyncReport *report)
source->addCallback(boost::bind(&SyncContext::startSourceAccess, this, source), &SyncSource::Operations::m_startAccess);
}
// ready to go: dump initial databases and prepare for final report
// In a server open/prepare are delayed until a client really
// accesses the source, see SyncContext::startSourceAccess().
if (!m_serverMode) {
sourceList.syncPrepare();
}
// ready to go
status = doSync();
} catch (...) {
// handle the exception here while the engine (and logging!) is still alive

View file

@ -771,8 +771,17 @@ class SyncSource : virtual public SyncSourceBase, public SyncSourceConfig, publi
/**
* Actually opens the data source specified in the constructor,
* will throw the normal exceptions if that fails. Should
* not modify the state of the sync source: that can be deferred
* until the server is also ready and beginSync() is called.
* not modify the state of the sync source.
*
* The expectation is that this call is fairly light-weight, but
* does enough checking to determine whether the source is
* usable. More expensive operations (like determining changes)
* should be done in the m_startDataRead callback (bound to
* beginSync() in some of the utility classes).
*
* In clients, it will be called for all sources before
* the sync starts. In servers, it is called for each source once
* the client asks for it, but not sooner.
*/
virtual void open() = 0;

View file

@ -90,8 +90,16 @@ class TrackingSyncSource : public TestingSyncSource,
/**
* Actually opens the data source specified in the constructor,
* will throw the normal exceptions if that fails. Should
* not modify the state of the sync source: that can be deferred
* until the server is also ready and beginSync() is called.
* not modify the state of the sync source.
*
* The expectation is that this call is fairly light-weight, but
* does enough checking to determine whether the source is
* usable. More expensive operations (like determining changes)
* should be done in the beginSync() callback.
*
* In clients, it will be called for all sources before
* the sync starts. In servers, it is called for each source once
* the client asks for it, but not sooner.
*/
virtual void open() = 0;