summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2008-07-30 11:39:41 +0000
committerdeva <deva>2008-07-30 11:39:41 +0000
commit2cfbbf77c85e48bad66288bad4b2122a526c6699 (patch)
tree8ef8cb20b49735b85d8836a2ae8382f70ee8b1c5
parentd13c6d619fca78b8c8e0e889757e984c7e537651 (diff)
Added max ttl on pentominos and db lookups.
-rw-r--r--server/src/configuration.cc4
-rw-r--r--server/src/configuration.h6
-rw-r--r--server/src/widgetgenerator.cc16
3 files changed, 17 insertions, 9 deletions
diff --git a/server/src/configuration.cc b/server/src/configuration.cc
index 8883e30..20d1c75 100644
--- a/server/src/configuration.cc
+++ b/server/src/configuration.cc
@@ -33,8 +33,8 @@ std::string Conf::server_group = "pracro";
std::string Conf::journal_commit_addr = "localhost";
port_t Conf::journal_commit_port = 18112;
-unsigned int Conf::db_max_ttl = 60 * 60 * 24;
-unsigned int Conf::pentominos_max_ttl = 60 * 60 * 24;
+time_t Conf::db_max_ttl = 60 * 60 * 24;
+time_t Conf::pentominos_max_ttl = 60 * 60 * 24;
std::string pentominos_addr = "localhost";
port_t pentominos_potr = 11108;
diff --git a/server/src/configuration.h b/server/src/configuration.h
index 09d8139..eacac14 100644
--- a/server/src/configuration.h
+++ b/server/src/configuration.h
@@ -28,6 +28,8 @@
#define __ARTEFACT_CONFIGURATION_H__
#include <string>
+
+#include <time.h>
#include <sys/types.h>
typedef uint16_t port_t;
@@ -40,8 +42,8 @@ namespace Conf {
extern std::string journal_commit_addr;
extern port_t journal_commit_port;
- extern unsigned int db_max_ttl;
- extern unsigned int pentominos_max_ttl;
+ extern time_t db_max_ttl;
+ extern time_t pentominos_max_ttl;
extern std::string pentominos_addr;
extern port_t pentominos_port;
diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc
index 32fdaba..e9a8fee 100644
--- a/server/src/widgetgenerator.cc
+++ b/server/src/widgetgenerator.cc
@@ -26,6 +26,8 @@
*/
#include "widgetgenerator.h"
+#include "configuration.h"
+
static std::string send_macro_widget(Macro &macro,
Widget &widget,
std::string tabs,
@@ -57,9 +59,11 @@ static std::string send_macro_widget(Macro &macro,
if(luamap != "") {
Value value = mapper.map(luamap);
- widget.attributes["value"] = value.value;
- timestamp = value.timestamp;
- prefilled = "pentominos";
+ if(value.timestamp > time(NULL) - Conf::pentominos_max_ttl) {
+ widget.attributes["value"] = value.value;
+ timestamp = value.timestamp;
+ prefilled = "pentominos";
+ }
}
// widget.attributes.erase(widget.attributes.find("map"));
}
@@ -67,8 +71,10 @@ static std::string send_macro_widget(Macro &macro,
// Check if there is a previously stored value in the db...
if(values.find(widget.attributes["name"]) != values.end() &&
(prefilled == "" || values[widget.attributes["name"]].timestamp > timestamp)) {
- widget.attributes["value"] = values[widget.attributes["name"]].value;
- prefilled = "pracro";
+ if(values[widget.attributes["name"]].timestamp > time(NULL) - Conf::db_max_ttl) {
+ widget.attributes["value"] = values[widget.attributes["name"]].value;
+ prefilled = "pracro";
+ }
}
while(p != widget.attributes.end()) {