Commit Graph

672 Commits

Author SHA1 Message Date
Maxim Dounin
c66a1e7a17 Workaround for fs_size on ZFS (ticket #46).
ZFS reports incorrect st_blocks until file settles on disk, and this
may take a while (i.e. just after creation of a file the st_blocks value
is incorrect).  As a workaround we now use st_blocks only if
st_blocks * 512 > st_size, this should fix ZFS problems while still
preserving accuracy for other filesystems.

The problem had appeared in r3900 (1.0.1).
2012-02-28 11:09:02 +00:00
Valentin Bartenev
86c5513ecb Disable symlinks: use O_SEARCH|O_DIRECTORY to open path components. 2012-02-21 15:10:13 +00:00
Maxim Dounin
7ba66f42a0 Disable symlinks: added explicit cast of AT_FDCWD (ticket #111).
Solaris has AT_FDCWD defined to unsigned value, and comparison of a file
descriptor with it causes warnings in modern versions of gcc.  Explicitly
cast AT_FDCWD to ngx_fd_t to resolve these warnings.
2012-02-20 19:14:35 +00:00
Andrey Belov
71205c3fbc Added openat()/fstatat(). 2012-02-13 16:13:21 +00:00
Valentin Bartenev
891b43db32 Added ngx_ncpu detection for most *nix platforms.
This inaccurate detection by using sysconf(_SC_NPROCESSORS_ONLN) can improve
usage of the mutex lock optimization on multicore systems.
2012-02-10 11:24:19 +00:00
Maxim Dounin
b3e461e63c Fixed AIO error handling on FreeBSD.
The aio_return() must be called regardless of the error returned by
aio_error().  Not calling it resulted in various problems up to segmentation
faults (as AIO events are level-triggered and were reported again and again).

Additionally, in "aio sendfile" case r->blocked was incremented in case of
error returned from ngx_file_aio_read(), thus causing request hangs.
2012-01-30 07:39:47 +00:00
Maxim Konovalov
f8d59e33f3 Copyright updated. 2012-01-18 15:07:43 +00:00
Maxim Dounin
b904676b5e Fixed sched_setaffinity(2) to correctly pass size.
Second argument (cpusetsize) is size in bytes, not in bits.  Previously
used constant 32 resulted in reading of uninitialized memory and caused
EINVAL to be returned on some Linux kernels.
2012-01-16 11:13:48 +00:00
Maxim Dounin
ae0e919135 Microoptimization of sendfile(2) usage under FreeBSD.
FreeBSD kernel checks headers/trailers pointer against NULL, not
corresponding count.  Passing NULL if there are no headers/trailers
helps to avoid unneeded work in kernel, as well as unexpected 0 bytes
GIO in traces.
2011-12-11 16:30:42 +00:00
Maxim Dounin
a4484b1369 Added (void) as we intentionally ignore returned values.
Requested by Igor Sysoev.
2011-11-28 11:01:42 +00:00
Maxim Dounin
13717da19e Unlock of shared memory zones on process crash.
If process exited abnormally while holding lock on some shared memory zone -
unlock it.  It may be not safe thing to do (as crash with lock held may
result in corrupted shared memory structure, and other processes will
subsequently crash while trying to access shared data), therefore complain
loudly if unlock succeeds.
2011-11-23 14:09:19 +00:00
Maxim Dounin
91ecc8f43c Added shmtx interface to forcibly unlock mutexes.
It is currently used from master process on abnormal worker termination to
unlock accept mutex (unlocking of accept mutex was broken in 1.0.2).  It is
expected to be used in the future to unlock other mutexes as well.

Shared mutex code was rewritten to make this possible in a safe way, i.e.
with a check if lock was actually held by the exited process.  We again use
pid to lock mutex, and use separate atomic variable for a count of processes
waiting in sem_wait().
2011-11-23 13:55:38 +00:00
Maxim Konovalov
f61b7b3a83 FreeBSD 10-current has recently gotten POSIX_FADV_* macros.
A fix for the broken build applied.

Patch from Igor Sysoev.
2011-11-18 18:42:00 +00:00
Igor Sysoev
07bb4ed971 Introduction of simple ngx_write_stderr() instead of ngx_log_stderr()
for output of ./configure options, etc., since ngx_log_stderr() output
length is limited by 2048 characters defined as NGX_MAX_ERROR_STR.
2011-11-14 14:59:00 +00:00
Ruslan Ermilov
c5762451a9 Fixed range checking for the "somaxconn" sysctl. 2011-10-25 13:48:05 +00:00
Igor Sysoev
efc6ecab82 malloc() debugging on MacOSX. 2011-10-24 15:46:48 +00:00
Maxim Dounin
ce61ff9c45 Fixed another return in unix ngx_write_chain_to_file().
Previous patch missed special case for one iovec, it needs total bytes
written to be returned as well.
2011-10-21 11:04:46 +00:00
Maxim Dounin
aecb2eda13 Fixed unix ngx_write_chain_to_file() to return total bytes written.
Previously result of last iteration's writev() was returned.  This was
unnoticed as return value was only used if chain contained only one or
two buffers.
2011-10-20 12:40:26 +00:00
Igor Sysoev
5f81070523 Fixing conflict with SDK off_t definition. 2011-10-20 07:12:45 +00:00
Igor Sysoev
1472e7964b Recent SDKs allow to build IPV6 only for Windows XP or above. 2011-10-20 07:00:04 +00:00
Ruslan Ermilov
a823c550e4 Replaced "can not" with "cannot" and "could not" in a bunch of places.
Fixed nearby grammar errors.
2011-09-19 14:48:29 +00:00
Igor Sysoev
4134b48b68 Fixing Linux AIO syscalls return value handling:
syscall(2) uses usual libc convention, it returns -1 on error and
sets errno. Obsolete _syscall(2) returns negative value of error.

Thanks to Hagai Avrahami.
2011-09-16 12:43:16 +00:00
Ruslan Ermilov
59efbc4bcb In Mac OS X Lion, Apple deprecated the use of the system OpenSSL library
in favour of their CommonCrypto library.  This change adds a work-around
that allows nginx to still be built on Lion with OpenSSL.
2011-09-13 09:18:43 +00:00
Maxim Dounin
4f65a05d18 Bugfix: open_file_cache lost is_directio flag.
On file retest open_file_cache lost is_directio if file wasn't changed.
This caused unaligned operations under Linux to fail with EINVAL.
It wasn't noticeable with AIO though, as errors wasn't properly logged.
2011-09-05 16:36:19 +00:00
Igor Sysoev
566dfe0c7f SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Non-daemon mode is currently used by supervisord, daemontools and so on
or during debugging. The NOACCEPT signal is only used for online upgrade
which is not supported when nginx is run under supervisord, etc.,
so this change should not break existant setups.
2011-08-22 12:34:48 +00:00
Maxim Dounin
de1a3e1e0c Fix buffer overrun under Windows. 2011-08-22 10:07:27 +00:00
Maxim Dounin
ec8186c733 Move SO_ACCEPTFILTER and TCP_DEFER_ACCEPT checks into configure.
NetBSD 5.0+ has SO_ACCEPTFILTER support merged from FreeBSD, and having
accept filter check in FreeBSD-specific ngx_freebsd_config.h prevents it
from being used on NetBSD.  Therefore move the check into configure (and
do the same for Linux-specific TCP_DEFER_ACCEPT, just to be in line).
2011-08-21 11:37:37 +00:00
Igor Sysoev
c2cafadfa5 elimination of reading cache files by cache loader 2011-07-24 19:46:53 +00:00
Igor Sysoev
5dc5945ccf "$apr1", "{PLAIN}", and "{SSHA}" password methods in auth basic module
patch by Maxim Dounin
2011-05-16 14:54:50 +00:00
Igor Sysoev
e2c8ad7122 use POSIX semaphores in shmtx instead of sched_yield()
number of spinlock spins are increased twice
2011-05-10 11:39:13 +00:00
Igor Sysoev
2bd01a0f01 revert r3864, it may cause kernel panic on some kernels while working with IPv6 2011-04-23 17:27:55 +00:00
Igor Sysoev
ef1f33b0db Use more precise stat.st_blocks to account cache size on Unix
instead of file length rounded to a file system block size.
There is no similar way on Windows, so rounding to a cache->bsize is kept.
2011-04-22 10:06:43 +00:00
Igor Sysoev
95899a3f19 use backlog -1 on Linux
thanks to Andrei Nigmatulin
2011-02-17 14:14:50 +00:00
Igor Sysoev
4d6db4a7ab set current atime while setting mtime
patch by Andrei Nigmatulin
2011-02-11 08:02:35 +00:00
Igor Sysoev
cc878dc6ac use SwitchToThread() instead of Sleep(0), because the later
may not yield control, if there is no thread with higher priority
2011-01-20 13:06:21 +00:00
Igor Sysoev
2567c92ace allow "env" to work in the single process mode 2010-12-13 10:55:15 +00:00
Igor Sysoev
d4b08c9134 allocate last zero byte in ngx_crypt() 2010-11-29 09:23:25 +00:00
Igor Sysoev
7f31a2098d use copied strerror() messages and autoconfigured sys_nerr value 2010-11-25 11:04:03 +00:00
Igor Sysoev
40747ad861 Linux accept4() support 2010-11-25 10:15:04 +00:00
Igor Sysoev
3bff22f2e2 update event flags after successful io_submit() 2010-10-12 12:11:11 +00:00
Igor Sysoev
8c70e67f7b worker_rlimit_core should be off_t 2010-09-15 15:24:21 +00:00
Igor Sysoev
8a9f761927 add "Global\" prefix for signal events 2010-09-02 13:49:05 +00:00
Igor Sysoev
f9dd541edb fix typo 2010-07-08 14:02:09 +00:00
Igor Sysoev
40b4ba1663 style fix 2010-07-08 13:49:21 +00:00
Igor Sysoev
ee37271a0f fix building by owc12: GetLongPathName() is available since Win2K only 2010-07-05 12:47:35 +00:00
Igor Sysoev
497c13774d HP/UX uses EWOULDBLOCK instead of EAGAIN 2010-07-03 20:16:55 +00:00
Igor Sysoev
c31c38b95e fix ngx_write_file() buf 2010-06-30 10:33:02 +00:00
Igor Sysoev
865db9bbf3 ngx_create_file_mapping() 2010-06-29 15:18:50 +00:00
Igor Sysoev
aa6936e61a style fix 2010-06-23 16:34:54 +00:00
Igor Sysoev
d50e53e675 do not free() stack allocated buffer 2010-06-14 18:09:52 +00:00
Igor Sysoev
3ec15dd090 use lstat() for WebDAV DELETE, COPY, and MOVE to handle symlinks 2010-04-22 17:15:42 +00:00
Igor Sysoev
bfc8b78f57 use non-blocking open() not to hang on FIFO files, etc. 2010-04-21 15:59:36 +00:00
Igor Sysoev
f59ae65fa4 use "rep; nop" instead of "pause" on Solaris/amd64 2010-03-26 13:38:41 +00:00
Igor Sysoev
6d45d8a50d *) introduce ngx_time_sigsafe_update() to update the error log time only
*) change ngx_time_update() interface
2010-03-25 09:10:10 +00:00
Igor Sysoev
2f916a9721 *) use previously cached GMT offset value to update time from a signal handler
*) change ngx_time_update() interface since there are no notification methods
   those return time
