mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-12 02:23:43 +00:00
better access checking
This commit is contained in:
14
src/stream.c
14
src/stream.c
@@ -303,25 +303,25 @@ void stream_switch_slowdown(struct stream_t *stream, bool slowdown) {
|
|||||||
|
|
||||||
static struct _workers_pool_t *_stream_init_loop(struct stream_t *stream) {
|
static struct _workers_pool_t *_stream_init_loop(struct stream_t *stream) {
|
||||||
struct _workers_pool_t *pool = NULL;
|
struct _workers_pool_t *pool = NULL;
|
||||||
bool wait_for_access = false;
|
int access_error = 0;
|
||||||
|
|
||||||
LOG_DEBUG("%s: stream->proc->stop=%d", __FUNCTION__, atomic_load(&stream->proc->stop));
|
LOG_DEBUG("%s: stream->proc->stop=%d", __FUNCTION__, atomic_load(&stream->proc->stop));
|
||||||
|
|
||||||
while (!atomic_load(&stream->proc->stop)) {
|
while (!atomic_load(&stream->proc->stop)) {
|
||||||
if (access(stream->dev->path, R_OK) < 0) {
|
if (access(stream->dev->path, R_OK|W_OK) < 0) {
|
||||||
if (!wait_for_access) {
|
if (access_error != errno) {
|
||||||
|
SEP_INFO('=');
|
||||||
LOG_PERROR("Can't access device");
|
LOG_PERROR("Can't access device");
|
||||||
LOG_INFO("Waiting for the device access ...");
|
LOG_INFO("Waiting for the device access ...");
|
||||||
wait_for_access = true;
|
access_error = errno;
|
||||||
}
|
}
|
||||||
sleep(stream->dev->error_delay);
|
sleep(stream->dev->error_delay);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
wait_for_access = false;
|
SEP_INFO('=');
|
||||||
|
access_error = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEP_INFO('=');
|
|
||||||
|
|
||||||
if ((pool = _stream_init_one(stream)) == NULL) {
|
if ((pool = _stream_init_one(stream)) == NULL) {
|
||||||
LOG_INFO("Sleeping %u seconds before new stream init ...", stream->dev->error_delay);
|
LOG_INFO("Sleeping %u seconds before new stream init ...", stream->dev->error_delay);
|
||||||
sleep(stream->dev->error_delay);
|
sleep(stream->dev->error_delay);
|
||||||
|
|||||||
Reference in New Issue
Block a user