summaryrefslogtreecommitdiffstats
path: root/src/core.c
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-09-06 10:24:19 +0000
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-09-06 12:32:38 +0200
commit2d68f8a0ec04b1f7700dce6bc0635c3bce516453 (patch)
tree65e39c982a2f0d604d10a1117a8d22b80a4b8c26 /src/core.c
parent5558fbcf0b5be8a8f90e5b3609ae62dc7c27f84e (diff)
#1061 add timeout to pending scheduled commands
Pending schedule commands can deny ogLive boot of clients due to filling of pending cmd queue with commands such as "Iniciar Sesión". For example: Using RemotePC to serve clients that do not boot into ogLive will fill up the pending command queue with "Iniciar Sesión". Introduce a safety timeout for pending (scheduled) commands to avoid this situation.
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index 6aa9b5c..9fe83bf 100644
--- a/src/core.c
+++ b/src/core.c
@@ -186,14 +186,25 @@ static void og_agent_reset_state(struct og_client *cli)
memset(cli->buf, 0, sizeof(cli->buf));
}
+#define OG_AGENT_CMD_TIMEOUT 900
+
static void og_agent_deliver_pending_cmd(struct og_client *cli)
{
+ struct timeval now, elapsed;
const struct og_cmd *cmd;
cmd = og_cmd_find(inet_ntoa(cli->addr.sin_addr));
if (!cmd)
return;
+ gettimeofday(&now, NULL);
+ timersub(&now, &cmd->tv, &elapsed);
+ if (elapsed.tv_sec >= OG_AGENT_CMD_TIMEOUT) {
+ og_dbi_update_action(cmd->id, false);
+ og_cmd_free(cmd);
+ return;
+ }
+
og_send_request(cmd->method, cmd->type, &cmd->params, cmd->json);
cli->last_cmd_id = cmd->id;