Skip to content

Commit b089f89

Browse files
committed
pikvm/pikvm#312: --exit-on-device-error
1 parent 0e521ad commit b089f89

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

man/ustreamer.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ Timeout for lock. Default: 1.
276276
.BR \-\-exit\-on\-parent\-death
277277
Exit the program if the parent process is dead. Required \fBWITH_PDEATHSIG\fR feature. Default: disabled.
278278
.TP
279+
.BR \-\-exit\-on\-device\-error
280+
Exit on any device error instead of polling until success. Default: disabled.
281+
.TP
279282
.BR \-\-exit\-on\-no\-clients \fIsec
280283
Exit the program if there have been no stream or sink clients or any HTTP requests in the last N seconds. Default: 0 (disabled).
281284
.TP

src/ustreamer/options.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ enum _US_OPT_VALUES {
117117
# ifdef WITH_PDEATHSIG
118118
_O_EXIT_ON_PARENT_DEATH,
119119
# endif
120+
_O_EXIT_ON_DEVICE_ERROR,
120121
_O_EXIT_ON_NO_CLIENTS,
121122
# ifdef WITH_SETPROCTITLE
122123
_O_PROCESS_NAME_PREFIX,
@@ -227,6 +228,7 @@ static const struct option _LONG_OPTS[] = {
227228
# ifdef WITH_PDEATHSIG
228229
{"exit-on-parent-death", no_argument, NULL, _O_EXIT_ON_PARENT_DEATH},
229230
# endif
231+
{"exit-on-device-error", no_argument, NULL, _O_EXIT_ON_DEVICE_ERROR},
230232
{"exit-on-no-clients", required_argument, NULL, _O_EXIT_ON_NO_CLIENTS},
231233
# ifdef WITH_SETPROCTITLE
232234
{"process-name-prefix", required_argument, NULL, _O_PROCESS_NAME_PREFIX},
@@ -490,6 +492,7 @@ int options_parse(us_options_s *options, us_capture_s *cap, us_encoder_s *enc, u
490492
};
491493
break;
492494
# endif
495+
case _O_EXIT_ON_DEVICE_ERROR: OPT_SET(stream->exit_on_device_error, true);
493496
case _O_EXIT_ON_NO_CLIENTS: OPT_NUMBER("--exit-on-no-clients", stream->exit_on_no_clients, 0, 86400, 0);
494497
# ifdef WITH_SETPROCTITLE
495498
case _O_PROCESS_NAME_PREFIX: OPT_SET(process_name_prefix, optarg);

src/ustreamer/stream.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@ static int _stream_init_loop(us_stream_s *stream) {
612612
goto offline_and_retry;
613613

614614
offline_and_retry:
615+
if (stream->exit_on_device_error) {
616+
US_LOG_INFO("Device error, exiting ...");
617+
us_process_suicide();
618+
}
615619
for (uint count = 0; count < stream->error_delay * 10; ++count) {
616620
if (atomic_load(&run->stop)) {
617621
break;

src/ustreamer/stream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ typedef struct {
8080
bool notify_parent;
8181
bool slowdown;
8282
uint error_delay;
83+
bool exit_on_device_error;
8384
uint exit_on_no_clients;
8485

8586
us_memsink_s *jpeg_sink;

0 commit comments

Comments
 (0)