diff --git a/src/motionplus.cpp b/src/motionplus.cpp index 41d56b81..574e0279 100644 --- a/src/motionplus.cpp +++ b/src/motionplus.cpp @@ -62,10 +62,12 @@ static void motion_signal_process(struct ctx_motapp *motapp) motapp->restart_all = true; /*FALLTHROUGH*/ case MOTION_SIGNAL_SIGTERM: /* Quit application */ + + motapp->webcontrol_finish = true; + if (motapp->cam_list != NULL) { indx = 0; while (motapp->cam_list[indx]) { - motapp->webcontrol_finish = true; motapp->cam_list[indx]->event_stop = true; motapp->cam_list[indx]->finish_cam = true; motapp->cam_list[indx]->restart_cam = false; diff --git a/src/webu_stream.cpp b/src/webu_stream.cpp index f00b1b0f..793ce955 100644 --- a/src/webu_stream.cpp +++ b/src/webu_stream.cpp @@ -49,6 +49,10 @@ static void webu_stream_mjpeg_delay(struct webui_ctx *webui) struct timespec time_curr; long stream_delay; + if (webui->cam->motapp->webcontrol_finish) { + return; + } + clock_gettime(CLOCK_REALTIME, &time_curr); /* The stream rate MUST be less than 1000000000 otherwise undefined behaviour @@ -82,6 +86,10 @@ static void webu_stream_mjpeg_getimg(struct webui_ctx *webui) int header_len; struct ctx_stream_data *local_stream; + if (webui->cam->motapp->webcontrol_finish) { + return; + } + memset(webui->resp_image, '\0', webui->resp_size); /* Assign to a local pointer the stream we want */