summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Zeller <luz@synthesis.ch>2009-10-13 15:28:39 +0200
committerLukas Zeller <luz@synthesis.ch>2009-10-13 15:31:32 +0200
commitbc623aee314ef78502ab6b2a557cb0dee65727cb (patch)
treeb7935f92c148c8b8891ae66ee56fb5c61f72051a /src
parent31f332ebf4d90a7524d6814939c88562cc0b275c (diff)
engine: added "lastused" and "timeout" session keys for server session timeout handling
Diffstat (limited to 'src')
-rw-r--r--src/sysync/engineinterface.cpp10
-rwxr-xr-xsrc/sysync/engineinterface.h1
-rwxr-xr-xsrc/sysync/syncagent.cpp29
3 files changed, 40 insertions, 0 deletions
diff --git a/src/sysync/engineinterface.cpp b/src/sysync/engineinterface.cpp
index 600c173..7f1fb80 100644
--- a/src/sysync/engineinterface.cpp
+++ b/src/sysync/engineinterface.cpp
@@ -741,6 +741,16 @@ TSyError TStructFieldsKey::returnInt(sInt32 aInt, memSize aIntSize, appPointer a
} // returnInt
+TSyError TStructFieldsKey::returnLineartime(lineartime_t aTime, appPointer aBuffer, memSize aBufSize, memSize &aValSize)
+{
+ aValSize=sizeof(lineartime_t);
+ if (aBufSize==0) return LOCERR_OK; // measuring size
+ if (aBufSize<aValSize) return LOCERR_BUFTOOSMALL;
+ *((lineartime_t *)aBuffer) = aTime;
+}
+
+
+
// get value's ID (e.g. internal index)
sInt32 TStructFieldsKey::GetValueID(cAppCharP aName)
diff --git a/src/sysync/engineinterface.h b/src/sysync/engineinterface.h
index dc4af89..a08e842 100755
--- a/src/sysync/engineinterface.h
+++ b/src/sysync/engineinterface.h
@@ -327,6 +327,7 @@ public:
// - static helper for procedural string readers
static TSyError returnString(cAppCharP aReturnString, appPointer aBuffer, memSize aBufSize, memSize &aValSize);
static TSyError returnInt(sInt32 aInt, memSize aIntSize, appPointer aBuffer, memSize aBufSize, memSize &aValSize);
+ static TSyError returnLineartime(lineartime_t aTime, appPointer aBuffer, memSize aBufSize, memSize &aValSize);
protected:
diff --git a/src/sysync/syncagent.cpp b/src/sysync/syncagent.cpp
index 0b89421..f15f063 100755
--- a/src/sysync/syncagent.cpp
+++ b/src/sysync/syncagent.cpp
@@ -3506,6 +3506,32 @@ static TSyError readConnectDoc(
} // readConnectDoc
+// - time when session was last used
+static TSyError readLastUsed(
+ TStructFieldsKey *aStructFieldsKeyP, const TStructFieldInfo *aFldInfoP,
+ appPointer aBuffer, memSize aBufSize, memSize &aValSize
+)
+{
+ TAgentParamsKey *mykeyP = static_cast<TAgentParamsKey *>(aStructFieldsKeyP);
+ // return it
+ return TStructFieldsKey::returnLineartime(mykeyP->fAgentP->getSessionLastUsed(), aBuffer, aBufSize, aValSize);
+} // readLastUsed
+
+
+// - server only: check session timeout
+static TSyError readTimedOut(
+ TStructFieldsKey *aStructFieldsKeyP, const TStructFieldInfo *aFldInfoP,
+ appPointer aBuffer, memSize aBufSize, memSize &aValSize
+)
+{
+ TAgentParamsKey *mykeyP = static_cast<TAgentParamsKey *>(aStructFieldsKeyP);
+ // check if session has timed out
+ bool timedout = mykeyP->fAgentP->getSessionLastUsed()+mykeyP->fAgentP->getSessionConfig()->getSessionTimeout() < mykeyP->fAgentP->getSystemNowAs(TCTX_UTC);
+ // return it
+ return TStructFieldsKey::returnInt(timedout, sizeof(bool), aBuffer, aBufSize, aValSize);
+} // readTimedOut
+
+
#ifdef SYSYNC_SERVER
// - server only: read respURI enable flag
@@ -3530,6 +3556,7 @@ static TSyError writeSendRespURI(
return LOCERR_OK;
} // writeSendRespURI
+
#endif // SYSYNC_SERVER
@@ -3578,6 +3605,8 @@ static const TStructFieldInfo ServerParamFieldInfos[] =
{ "connectURI", VALTYPE_TEXT, false, 0, 0, &readConnectURI, NULL },
{ "connectHost", VALTYPE_TEXT, false, 0, 0, &readConnectHost, NULL },
{ "connectDoc", VALTYPE_TEXT, false, 0, 0, &readConnectDoc, NULL },
+ { "timedout", VALTYPE_INT8, false, 0, 0, &readTimedOut, NULL },
+ { "lastused", VALTYPE_TIME64, false, 0, 0, &readLastUsed, NULL },
#ifdef SYSYNC_SERVER
{ "sendrespuri", VALTYPE_INT8, true, 0, 0, &readSendRespURI, &writeSendRespURI },
#endif