]> git.kaiwu.me - nginx.git/commitdiff
Win32: additional error code NGX_EEXIST_FILE (ticket #910).
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 29 Mar 2016 06:51:46 +0000 (09:51 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 29 Mar 2016 06:51:46 +0000 (09:51 +0300)
On Windows there are two possible error codes which correspond to
the EEXIST error code: ERROR_FILE_EXISTS used by CreateFile(CREATE_NEW),
and ERROR_ALREADY_EXISTS used by CreateDirectory().

MoveFile() seems to use both: ERROR_ALREADY_EXISTS when moving within
one filesystem, and ERROR_FILE_EXISTS when copying a file to a different
drive.

src/core/ngx_file.c
src/os/unix/ngx_errno.h
src/os/win32/ngx_errno.h

index 2dc2228655362f005accc666a8410e475d7b3c77..d3e2ecebf0263f57566fdbce158667cb5bc71870 100644 (file)
@@ -196,7 +196,7 @@ ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool,
 
         err = ngx_errno;
 
-        if (err == NGX_EEXIST) {
+        if (err == NGX_EEXIST_FILE) {
             n = (uint32_t) ngx_next_temp_number(1);
             continue;
         }
@@ -692,7 +692,7 @@ ngx_ext_rename_file(ngx_str_t *src, ngx_str_t *to, ngx_ext_rename_file_t *ext)
 
 #if (NGX_WIN32)
 
-    if (err == NGX_EEXIST) {
+    if (err == NGX_EEXIST || err == NGX_EEXIST_FILE) {
         err = ngx_win32_rename_file(src, to, ext->log);
 
         if (err == 0) {
index 16cafda31075c34299bff15d1b3d94a847487955..7d6ca764d6853f6a6bf4bcdb4f5b367284452448 100644 (file)
@@ -25,6 +25,7 @@ typedef int               ngx_err_t;
 #define NGX_EACCES        EACCES
 #define NGX_EBUSY         EBUSY
 #define NGX_EEXIST        EEXIST
+#define NGX_EEXIST_FILE   EEXIST
 #define NGX_EXDEV         EXDEV
 #define NGX_ENOTDIR       ENOTDIR
 #define NGX_EISDIR        EISDIR
index fd32145635f9d2f2d60ab10adb9fae1b35bf8ac6..02245e440dbba536f4a5ee4bd539a129dc63f169 100644 (file)
@@ -25,8 +25,14 @@ typedef DWORD                      ngx_err_t;
 #define NGX_ENOPATH                ERROR_PATH_NOT_FOUND
 #define NGX_ENOMEM                 ERROR_NOT_ENOUGH_MEMORY
 #define NGX_EACCES                 ERROR_ACCESS_DENIED
-/* it's seems that ERROR_FILE_EXISTS is not appropriate error code */
+/*
+ * there are two EEXIST error codes:
+ * ERROR_FILE_EXISTS used by CreateFile(CREATE_NEW),
+ * and ERROR_ALREADY_EXISTS used by CreateDirectory();
+ * MoveFile() uses both
+ */
 #define NGX_EEXIST                 ERROR_ALREADY_EXISTS
+#define NGX_EEXIST_FILE            ERROR_FILE_EXISTS
 /*
  * could not found cross volume directory move error code,
  * so use ERROR_WRONG_DISK as stub one