diff options
Diffstat (limited to '')
| -rw-r--r-- | src/os/unix/freebsd/ngx_rfork_thread.c (renamed from src/os/freebsd/ngx_os_thread.c) | 4 | ||||
| -rw-r--r-- | src/os/unix/freebsd/ngx_rfork_thread.h (renamed from src/os/freebsd/ngx_os_thread.h) | 0 | ||||
| -rw-r--r-- | src/os/unix/freebsd/ngx_sendfile.c (renamed from src/os/unix/ngx_sendfile.c) | 6 | ||||
| -rw-r--r-- | src/os/unix/ngx_errno.h | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_file.h | 29 | ||||
| -rw-r--r-- | src/os/unix/ngx_sendfile.h | 2 | ||||
| -rw-r--r-- | src/os/unix/ngx_sendv.c | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_sendv.h | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_socket.h | 3 | ||||
| -rw-r--r-- | src/os/unix/ngx_stat.h | 19 | ||||
| -rw-r--r-- | src/os/unix/ngx_time.h | 2 | ||||
| -rw-r--r-- | src/os/unix/ngx_types.h | 2 | ||||
| -rw-r--r-- | src/os/win32/ngx_errno.h | 1 | ||||
| -rw-r--r-- | src/os/win32/ngx_file.h | 52 | ||||
| -rw-r--r-- | src/os/win32/ngx_sendfile.c | 14 | ||||
| -rw-r--r-- | src/os/win32/ngx_sendfile.h | 1 | ||||
| -rw-r--r-- | src/os/win32/ngx_socket.c | 17 | ||||
| -rw-r--r-- | src/os/win32/ngx_socket.h | 7 | ||||
| -rw-r--r-- | src/os/win32/ngx_stat.c | 13 | ||||
| -rw-r--r-- | src/os/win32/ngx_stat.h | 10 | ||||
| -rw-r--r-- | src/os/win32/ngx_time.h | 2 | ||||
| -rw-r--r-- | src/os/win32/ngx_types.h | 1 |
22 files changed, 150 insertions, 38 deletions
diff --git a/src/os/freebsd/ngx_os_thread.c b/src/os/unix/freebsd/ngx_rfork_thread.c index f40956e20..acd5ec6e2 100644 --- a/src/os/freebsd/ngx_os_thread.c +++ b/src/os/unix/freebsd/ngx_rfork_thread.c @@ -17,7 +17,7 @@ int *__error() } -int ngx_create_os_thread(ngx_os_tid_t *tid, void *stack, +int ngx_create_thread(ngx_os_tid_t *tid, void *stack, int (*func)(void *arg), void *arg, ngx_log_t log) { int id, err; @@ -35,7 +35,7 @@ int ngx_create_os_thread(ngx_os_tid_t *tid, void *stack, } -int ngx_create_os_thread_env(int n, size_t size, ngx_log_t log) +int ngx_create_thread_env(int n, size_t size, ngx_log_t log) { char *addr; diff --git a/src/os/freebsd/ngx_os_thread.h b/src/os/unix/freebsd/ngx_rfork_thread.h index bd500e1a4..bd500e1a4 100644 --- a/src/os/freebsd/ngx_os_thread.h +++ b/src/os/unix/freebsd/ngx_rfork_thread.h diff --git a/src/os/unix/ngx_sendfile.c b/src/os/unix/freebsd/ngx_sendfile.c index 2bc157361..31915e405 100644 --- a/src/os/unix/ngx_sendfile.c +++ b/src/os/unix/freebsd/ngx_sendfile.c @@ -1,6 +1,8 @@ #include <ngx_config.h> #include <ngx_types.h> +#include <ngx_file.h> +#include <ngx_socket.h> #include <ngx_errno.h> #include <ngx_log.h> #include <ngx_sendv.h> @@ -56,8 +58,8 @@ int ngx_sendfile(ngx_socket_t s, } } - ngx_log_debug(log, "ngx_sendfile: %d, @%qd %d:%qd" _ - rc _ offset _ nbytes _ *sent); + ngx_log_debug(log, "ngx_sendfile: %d, @%qd %qd:%d" _ + rc _ offset _ *sent _ nbytes); return 0; } diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h index c14a977fa..2649fe9b4 100644 --- a/src/os/unix/ngx_errno.h +++ b/src/os/unix/ngx_errno.h @@ -10,6 +10,7 @@ typedef int ngx_err_t; #define NGX_ENOENT ENOENT #define NGX_EINTR EINTR #define NGX_EAGAIN EWOULDBLOCK +#define NGX_EADDRINUSE EADDRINUSE #define ngx_errno errno #define ngx_socket_errno errno diff --git a/src/os/unix/ngx_file.h b/src/os/unix/ngx_file.h new file mode 100644 index 000000000..0e05b8424 --- /dev/null +++ b/src/os/unix/ngx_file.h @@ -0,0 +1,29 @@ +#ifndef _NGX_FILE_H_INCLUDED_ +#define _NGX_FILE_H_INCLUDED_ + + +#include <sys/types.h> +#include <sys/stat.h> + +typedef int ngx_file_t; +typedef struct stat ngx_file_info_t; + + +#define ngx_open_file open +#define ngx_open_file_n "open" + +#define NGX_FILE_RDONLY O_RDONLY + + +#define ngx_file_type(file, sb) stat(file, sb) +#define ngx_file_type_n "stat" + +#define ngx_stat_fd(fd, sb) fstat(fd, sb) +#define ngx_stat_fd_n "fstat" + +#define ngx_is_dir(sb) (S_ISDIR(sb.st_mode)) +#define ngx_file_size(sb) sb.st_size +#define ngx_file_mtime(sb) sb.st_mtime + + +#endif /* _NGX_FILE_H_INCLUDED_ */ diff --git a/src/os/unix/ngx_sendfile.h b/src/os/unix/ngx_sendfile.h index a347c6c50..0a0a25e76 100644 --- a/src/os/unix/ngx_sendfile.h +++ b/src/os/unix/ngx_sendfile.h @@ -3,6 +3,8 @@ #include <ngx_types.h> +#include <ngx_file.h> +#include <ngx_socket.h> #include <ngx_log.h> #include <ngx_sendv.h> diff --git a/src/os/unix/ngx_sendv.c b/src/os/unix/ngx_sendv.c index bd95d7a7d..22838c2bb 100644 --- a/src/os/unix/ngx_sendv.c +++ b/src/os/unix/ngx_sendv.c @@ -1,5 +1,6 @@ #include <ngx_types.h> +#include <ngx_socket.h> #include <ngx_sendv.h> ssize_t ngx_sendv(ngx_socket_t s, ngx_iovec_t *iovec, int n, size_t *sent) diff --git a/src/os/unix/ngx_sendv.h b/src/os/unix/ngx_sendv.h index 16c24039b..5906e423b 100644 --- a/src/os/unix/ngx_sendv.h +++ b/src/os/unix/ngx_sendv.h @@ -3,6 +3,7 @@ #include <ngx_types.h> +#include <ngx_socket.h> typedef struct iovec ngx_iovec_t; #define ngx_iov_base iov_base diff --git a/src/os/unix/ngx_socket.h b/src/os/unix/ngx_socket.h index 18c07f9b0..e9e797474 100644 --- a/src/os/unix/ngx_socket.h +++ b/src/os/unix/ngx_socket.h @@ -12,5 +12,8 @@ typedef int ngx_socket_t; #define ngx_nonblocking(s) fcntl(s, F_SETFL, O_NONBLOCK) #define ngx_nonblocking_n "fcntl (O_NONBLOCK)" +#define ngx_close_socket close +#define ngx_close_socket_n "close" + #endif /* _NGX_SOCKET_H_INCLUDED_ */ diff --git a/src/os/unix/ngx_stat.h b/src/os/unix/ngx_stat.h deleted file mode 100644 index f42edff13..000000000 --- a/src/os/unix/ngx_stat.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _NGX_STAT_H_INCLUDED_ -#define _NGX_STAT_H_INCLUDED_ - - -#include <sys/types.h> -#include <sys/stat.h> - -typedef struct stat ngx_stat_t; - -#define ngx_is_dir(sb) (S_ISDIR(sb.st_mode)) - -#define ngx_stat(file, sb) stat(file, sb) -#define ngx_stat_n "stat" - -#define ngx_fstat(file, fd, sb) fstat(fd, sb) -#define ngx_fstat_n "stat" - - -#endif /* _NGX_STAT_H_INCLUDED_ */ diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h index b262da7cf..f81ee4efc 100644 --- a/src/os/unix/ngx_time.h +++ b/src/os/unix/ngx_time.h @@ -14,6 +14,8 @@ typedef struct tm ngx_tm_t; #define ngx_tm_year tm_year #define ngx_tm_wday tm_wday +#define ngx_msleep(ms) usleep(ms * 1000) + void ngx_localtime(ngx_tm_t *tm); u_int ngx_msec(void); diff --git a/src/os/unix/ngx_types.h b/src/os/unix/ngx_types.h index ebcbb1fac..94417cba9 100644 --- a/src/os/unix/ngx_types.h +++ b/src/os/unix/ngx_types.h @@ -5,8 +5,6 @@ #include <ngx_config.h> -typedef int ngx_file_t; -typedef int ngx_socket_t; #endif /* _NGX_TYPES_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_errno.h b/src/os/win32/ngx_errno.h index dc4cd5044..5197fdd17 100644 --- a/src/os/win32/ngx_errno.h +++ b/src/os/win32/ngx_errno.h @@ -11,6 +11,7 @@ typedef DWORD ngx_err_t; #define NGX_ENOENT ERROR_FILE_NOT_FOUND #define NGX_EAGAIN WSAEWOULDBLOCK +#define NGX_EADDRINUSE WSAEADDRINUSE int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size); diff --git a/src/os/win32/ngx_file.h b/src/os/win32/ngx_file.h new file mode 100644 index 000000000..cae823f5e --- /dev/null +++ b/src/os/win32/ngx_file.h @@ -0,0 +1,52 @@ +#ifndef _NGX_FILE_H_INCLUDED_ +#define _NGX_FILE_H_INCLUDED_ + + +#include <ngx_config.h> + + +/* INVALID_FILE_ATTRIBUTES specified but never defined at least in VC6SP2 */ +#ifndef INVALID_FILE_ATTRIBUTES +#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF +#endif + +typedef HANDLE ngx_file_t; +typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t; + + +#define ngx_open_file(name, flags) \ + CreateFile(name, flags, \ + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \ + NULL, OPEN_EXISTING, 0, NULL) + +#define ngx_open_file_n "CreateFile" + +#define NGX_FILE_RDONLY GENERIC_READ + + +int ngx_file_type(char *filename, ngx_file_info_t *fi); +#define ngx_file_type_n "GetFileAttributes" + +#define ngx_stat_fd(fd, fi) GetFileInformationByHandle(fd, fi) +#define ngx_stat_fd_n "GetFileInformationByHandle" + +#define ngx_is_dir(fi) (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + +#define ngx_file_size(fi) \ + fi.nFileSizeLow + +/* +#define ngx_file_size(fi) \ + ((off_t) fi.nFileSizeHigh << 32 & fi.nFileSizeLow) +*/ + +#define ngx_file_mtime(fi) fi.ftLastWriteTime + +/* +1970 - 1601: + 116444736000000000 + 19DB1DED53E8000 +*/ + + +#endif /* _NGX_FILE_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_sendfile.c b/src/os/win32/ngx_sendfile.c index 922a4f1f5..d17df6436 100644 --- a/src/os/win32/ngx_sendfile.c +++ b/src/os/win32/ngx_sendfile.c @@ -1,6 +1,7 @@ #include <ngx_config.h> #include <ngx_types.h> +#include <ngx_socket.h> #include <ngx_errno.h> #include <ngx_log.h> #include <ngx_sendv.h> @@ -52,16 +53,22 @@ int ngx_sendfile(ngx_socket_t s, ptfb = NULL; } +#if 0 tfrc = TransmitFile(s, fd, nbytes, 0, &olp, ptfb, 0); +#else + tfrc = TransmitFile(s, fd, nbytes, 0, NULL, ptfb, 0); +#endif if (tfrc == 0) tf_err = ngx_socket_errno; /* set sent */ +#if 0 rc = WSAGetOverlappedResult(s, &olp, (unsigned long *) sent, 0, NULL); +#endif - ngx_log_debug(log, "ngx_sendfile: %d, @%qd %d:%qd" _ - tfrc _ offset _ nbytes _ *sent); + ngx_log_debug(log, "ngx_sendfile: %d, @%I64d %I64d:%d" _ + tfrc _ offset _ *sent _ nbytes); if (rc == 0) { err = ngx_socket_errno; @@ -77,7 +84,8 @@ int ngx_sendfile(ngx_socket_t s, } ngx_log_error(NGX_LOG_INFO, log, tf_err, - "ngx_sendfile: TransmitFile sent only %qd bytes", *sent); + "ngx_sendfile: TransmitFile sent only %I64d bytes", + *sent); } if (rc == 0) diff --git a/src/os/win32/ngx_sendfile.h b/src/os/win32/ngx_sendfile.h index 5bad2b926..053db8ec2 100644 --- a/src/os/win32/ngx_sendfile.h +++ b/src/os/win32/ngx_sendfile.h @@ -4,6 +4,7 @@ #include <ngx_config.h> #include <ngx_types.h> +#include <ngx_socket.h> #include <ngx_log.h> #include <ngx_sendv.h> diff --git a/src/os/win32/ngx_socket.c b/src/os/win32/ngx_socket.c index 590eb08e7..d0e547ca6 100644 --- a/src/os/win32/ngx_socket.c +++ b/src/os/win32/ngx_socket.c @@ -1,8 +1,8 @@ -#include <nxg_config.h> +#include <ngx_config.h> -#include <nxg_log.h> -#include <nxg_errno.h> -#include <nxg_socket.h> +#include <ngx_log.h> +#include <ngx_errno.h> +#include <ngx_socket.h> void ngx_init_sockets(ngx_log_t *log) @@ -12,6 +12,8 @@ void ngx_init_sockets(ngx_log_t *log) if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, "ngx_init_sockets: WSAStartup failed"); + + /* get AcceptEx(), TransmitFile() functions */ } int ngx_nonblocking(ngx_socket_t s) @@ -20,3 +22,10 @@ int ngx_nonblocking(ngx_socket_t s) return ioctlsocket(s, FIONBIO, &nb); } + +int ngx_blocking(ngx_socket_t s) +{ + unsigned long nb = 0; + + return ioctlsocket(s, FIONBIO, &nb); +} diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h index 36ed26f69..7002795a7 100644 --- a/src/os/win32/ngx_socket.h +++ b/src/os/win32/ngx_socket.h @@ -3,14 +3,17 @@ #include <ngx_config.h> +#include <ngx_log.h> -typedef SOCKET ngx_socket_t; +typedef SOCKET ngx_socket_t; void ngx_init_sockets(ngx_log_t *log); int ngx_nonblocking_n(s); -#define ngx_nonblocking_n "ioctlsocket (FIONBIO)" +#define ngx_nonblocking_n "ioctlsocket (FIONBIO)" +#define ngx_close_socket closesocket +#define ngx_close_socket_n "closesocket" #endif /* _NGX_SOCKET_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_stat.c b/src/os/win32/ngx_stat.c index 5b1af3014..5c844b14f 100644 --- a/src/os/win32/ngx_stat.c +++ b/src/os/win32/ngx_stat.c @@ -3,6 +3,18 @@ #include <ngx_stat.h> +int ngx_file_type(char *file, ngx_file_info_t *sb) +{ + sb->dwFileAttributes = GetFileAttributes(file); + + if (sb->dwFileAttributes == INVALID_FILE_ATTRIBUTES) { + return -1; + } + + return 0; +} + +/* int ngx_stat(char *file, ngx_stat_t *sb) { *sb = GetFileAttributes(file); @@ -13,3 +25,4 @@ int ngx_stat(char *file, ngx_stat_t *sb) return 0; } +*/ diff --git a/src/os/win32/ngx_stat.h b/src/os/win32/ngx_stat.h index 600facd3e..6daf4e66e 100644 --- a/src/os/win32/ngx_stat.h +++ b/src/os/win32/ngx_stat.h @@ -4,15 +4,17 @@ #include <windows.h> -/* INVALID_FILE_ATTRIBUTES specified but never defined */ +/* INVALID_FILE_ATTRIBUTES specified but never defined at least in VC6SP2 */ #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF #endif -typedef DWORD ngx_stat_t; +typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t; -#define ngx_is_dir(sb) (*sb & FILE_ATTRIBUTE_DIRECTORY) +#define ngx_file_type_n "GetFileAttributes" + +#define ngx_is_dir(fi) (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) #define ngx_stat_n "GetFileAttributes" @@ -20,7 +22,9 @@ typedef DWORD ngx_stat_t; #define ngx_fstat_n "GetFileAttributes" +/* int ngx_stat(char *file, ngx_stat_t *sb); +*/ #endif /* _NGX_STAT_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_time.h b/src/os/win32/ngx_time.h index 57915ac1a..be932445a 100644 --- a/src/os/win32/ngx_time.h +++ b/src/os/win32/ngx_time.h @@ -5,6 +5,7 @@ #include <windows.h> typedef SYSTEMTIME ngx_tm_t; +typedef FILETIME ngx_mtime_t; #define ngx_tm_sec wSecond #define ngx_tm_min wMinute @@ -14,6 +15,7 @@ typedef SYSTEMTIME ngx_tm_t; #define ngx_tm_year wYear #define ngx_tm_wday wDayOfWeek +#define ngx_msleep Sleep #define ngx_localtime GetLocalTime #define ngx_msec GetTickCount diff --git a/src/os/win32/ngx_types.h b/src/os/win32/ngx_types.h index 5715e3fc4..85a2c56d0 100644 --- a/src/os/win32/ngx_types.h +++ b/src/os/win32/ngx_types.h @@ -6,7 +6,6 @@ typedef HANDLE ngx_file_t; -typedef SOCKET ngx_socket_t; typedef long time_t; typedef unsigned __int64 off_t; |