2010-03-13 18:08:07 +00:00
Igor Sysoev
9eaabc69ca use sys_errlist[] in signal handler instead
of non Async-Signal-Safe strerror_r()
2010-03-12 11:15:26 +00:00
Igor Sysoev
f953436886 compare long file names in case-insensitive mode,
the bug had been introduced in r3418
2010-03-03 10:05:54 +00:00
Igor Sysoev
10fa102e32 disable Win32 short file names 2010-01-28 14:17:51 +00:00
Igor Sysoev
fb0c73b08d fix building by gcc 4.x with -O2/3/s in some Linux distributions:
dereferencing type-punned pointer will break strict-aliasing rules
2009-12-22 15:29:56 +00:00
Igor Sysoev
44be39475c fix Win32 error messages when an temporary file replaces an existent file:
*) do not rename an already renamed file
*) now ngx_win32_rename_file() returns error code
*) do not log failure inside ngx_win32_rename_file()
2009-12-15 13:47:02 +00:00
Igor Sysoev
8f7c8f3c07 fix libatomic usage on arm, cris, hppa, m68k, and sparc platforms 2009-12-07 15:32:38 +00:00
Igor Sysoev
bdfa3baaee fix comment 2009-11-25 17:56:53 +00:00
Igor Sysoev
213cad8e81 libatomic_ops support 2009-11-25 17:55:25 +00:00
Igor Sysoev
89d635fa5d GCC 4.1 builtin atomic operations 2009-11-25 17:34:35 +00:00
Igor Sysoev
72db760eca add NGX_PROCESS_HELPER process status 2009-11-23 15:46:21 +00:00
Igor Sysoev
2952af08f1 a cache manager thread handle was overwritten by a cache loader thread handle,
this caused an exit delay, the bug had been introduced in r3023
2009-11-17 16:46:27 +00:00
Igor Sysoev
93da565962 fix building without --with-debug, introduced in r3328 2009-11-16 16:00:52 +00:00
Igor Sysoev
3e1a05c467 add alignment in debug log 2009-11-16 12:46:05 +00:00
Igor Sysoev
700a779824 fix posix_fadvise() error handling 2009-11-15 09:16:58 +00:00
Igor Sysoev
b13029c57c update allocation error messages 2009-11-15 09:03:08 +00:00
Igor Sysoev
fc514f1d07 fix posix_memalign() error handling 2009-11-15 08:56:40 +00:00
Igor Sysoev
9eadbde324 fix building without --with-debug, introduced in r3294 2009-11-11 12:32:06 +00:00
Igor Sysoev
8b620a8a97 delete useless statement 2009-11-05 17:09:02 +00:00
Igor Sysoev
4121aa3440 export aio presence knowledge to prevent using "aio sendfile",
if aio does not present
2009-11-05 13:12:30 +00:00
Igor Sysoev
9b67ca0e41 Fix a bug introduced in r2032: After a child process has read a terminate
message from a channel, the process tries to read the channel again.
The kernel (at least FreeBSD) may preempt the process and sends a SIGIO
signal to a master process. The master process sends a new terminate message,
the kernel switches again to the the child process, and the child process
reads the messages instead of an EAGAIN error. And this may repeat over
and over. Being that the child process can not exit the cycle and test
the termination flag set by the message handler.

