Add watchdog kill as parameter

This commit is contained in:
MrDave
2020-12-20 13:03:02 -07:00
committed by Mr-Dave
parent 823c126dea
commit a5ff4d8ef2
4 changed files with 27 additions and 3 deletions

View File

@@ -93,6 +93,10 @@ struct ctx_parm config_parms[] = {
"# Timeout in seconds for thread response.",
0, PARM_TYP_INT,PARM_CAT_01,WEBUI_LEVEL_LIMITED},
{
"watchdog_kill",
"# Timeout before forcefully killing the thread.",
0, PARM_TYP_INT,PARM_CAT_01,WEBUI_LEVEL_LIMITED},
{
"v4l2_device",
"# Video device (e.g. /dev/video0) to be used for capturing.",
0,PARM_TYP_STRING,PARM_CAT_01,WEBUI_LEVEL_ADVANCED
@@ -1080,6 +1084,25 @@ static void conf_edit_watchdog_tmo(struct ctx_cam *cam, std::string &parm, enum
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","watchdog_tmo",_("watchdog_tmo"));
}
static void conf_edit_watchdog_kill(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
{
int parm_in;
if (pact == PARM_ACT_DFLT){
cam->conf->watchdog_kill = 10;
} else if (pact == PARM_ACT_SET){
parm_in = atoi(parm.c_str());
if (parm_in < 1) {
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid watchdog kill timeout %d"),parm_in);
} else {
cam->conf->watchdog_kill = parm_in;
}
} else if (pact == PARM_ACT_GET){
parm = std::to_string(cam->conf->watchdog_kill);
}
return;
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","watchdog_kill",_("watchdog_kill"));
}
static void conf_edit_v4l2_device(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
{
if (pact == PARM_ACT_DFLT) {
@@ -3130,6 +3153,7 @@ static void conf_edit_cat01(struct ctx_cam *cam, std::string parm_nm, std::strin
} else if (parm_nm == "camera_id"){ conf_edit_camera_id(cam, parm_val, pact);
} else if (parm_nm == "target_dir"){ conf_edit_target_dir(cam, parm_val, pact);
} else if (parm_nm == "watchdog_tmo"){ conf_edit_watchdog_tmo(cam, parm_val, pact);
} else if (parm_nm == "watchdog_kill"){ conf_edit_watchdog_kill(cam, parm_val, pact);
} else if (parm_nm == "v4l2_device"){ conf_edit_v4l2_device(cam, parm_val, pact);
} else if (parm_nm == "v4l2_params"){ conf_edit_v4l2_params(cam, parm_val, pact);
} else if (parm_nm == "netcam_url"){ conf_edit_netcam_url(cam, parm_val, pact);

View File

@@ -32,6 +32,7 @@
std::string camera_dir;
std::string target_dir;
int watchdog_tmo;
int watchdog_kill;
/* Capture device configuration parameters */
std::string v4l2_device;

View File

@@ -480,7 +480,7 @@ static void motion_watchdog(struct ctx_motapp *motapp, int indx)
motapp->cam_list[indx]->finish_cam = TRUE;
}
if (motapp->cam_list[indx]->watchdog == WATCHDOG_KILL) {
if (motapp->cam_list[indx]->watchdog == (0 - motapp->cam_list[indx]->conf->watchdog_kill) ) {
MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO
,_("Thread %d - Watchdog timeout did NOT restart, killing it!")
, motapp->cam_list[indx]->threadnr);
@@ -495,7 +495,7 @@ static void motion_watchdog(struct ctx_motapp *motapp, int indx)
pthread_cancel(motapp->cam_list[indx]->thread_id);
}
if (motapp->cam_list[indx]->watchdog < WATCHDOG_KILL) {
if (motapp->cam_list[indx]->watchdog < (0 - motapp->cam_list[indx]->conf->watchdog_kill)) {
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO
,_("Thread %d - Watchdog kill!")
, motapp->cam_list[indx]->threadnr);

View File

@@ -87,7 +87,6 @@ struct ctx_v4l2cam;
#define THRESHOLD_TUNE_LENGTH 256
#define MISSING_FRAMES_TIMEOUT 30 /* Frame count before grey lost image is used */
#define WATCHDOG_KILL -10 /* 10 sec grace period before calling thread cancel */
/* Filetype defines */
#define FTYPE_IMAGE 1