From 252cdbb0dc074162c24764911f78637d649e0610 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Thu, 12 Sep 2013 16:49:29 +0100 Subject: [PATCH] now it works mostly as before...the only difference is that you really have to be logged in to see the rand value --- src/application/adapter/http/update.c | 17 ++++++++++++++--- src/application/session_stop.c | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/application/adapter/http/update.c b/src/application/adapter/http/update.c index fa1cb11..145a5c1 100644 --- a/src/application/adapter/http/update.c +++ b/src/application/adapter/http/update.c @@ -4,7 +4,7 @@ * \author Georg Hopp * * \copyright - * Copyright © 2012 Georg Hopp + * Copyright © 2013 Georg Hopp * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #define _GNU_SOURCE +#include #include #include #include @@ -121,8 +122,18 @@ void applicationAdapterHttpUpdate(void * _this, void * subject) { ApplicationAdapterHttp this = _this; - HttpWorker worker = (HttpWorker)subject; - unsigned long sid = getSessionId(worker->current_request->cookies); + HttpWorker worker = (HttpWorker)subject; + unsigned long sid = getSessionId(worker->current_request->cookies); + Session session = applicationSessionGet(this->application, sid); + + if (NULL != session) { + if (time(NULL) < session->livetime) { + session->livetime = time(NULL) + SESSION_LIVETIME; + } else { + applicationSessionStop(this->application, sid); + } + + } if (0 == strcmp("POST", worker->current_request->method)) { if (0 == strcmp("/login/", worker->current_request->path)) { diff --git a/src/application/session_stop.c b/src/application/session_stop.c index 0b04928..1d876a0 100644 --- a/src/application/session_stop.c +++ b/src/application/session_stop.c @@ -35,7 +35,8 @@ void applicationSessionStop(Application this, unsigned long sid) { - hashDeleteByVal(this->active_sessions, sid); + Session session = hashDeleteByVal(this->active_sessions, sid); + delete(session); } // vim: set ts=4 sw=4: