Mercurial > hg > nginx
view src/os/win32/ngx_files.c @ 509:9b8c906f6e63 release-0.1.29
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 12 May 2005 14:58:06 +0000 |
parents | d4ea69372b94 |
children | e48ebafc6939 |
line wrap: on
line source
/* * Copyright (C) Igor Sysoev */ #include <ngx_config.h> #include <ngx_core.h> ssize_t ngx_read_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset) { long high_offset; u_long n; ngx_err_t err; OVERLAPPED ovlp, *povlp; if (ngx_win32_version < NGX_WIN_NT) { /* * under Win9X the overlapped pointer must be NULL * so we have to use SetFilePointer() to set the offset */ if (file->offset != offset) { /* * the maximum file size on the FAT16 is 2G, but on the FAT32 * the size is 4G so we have to use the high_offset * because a single offset is signed value */ high_offset = (long) (offset >> 32); if (SetFilePointer(file->fd, (long) offset, &high_offset, FILE_BEGIN) == INVALID_SET_FILE_POINTER) { /* * INVALID_SET_FILE_POINTER is 0xffffffff and it can be valid * value for large file so we need also to check GetLastError() */ err = ngx_errno; if (err != NO_ERROR) { ngx_log_error(NGX_LOG_ERR, file->log, err, "SeekFilePointer() failed"); return NGX_ERROR; } } } povlp = NULL; } else { ovlp.Internal = 0; ovlp.InternalHigh = 0; ovlp.Offset = (u_long) offset; ovlp.OffsetHigh = (u_long) (offset >> 32); ovlp.hEvent = NULL; povlp = &ovlp; } if (ReadFile(file->fd, buf, size, &n, povlp) == 0) { ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, "ReadFile() failed"); return NGX_ERROR; } file->offset += n; return n; } ssize_t ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset) { long high_offset; u_long n; ngx_err_t err; OVERLAPPED ovlp, *povlp; if (ngx_win32_version < NGX_WIN_NT) { /* * under Win9X the overlapped pointer must be NULL * so we have to use SetFilePointer() to set the offset */ if (file->offset != offset) { /* * the maximum file size on the FAT16 is 2G, but on the FAT32 * the size is 4G so we have to use high_offset * because a single offset is signed value */ high_offset = (long) (offset >> 32); if (SetFilePointer(file->fd, (long) offset, &high_offset, FILE_BEGIN) == INVALID_SET_FILE_POINTER) { /* * INVALID_SET_FILE_POINTER is 0xffffffff and it can be valid * value for large file so we need also to check GetLastError() */ err = ngx_errno; if (err != NO_ERROR) { ngx_log_error(NGX_LOG_ERR, file->log, err, "SeekFilePointer() failed"); return NGX_ERROR; } } } povlp = NULL; } else { ovlp.Internal = 0; ovlp.InternalHigh = 0; ovlp.Offset = (u_long) offset; ovlp.OffsetHigh = (u_long) (offset >> 32); ovlp.hEvent = NULL; povlp = &ovlp; } if (WriteFile(file->fd, buf, size, &n, povlp) == 0) { ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, "WriteFile() failed"); return NGX_ERROR; } file->offset += n; return n; } ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset, ngx_pool_t *pool) { u_char *buf, *prev; size_t size; ssize_t total, n; total = 0; while (cl) { buf = cl->buf->pos; prev = buf; size = 0; /* coalesce the neighbouring bufs */ while (cl && prev == cl->buf->pos) { size += cl->buf->last - cl->buf->pos; prev = cl->buf->last; cl = cl->next; } n = ngx_write_file(file, buf, size, offset); if (n == NGX_ERROR) { return NGX_ERROR; } total += n; offset += n; } return total; } ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool) { 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")); if (name == NULL) { return NGX_ERROR; } ngx_memcpy(name, to->data, to->len); collision = 0; /* mutex_lock() (per cache or single ?) */ for ( ;; ) { num = ngx_next_temp_number(collision); ngx_sprintf(name + to->len, ".%0muA.DELETE", num); if (MoveFile((const char *) to->data, (const char *) name) != 0) { break; } collision = 1; ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno, "MoveFile() failed"); } if (MoveFile((const char *) from->data, (const char *) to->data) == 0) { rc = NGX_ERROR; } else { rc = NGX_OK; } if (ngx_win32_version >= NGX_WIN_NT) { if (DeleteFile((const char *) name) == 0) { ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno, "DeleteFile() failed"); } } else { /* TODO: Win9X: update the open files table */ } if (rc == NGX_ERROR) { ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno, "MoveFile() failed"); } /* mutex_unlock() */ return rc; } #if 0 ngx_int_t ngx_file_info(char *file, ngx_file_info_t *sb) { WIN32_FILE_ATTRIBUTE_DATA fa; /* NT4 and Win98 */ if (GetFileAttributesEx(file, GetFileExInfoStandard, &fa) == 0) { return NGX_ERROR; } sb->dwFileAttributes = fa.dwFileAttributes; sb->ftCreationTime = fa.ftCreationTime; sb->ftLastAccessTime = fa.ftLastAccessTime; sb->ftLastWriteTime = fa.ftLastWriteTime; sb->nFileSizeHigh = fa.nFileSizeHigh; sb->nFileSizeLow = fa.nFileSizeLow; return NGX_OK; } #endif ngx_int_t ngx_file_info(u_char *file, ngx_file_info_t *sb) { /* Win95 */ sb->dwFileAttributes = GetFileAttributes((const char *) file); if (sb->dwFileAttributes == INVALID_FILE_ATTRIBUTES) { return NGX_ERROR; } return NGX_OK; } ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir) { ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1); dir->dir = FindFirstFile((const char *) name->data, &dir->fd); if (dir->dir == INVALID_HANDLE_VALUE) { return NGX_ERROR; } dir->valid_info = 1; dir->ready = 1; return NGX_OK; } ngx_int_t ngx_read_dir(ngx_dir_t *dir) { if (dir->ready) { dir->ready = 0; return NGX_OK; } if (FindNextFile(dir->dir, &dir->fd) == 0) { return NGX_ERROR; } return NGX_OK; } ngx_int_t ngx_de_info(u_char *name, ngx_dir_t *dir) { return NGX_OK; } ngx_int_t ngx_de_link_info(u_char *name, ngx_dir_t *dir) { return NGX_OK; } ngx_int_t ngx_file_append_mode(ngx_fd_t fd) { #if 0 if (LockFile(fd, 0, 0, 0xffffffff, 0xffffffff) == 0) { return NGX_ERROR; } #endif if (SetFilePointer(fd, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER) { if (ngx_errno != NO_ERROR) { return NGX_ERROR; } } #if 0 if (UnlockFile(fd, 0, 0, 0xffffffff, 0xffffffff) == 0) { return NGX_ERROR; } #endif return NGX_OK; }