Welcome! Log In Create A New Profile

Advanced

[nginx] Win32: ngx_open_dir() and ngx_close_dir() fixes.

Maxim Dounin
July 06, 2014 03:34PM
details: http://hg.nginx.org/nginx/rev/a680bf4dddd5
branches:
changeset: 5749:a680bf4dddd5
user: Maxim Dounin <mdounin@mdounin.ru>
date: Sat Jul 05 23:29:47 2014 +0400
description:
Win32: ngx_open_dir() and ngx_close_dir() fixes.

The ngx_open_dir() function changed to restore name passed to it. This
fixes removing destination directory in dav module, as caught by dav.t.
The ngx_close_dir() function introduced to properly convert errors, as
FindClose() returns 0 on error.

diffstat:

src/os/win32/ngx_files.c | 13 +++++++++++++
src/os/win32/ngx_files.h | 2 +-
2 files changed, 14 insertions(+), 1 deletions(-)

diffs (42 lines):

diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -430,6 +430,8 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t

dir->dir = FindFirstFile((const char *) name->data, &dir->finddata);

+ name->data[name->len] = '\0';
+
if (dir->dir == INVALID_HANDLE_VALUE) {
return NGX_ERROR;
}
@@ -459,6 +461,17 @@ ngx_read_dir(ngx_dir_t *dir)


ngx_int_t
+ngx_close_dir(ngx_dir_t *dir)
+{
+ if (FindClose(dir->dir) == 0) {
+ return NGX_ERROR;
+ }
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
ngx_open_glob(ngx_glob_t *gl)
{
u_char *p;
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -193,7 +193,7 @@ ngx_int_t ngx_read_dir(ngx_dir_t *dir);
#define ngx_read_dir_n "FindNextFile()"


-#define ngx_close_dir(d) FindClose((d)->dir)
+ngx_int_t ngx_close_dir(ngx_dir_t *dir);
#define ngx_close_dir_n "FindClose()"



_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Win32: ngx_open_dir() and ngx_close_dir() fixes.

Maxim Dounin 633 July 06, 2014 03:34PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 255
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready