From a1b1c205f190168a7bd9beff2c290650b541810d Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 28 Nov 2013 18:55:38 +0400 Subject: [PATCH 1/4] removed extra ngx_de_info call in win32 --- dash/ngx_rtmp_dash_module.c | 2 +- hls/ngx_rtmp_hls_module.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index f151ea1..931ce30 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -1280,7 +1280,7 @@ ngx_rtmp_dash_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) nentries++; - if (ngx_de_info(path, &dir) == NGX_FILE_ERROR) { + if (!dir.valid_info && ngx_de_info(path, &dir) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, ngx_errno, "dash: cleanup " ngx_de_info_n " \"%V\" failed", &spath); diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index 3b5319a..09e2765 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -1941,7 +1941,7 @@ ngx_rtmp_hls_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) nentries++; - if (ngx_de_info(path, &dir) == NGX_FILE_ERROR) { + if (!dir.valid_info && ngx_de_info(path, &dir) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, ngx_errno, "hls: cleanup " ngx_de_info_n " \"%V\" failed", &spath); From ec5687f45972bbf09ab3bbd0d310ac13c99a347a Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 28 Nov 2013 19:05:21 +0400 Subject: [PATCH 2/4] improved result code check to work on windows --- dash/ngx_rtmp_dash_module.c | 7 ++++--- hls/ngx_rtmp_hls_module.c | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index 931ce30..aeae90a 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -1294,9 +1294,10 @@ ngx_rtmp_dash_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) ngx_log_debug1(NGX_LOG_DEBUG_RTMP, ngx_cycle->log, 0, "dash: cleanup dir '%V'", &name); - if (ngx_delete_dir(spath.data) != NGX_OK) { + if (ngx_delete_dir(spath.data) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, - "dash: cleanup dir error '%V'", &spath); + "dash: cleanup " ngx_delete_dir_n + "failed on '%V'", &spath); } else { nerased++; } @@ -1384,7 +1385,7 @@ ngx_rtmp_dash_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) "dash: cleanup '%V' mtime=%T age=%T", &name, mtime, ngx_cached_time->sec - mtime); - if (ngx_delete_file(spath.data) != NGX_OK) { + if (ngx_delete_file(spath.data) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, "dash: cleanup " ngx_delete_file_n " failed on '%V'", &spath); diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index 09e2765..a32054e 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -1957,7 +1957,8 @@ ngx_rtmp_hls_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) if (ngx_delete_dir(spath.data) != NGX_OK) { ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, - "hls: cleanup dir error '%V'", &spath); + "hls: cleanup " ngx_delete_dir_n + "failed on '%V'", &spath); } else { nerased++; } @@ -1999,9 +2000,10 @@ ngx_rtmp_hls_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) "hls: cleanup '%V' mtime=%T age=%T", &name, mtime, ngx_cached_time->sec - mtime); - if (ngx_delete_file(spath.data) != NGX_OK) { + if (ngx_delete_file(spath.data) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, - "hls: cleanup error '%V'", &spath); + "hls: cleanup " ngx_delete_file_n " failed on '%V'", + &spath); continue; } From c928742cb98c97e72b51ed11eef7b47a857607a8 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 28 Nov 2013 19:11:31 +0400 Subject: [PATCH 3/4] fixed file op result code checks --- dash/ngx_rtmp_dash_module.c | 4 +++- hls/ngx_rtmp_hls_module.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index aeae90a..f7bea34 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -431,7 +431,9 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s) ngx_close_file(fd); - if (ngx_rtmp_dash_rename_file(ctx->playlist_bak.data, ctx->playlist.data)) { + if (ngx_rtmp_dash_rename_file(ctx->playlist_bak.data, ctx->playlist.data) + == NGX_FILE_ERROR) + { ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno, "dash: rename failed: '%V'->'%V'", &ctx->playlist_bak, &ctx->playlist); diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index a32054e..dc23f7f 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -474,10 +474,10 @@ ngx_rtmp_hls_write_variant_playlist(ngx_rtmp_session_t *s) ngx_close_file(fd); - rc = ngx_rtmp_hls_rename_file(ctx->var_playlist_bak.data, - ctx->var_playlist.data); - - if (rc != NGX_OK) { + if (ngx_rtmp_hls_rename_file(ctx->var_playlist_bak.data, + ctx->var_playlist.data) + == NGX_FILE_ERROR) + { ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno, "hls: rename failed: '%V'->'%V'", &ctx->var_playlist_bak, &ctx->var_playlist); @@ -497,7 +497,7 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s) ngx_rtmp_hls_ctx_t *ctx; ssize_t n; ngx_rtmp_hls_app_conf_t *hacf; - ngx_int_t nretry, rc; + ngx_int_t nretry; ngx_rtmp_hls_frag_t *f; ngx_uint_t i, max_frag; ngx_str_t name_part; @@ -592,9 +592,9 @@ retry: ngx_close_file(fd); - rc = ngx_rtmp_hls_rename_file(ctx->playlist_bak.data, ctx->playlist.data); - - if (rc != NGX_OK) { + if (ngx_rtmp_hls_rename_file(ctx->playlist_bak.data, ctx->playlist.data) + == NGX_FILE_ERROR) + { ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno, "hls: rename failed: '%V'->'%V'", &ctx->playlist_bak, &ctx->playlist); From 43718388f4e3b09cfcdcf9a72b4f0a4bac619ab4 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 28 Nov 2013 19:51:15 +0400 Subject: [PATCH 4/4] fixed time formatting & file op error code check --- dash/ngx_rtmp_dash_module.c | 4 ++-- hls/ngx_rtmp_hls_module.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index f7bea34..2fd7805 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -340,7 +340,7 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s) ngx_rtmp_dash_get_frag(s, 0)->timestamp / 1000, &tm); *ngx_sprintf(start_time, "%4d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", - tm.tm_year, tm.tm_mon, + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, ctx->start_time.gmtoff < 0 ? '-' : '+', @@ -353,7 +353,7 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s) 1000, &tm); *ngx_sprintf(end_time, "%4d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", - tm.tm_year, tm.tm_mon, + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, ctx->start_time.gmtoff < 0 ? '-' : '+', diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index dc23f7f..09d80ac 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -315,7 +315,7 @@ ngx_rtmp_hls_create_parent_dir(ngx_rtmp_session_t *s) *ngx_snprintf(path, sizeof(path) - 1, "%V", &hacf->path) = 0; - if (ngx_create_dir(path, NGX_RTMP_HLS_DIR_ACCESS) != NGX_OK) { + if (ngx_create_dir(path, NGX_RTMP_HLS_DIR_ACCESS) == NGX_FILE_ERROR) { err = ngx_errno; if (err != NGX_EEXIST) { ngx_log_error(NGX_LOG_ERR, s->connection->log, err, @@ -342,7 +342,7 @@ ngx_rtmp_hls_create_parent_dir(ngx_rtmp_session_t *s) ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, "hls: creating nested folder: '%s'", path); - if (ngx_create_dir(path, NGX_RTMP_HLS_DIR_ACCESS) != NGX_OK) { + if (ngx_create_dir(path, NGX_RTMP_HLS_DIR_ACCESS) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno, "hls: error creating nested folder: '%s'", path); return NGX_ERROR;