diff --git a/ngx_rtmp_record_module.c b/ngx_rtmp_record_module.c index f535d52..5db8038 100644 --- a/ngx_rtmp_record_module.c +++ b/ngx_rtmp_record_module.c @@ -387,8 +387,12 @@ ngx_rtmp_record_make_path(ngx_rtmp_session_t *s, static void ngx_rtmp_record_notify_error(ngx_rtmp_session_t *s, - ngx_rtmp_record_app_conf_t *rracf) + ngx_rtmp_record_rec_ctx_t *rctx) { + ngx_rtmp_record_app_conf_t *rracf = rctx->conf; + + rctx->failed = 1; + if (!rracf->notify) { return; } @@ -425,6 +429,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_session_t *s, rctx->last = *ngx_cached_time; rctx->file.offset = 0; + rctx->failed = 0; rctx->file.log = s->connection->log; rctx->file.fd = ngx_open_file(path.data, NGX_FILE_WRONLY, NGX_FILE_TRUNCATE, NGX_FILE_DEFAULT_ACCESS); @@ -438,7 +443,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_session_t *s, &rracf->id, &path); } - ngx_rtmp_record_notify_error(s, rracf); + ngx_rtmp_record_notify_error(s, rctx); return NGX_OK; } @@ -588,7 +593,7 @@ ngx_rtmp_record_node_close(ngx_rtmp_session_t *s, ngx_log_error(NGX_LOG_CRIT, s->connection->log, err, "record: %V error closing file", &rracf->id); - ngx_rtmp_record_notify_error(s, rracf); + ngx_rtmp_record_notify_error(s, rctx); } rctx->file.fd = NGX_INVALID_FILE; @@ -690,7 +695,7 @@ ngx_rtmp_record_write_frame(ngx_rtmp_session_t *s, if (ngx_write_file(&rctx->file, hdr, ph - hdr, rctx->file.offset) == NGX_ERROR) { - ngx_rtmp_record_notify_error(s, rracf); + ngx_rtmp_record_notify_error(s, rctx); ngx_close_file(rctx->file.fd); @@ -824,7 +829,7 @@ ngx_rtmp_record_node_av(ngx_rtmp_session_t *s, ngx_rtmp_record_rec_ctx_t *rctx, ngx_rtmp_record_node_open(s, rctx); } - } else { + } else if (!rctx->failed) { ngx_rtmp_record_node_open(s, rctx); } } diff --git a/ngx_rtmp_record_module.h b/ngx_rtmp_record_module.h index e816e3f..61f8e7c 100644 --- a/ngx_rtmp_record_module.h +++ b/ngx_rtmp_record_module.h @@ -41,6 +41,7 @@ typedef struct { uint32_t epoch; ngx_time_t last; time_t timestamp; + unsigned failed:1; } ngx_rtmp_record_rec_ctx_t;