mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
httpd: make the session timeout configurable
The session timeout was a compile-time constant (200 s), so changing it meant rebuilding the firmware. Make it a variable that keeps the same default and add a "session <seconds>" command, so it can be set from the console or from the startup configuration like the other settings. Measured on KP_9000_9XHML_X_V3_1: ROM +180 bytes (BANK1 +17, BANK2 +161) and xdata +2 bytes; the internal RAM map is unchanged.
This commit is contained in:
1 parent
2f005d2993
commit
f0b311fc43
4 files changed
+32
-3
No files matched your search
+6
-2
@@ -12,7 +12,11 @@
|
||||
#include "debug.h"
|
||||
|
||||
#define SESSION_ID_LENGTH 12
|
||||
#define SESSION_TIMEOUT 200
|
||||
#define SESSION_TIMEOUT_DEFAULT 200
|
||||
|
||||
/* Seconds of inactivity after which a session cookie stops validating.
|
||||
* Configurable with the "session" command, see cmd_parser.c. */
|
||||
__xdata uint16_t session_timeout = SESSION_TIMEOUT_DEFAULT;
|
||||
|
||||
#define CMARK_S 6
|
||||
|
||||
@@ -341,7 +345,7 @@ __xdata uint8_t *scan_header(__xdata uint8_t * __xdata p)
|
||||
read_reg_timer(&now);
|
||||
|
||||
if (session) {
|
||||
if (now - last_session_use > SESSION_TIMEOUT) {
|
||||
if (now - last_session_use > session_timeout) {
|
||||
dbg_string("Session expired\n");
|
||||
} else {
|
||||
if (is_word_x(session, session_id)) {
|
||||
|
||||
Reference in new issue
Block a user