From 4683fceb72cef0e7301b735a23b1f40323da52ba Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 29 Aug 2014 10:35:47 +0200 Subject: syncsession: avoid unnecessary nonce update When the configure auth type needs no nonce, don't generate one and return NULL immediately, like newChallenge() would do. That avoids unnecessary disk writes for storing the new nonce, which is important for local syncs in IVI. It also avoids debug output about a challenge that would not get sent. --- src/sysync/syncsession.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sysync/syncsession.cpp b/src/sysync/syncsession.cpp index 54c119c..f7c7a11 100644 --- a/src/sysync/syncsession.cpp +++ b/src/sysync/syncsession.cpp @@ -4061,15 +4061,22 @@ bool TSyncSession::processSyncOpItem( // generate challenge for session SmlChalPtr_t TSyncSession::newSessionChallenge(void) { + sysync::TAuthTypes auth = requestedAuthType(); + + // Avoid misleading debug output (there is no challenge) + // and more importantly, creating a new nonce that is not + // going to be used. That causes unnecessary disk writes. + if (auth == sysync::auth_none) return NULL; + string nonce; getNextNonce(fRemoteURI.c_str(),nonce); PDEBUGPRINTFX(DBG_PROTO,( "Challenge for next auth: AuthType=%s, Nonce='%s', binary %sallowed", - authTypeSyncMLNames[requestedAuthType()], + authTypeSyncMLNames[auth], nonce.c_str(), getEncoding()==SML_WBXML ? "" : "NOT " )); - return newChallenge(requestedAuthType(),nonce,getEncoding()==SML_WBXML); + return newChallenge(auth,nonce,getEncoding()==SML_WBXML); } // TSyncSession::newSessionChallenge -- cgit v1.2.3