diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2013-06-10 14:59:28 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2013-06-10 14:59:28 +0200 |
commit | 5be60030cf07922f2ad61ef3338e1ae124c85620 (patch) | |
tree | adf8ad5e6bfdb0a24d340ff5d12a9b5ca20bac08 | |
parent | 336683148e1cfa7c3d052582d0e8cc2b6dd72c74 (diff) |
syncsession: move code into new tryDelayedExecutionCommands()
The code gets copied 1:1 without changes. This will be useful
because some code in coming patches needs to call it.
-rw-r--r-- | src/sysync/syncsession.cpp | 89 | ||||
-rwxr-xr-x | src/sysync/syncsession.h | 1 |
2 files changed, 49 insertions, 41 deletions
diff --git a/src/sysync/syncsession.cpp b/src/sysync/syncsession.cpp index 37dd312..6f4ea16 100644 --- a/src/sysync/syncsession.cpp +++ b/src/sysync/syncsession.cpp @@ -2648,47 +2648,7 @@ Ret_t TSyncSession::processHeader(TSyncHeader *aSyncHdrP) delete aSyncHdrP; // now execute delayed commands (before executing new ones) PDEBUGPRINTFX(DBG_SESSION,("New message: Executing %ld delayed commands",(long)fDelayedExecutionCommands.size())); - TSmlCommandPContainer::iterator pos=fDelayedExecutionCommands.begin(); - bool syncEndAfterSyncPackageEnd=false; - while (pos!=fDelayedExecutionCommands.end()) { - // execute again - TSmlCommand *cmdP = (*pos); - // command ok so far (has cmdid, so we can refer to it) - PDEBUGBLOCKFMT(("executeDelayedCmd","Re-executing command from delayed queue", - "Cmd=%s|IncomingMsgID=%ld|CmdID=%ld", - cmdP->getName(), - (long)cmdP->getMsgID(), - (long)cmdP->getCmdID() - )); - SYSYNC_TRY { - fCmdIncomingState=cmdP->getPackageState(); - if (cmdP->execute()) { - // check if this was a syncend which was now executed AFTER the end of the incoming sync package - if (cmdP->getCmdType()==scmd_syncend) { - fDelayedExecSyncEnds--; // count executed syncend - if (cmdP->getPackageState()!=fIncomingState) - syncEndAfterSyncPackageEnd=true; // remember that we had at least one - } - // execution finished, can be deleted - PDEBUGPRINTFX(DBG_SESSION,("%s: command finished execution -> deleting",cmdP->getName())); - delete cmdP; - // delete from queue and get next - pos=fDelayedExecutionCommands.erase(pos); - } - else { - // command has not finished execution, must be retried after next incoming message - PDEBUGPRINTFX(DBG_SESSION,("%s: command STILL NOT finished execution -> keep it (and all follwoing) in queue ",cmdP->getName())); - // keep this and all subsequent commands in the queue - PDEBUGENDBLOCK("executeDelayedCmd"); - break; - } - PDEBUGENDBLOCK("executeDelayedCmd"); - } // try - SYSYNC_CATCH (...) - PDEBUGENDBLOCK("executeDelayedCmd"); - SYSYNC_RETHROW; - SYSYNC_ENDCATCH - } + bool syncEndAfterSyncPackageEnd=tryDelayedExecutionCommands(); // check if all delayed commands are executed now if (fDelayedExecSyncEnds<=0 && syncEndAfterSyncPackageEnd) { // there was at least one queued syncend executed AFTER end of incoming sync package @@ -2770,6 +2730,53 @@ Ret_t TSyncSession::processHeader(TSyncHeader *aSyncHdrP) return SML_ERR_OK; } // TSyncSession::processHeader + +bool TSyncSession::tryDelayedExecutionCommands() +{ + TSmlCommandPContainer::iterator pos=fDelayedExecutionCommands.begin(); + bool syncEndAfterSyncPackageEnd=false; + while (pos!=fDelayedExecutionCommands.end()) { + // execute again + TSmlCommand *cmdP = (*pos); + // command ok so far (has cmdid, so we can refer to it) + PDEBUGBLOCKFMT(("executeDelayedCmd","Re-executing command from delayed queue", + "Cmd=%s|IncomingMsgID=%ld|CmdID=%ld", + cmdP->getName(), + (long)cmdP->getMsgID(), + (long)cmdP->getCmdID() + )); + SYSYNC_TRY { + fCmdIncomingState=cmdP->getPackageState(); + if (cmdP->execute()) { + // check if this was a syncend which was now executed AFTER the end of the incoming sync package + if (cmdP->getCmdType()==scmd_syncend) { + fDelayedExecSyncEnds--; // count executed syncend + if (cmdP->getPackageState()!=fIncomingState) + syncEndAfterSyncPackageEnd=true; // remember that we had at least one + } + // execution finished, can be deleted + PDEBUGPRINTFX(DBG_SESSION,("%s: command finished execution -> deleting",cmdP->getName())); + delete cmdP; + // delete from queue and get next + pos=fDelayedExecutionCommands.erase(pos); + } + else { + // command has not finished execution, must be retried after next incoming message + PDEBUGPRINTFX(DBG_SESSION,("%s: command STILL NOT finished execution -> keep it (and all follwoing) in queue ",cmdP->getName())); + // keep this and all subsequent commands in the queue + PDEBUGENDBLOCK("executeDelayedCmd"); + break; + } + PDEBUGENDBLOCK("executeDelayedCmd"); + } // try + SYSYNC_CATCH (...) + PDEBUGENDBLOCK("executeDelayedCmd"); + SYSYNC_RETHROW; + SYSYNC_ENDCATCH + } + return syncEndAfterSyncPackageEnd; +} + #ifdef __PALM_OS__ #pragma segment session2 #endif diff --git a/src/sysync/syncsession.h b/src/sysync/syncsession.h index 3bb5cb8..3a652c6 100755 --- a/src/sysync/syncsession.h +++ b/src/sysync/syncsession.h @@ -524,6 +524,7 @@ public: bool sessionMustContinue(void); virtual void essentialStatusReceived(void) { /* NOP here */ }; void delayExecUntilNextRequest(TSmlCommand *aCommand); + bool tryDelayedExecutionCommands(); // returns syncEndAfterSyncPackageEnd bool delayedSyncEndsPending(void) { return fDelayedExecSyncEnds>0; }; // - continue interrupted or prevented issue in next package void ContinuePackageRoot(void); |