The fix disallow the master process to send a new terminate message on
SIGIO signal reception. It may send the message only on SIGALARM signal.
2009-11-04 19:41:08 +00:00
Igor Sysoev
1bc750da2f use setproctitle("%s", title) 2009-11-03 16:28:21 +00:00
Igor Sysoev
f4b598b81b fix "if (!-x ...)" 2009-11-03 14:57:27 +00:00
Igor Sysoev
19811dbdde style fix 2009-11-02 12:41:56 +00:00
Igor Sysoev
baf8e409ba http listen unix domain sockets 2009-10-26 11:43:32 +00:00
Igor Sysoev
e58700d3b0 *) reset cached dirent.d_type after stat()
this fixes slash after link to a directory in ngx_http_autoindex_module;
*) use cached dirent.d_type as hint on all systems

the issues has been introduced in r2235
2009-10-14 11:33:35 +00:00
Igor Sysoev
3266171fd4 read_ahead 2009-09-30 13:21:52 +00:00
Igor Sysoev
29e7d8cc73 use parents around NGX_ATOMIC_T_LEN value 2009-09-25 20:25:47 +00:00
Igor Sysoev
48a28e2dad uniform ngx_directio_on/off() interface with other file functions 2009-09-25 14:17:28 +00:00
Igor Sysoev
38a7faadfe handle short pwrite() to log an error cause: ENOSPC, EDQUOT, or EFBIG 2009-09-25 13:55:46 +00:00
Igor Sysoev
5631879c7a test incomplete WriteFile() 2009-09-24 20:05:21 +00:00
Igor Sysoev
f4d97e2472 log file name for read/write errors 2009-09-24 20:04:10 +00:00
Igor Sysoev
4bcc725f83 delete Win95 code 2009-09-24 19:55:35 +00:00
Igor Sysoev
866e958c5d win32 ngx_file_info() utf8 support 2009-09-16 13:30:13 +00:00
Igor Sysoev
7e4e5e165f preserve errno while ngx_free() 2009-09-16 13:28:20 +00:00
Igor Sysoev
f0e12845a5 log offset passed to sendfile() 2009-09-04 09:53:09 +00:00
Igor Sysoev
2052077b93 small optimization 2009-09-04 09:50:58 +00:00
Igor Sysoev
bfff03406d aio sendfile 2009-08-30 09:52:39 +00:00
Igor Sysoev
8c491a77bc refactor EAGAIN/EINTR processing 2009-08-30 09:42:29 +00:00
Igor Sysoev
a962506498 FreeBSD and Linux AIO support 2009-08-28 08:12:35 +00:00
Igor Sysoev
450659e62a twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
and SIGIO signals quickly increase delay to the level when SIGKILL is sent
2009-08-26 15:12:28 +00:00
Igor Sysoev
31f6c5c55d style fix 2009-08-26 15:09:09 +00:00
Igor Sysoev
9262c6138e fix typo 2009-08-26 15:03:53 +00:00
Igor Sysoev
764c5eca29 ignore SIGSYS 2009-08-26 05:19:57 +00:00
Igor Sysoev
b71610eb09 *) move small declarations in appropriate places and delete the surplus
header files
*) delete insignificant comments
2009-08-25 09:09:13 +00:00
Igor Sysoev
3a58935936 *) share temporary number between workers
*) randomize collision offset
2009-08-21 09:06:35 +00:00
Igor Sysoev
c287a9811e fix debug point for left open sockets 2009-08-13 08:40:25 +00:00
Igor Sysoev
c9538c069f NGX_ENOPATH 2009-08-11 14:25:04 +00:00
Igor Sysoev
98ab9ce988 win32 cache loader support 2009-08-11 08:14:43 +00:00
Igor Sysoev
e9d8858da5 style fix 2009-08-11 07:55:39 +00:00
Igor Sysoev
632a1922fa delete mistaken sleep in the previous commit 2009-08-10 14:45:52 +00:00
Igor Sysoev
4413fad0db cache loader process 2009-08-10 13:27:14 +00:00
Igor Sysoev
07b280a29f introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly 2009-08-10 13:07:15 +00:00
Igor Sysoev
2642bf1a6d use caseless regex locations on caseless filesystems: MacOSX, Win32, Cygwin 2009-07-14 08:53:37 +00:00
Igor Sysoev
52833f2211 handle Win32 ReadFile() EOF state in Unix way 2009-07-13 09:32:49 +00:00
Igor Sysoev
eb5a64fdf2 style fix 2009-06-11 05:51:37 +00:00
Igor Sysoev
2d65078eff update r2925 2009-06-07 18:22:58 +00:00
Igor Sysoev
7b6b09f105 *) exit if no workers could not be started
*) do not quit old workers if no new workers could not be started
2009-06-06 12:36:44 +00:00
Igor Sysoev
a864311b12 fix debug logging 2009-06-05 17:44:49 +00:00
Igor Sysoev
42846485a2 test premature process termination 2009-06-02 14:26:59 +00:00
Igor Sysoev
130690fceb log GetExitCodeProcess()'s errno 2009-06-02 14:26:18 +00:00
Igor Sysoev
5b26bec9e8 *) fix memory leak in successful case
*) log shared memory name in failure case
2009-06-02 13:56:42 +00:00
Igor Sysoev
785ee23467 allow shared memory segments more than 4G 2009-05-30 17:06:38 +00:00
Igor Sysoev
6da803a6be fix logging in ngx_win32_rename_file() 2009-05-29 09:32:52 +00:00
Igor Sysoev
b7882d1213 add trailing zero to a file name 2009-05-29 09:31:48 +00:00
Igor Sysoev
b1897d2395 reconfigure master process 2009-05-08 18:12:03 +00:00
Igor Sysoev
4318688cce preserve Solaris binary hardware capabilities 2009-05-08 09:41:43 +00:00
Igor Sysoev
ef919756d9 uniform ngx_file_info() interface with ngx_fd_info() 2009-04-29 19:28:52 +00:00
Igor Sysoev
ff95d9290c style fix 2009-04-29 13:08:10 +00:00
Igor Sysoev
a70d086812 fix the previous commit 2009-04-29 13:07:16 +00:00
Igor Sysoev
bb8971fd26 fallback to neutral language in FormatMessage() 2009-04-28 15:06:29 +00:00
Igor Sysoev
9d4a8d9111 introduce ngx_write_console() to support OEM code pages 2009-04-28 15:05:27 +00:00
Igor Sysoev
28b313290b it seems MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT) returns
ERROR_RESOURCE_LANG_NOT_FOUND for Russian locale
2009-04-27 18:58:35 +00:00
Igor Sysoev
f67e0a4050 ngx_log_errno() 2009-04-27 13:17:33 +00:00
Igor Sysoev
e1c9746e37 use ngx_vslprintf(), ngx_slprintf() 2009-04-27 13:06:20 +00:00
Igor Sysoev
5ef370df40 -p and --prefix= 2009-04-27 11:32:33 +00:00
Igor Sysoev
caf17102e8 pass command lines options to workers 2009-04-23 18:22:28 +00:00
Igor Sysoev
bf14b000e6 ngx_path_separator() 2009-04-23 16:38:59 +00:00
Igor Sysoev
c28ff717cb issue start up errors and warning on both stderr and error_log 2009-04-23 11:13:12 +00:00
Igor Sysoev
fce0ab53ad axe incomplete support of Winsock error descriptions on NT 2009-04-22 11:25:12 +00:00
Igor Sysoev
b5b7e89469 use English only error descriptions in Win32 ngx_strerror_r() 2009-04-22 11:20:31 +00:00
Igor Sysoev
c8e9f26a57 implement "-s signal" option for Unix 2009-04-21 20:25:49 +00:00
Igor Sysoev
80ce3d4dd1 style fix: remove trailing spaces 2009-04-21 19:49:48 +00:00
Igor Sysoev
e980a6814b add 48x48 icon 2009-04-21 15:44:39 +00:00
Igor Sysoev
bd91999ea5 Win32 master/workers model 2009-04-20 06:08:47 +00:00
Igor Sysoev
b533e98252 fix Win32 ngx_gettimezone() 2009-04-19 19:08:49 +00:00
Igor Sysoev
f7a08d5f9a support attaching to an existent Win32 shared memory 2009-04-18 19:27:28 +00:00
Igor Sysoev
6ac68bcc4c update c->sent in ngx_unix_send() 2009-04-18 19:13:53 +00:00
Igor Sysoev
c7f876bd4c move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory 2009-04-16 19:25:09 +00:00
Igor Sysoev
a2de7b9b93 delete win32 ngx_file_append_mode() as we use reliable
FILE_APPEND_DATA|SYNCHRONIZE flags
2009-04-08 19:13:28 +00:00
Igor Sysoev
2ec2e35efe adopt NGX_FILE_TRUNCATE for win32 2009-04-08 19:03:41 +00:00
Igor Sysoev
c919d3178a autoconfigure crypt_r(): uclibc has no crypt_r() 2009-04-02 13:46:39 +00:00
Igor Sysoev
76f42ca21a fix OpenBSD building, broken in r2616 2009-04-02 13:44:32 +00:00
Igor Sysoev
de9fca55b1 fix MacOSX building, broken in r2616 2009-04-01 13:09:36 +00:00
Igor Sysoev
24c2787163 Win32 appends synchronized if only FILE_APPEND_DATA and SYNCHRONIZE are set
without any other flags. On the other hand, Unix requires at least the write
flag to be set together with O_APPEND.
2009-03-31 13:52:01 +00:00
Igor Sysoev
fadc7a7e81 win32 ngx_open_file() supports utf8 names and NGX_FILE_APPEND 2009-03-30 14:51:51 +00:00