mirror of
https://github.com/nginx/nginx.git
synced 2024-12-19 05:33:52 -06:00
use malloc() in ngx_win32_rename_file, set crit level instead of error
This commit is contained in:
parent
03df86a541
commit
27dd6a62bd
@ -295,7 +295,7 @@ ngx_http_dav_put_handler(ngx_http_request_t *r)
|
||||
#if (NGX_WIN32)
|
||||
|
||||
if (err == NGX_EEXIST) {
|
||||
if (ngx_win32_rename_file(temp, &path, r->pool) != NGX_ERROR) {
|
||||
if (ngx_win32_rename_file(temp, &path, r->connection->log) == NGX_OK) {
|
||||
|
||||
if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) {
|
||||
goto ok;
|
||||
|
@ -2224,7 +2224,7 @@ ngx_http_upstream_store(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
#if (NGX_WIN32)
|
||||
|
||||
if (err == NGX_EEXIST) {
|
||||
if (ngx_win32_rename_file(temp, &path, r->pool) != NGX_ERROR) {
|
||||
if (ngx_win32_rename_file(temp, &path, r->connection->log) == NGX_OK) {
|
||||
|
||||
if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) {
|
||||
return;
|
||||
|
@ -201,14 +201,14 @@ ngx_write_fd(ngx_fd_t fd, void *buf, size_t size)
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool)
|
||||
ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_log_t *log)
|
||||
{
|
||||
u_char *name;
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t collision;
|
||||
ngx_atomic_uint_t num;
|
||||
|
||||
name = ngx_palloc(pool, to->len + 1 + 10 + 1 + sizeof("DELETE"));
|
||||
name = ngx_alloc(to->len + 1 + 10 + 1 + sizeof("DELETE"), log);
|
||||
if (name == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -230,7 +230,7 @@ ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool)
|
||||
|
||||
collision = 1;
|
||||
|
||||
ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno, "MoveFile() failed");
|
||||
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, "MoveFile() failed");
|
||||
}
|
||||
|
||||
if (MoveFile((const char *) from->data, (const char *) to->data) == 0) {
|
||||
@ -241,15 +241,17 @@ ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool)
|
||||
}
|
||||
|
||||
if (DeleteFile((const char *) name) == 0) {
|
||||
ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno, "DeleteFile() failed");
|
||||
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, "DeleteFile() failed");
|
||||
}
|
||||
|
||||
if (rc == NGX_ERROR) {
|
||||
ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno, "MoveFile() failed");
|
||||
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, "MoveFile() failed");
|
||||
}
|
||||
|
||||
/* mutex_unlock() */
|
||||
|
||||
ngx_free(name);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,7 @@ ssize_t ngx_write_fd(ngx_fd_t fd, void *buf, size_t size);
|
||||
|
||||
#define ngx_rename_file(o, n) MoveFile((const char *) o, (const char *) n)
|
||||
#define ngx_rename_file_n "MoveFile()"
|
||||
ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to,
|
||||
ngx_pool_t *pool);
|
||||
ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_log_t *log);
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user