Commit Graph

121 Commits

Author SHA1 Message Date
Maxim Dounin 8a93bc9885 Merge of r5138: use of NGX_FILE_ERROR.
Use NGX_FILE_ERROR for handling file operations errors.

On Win32 platforms 0 is used to indicate errors in file operations, so
comparing against either -1 or NGX_OK is not portable.

This was not much of an issue in patched code, since only ngx_fd_info() test
is actually reachable on Win32 and in worst case it might result in bogus
error log entry.

Patch by Piotr Sikora.
2013-03-29 18:18:42 +00:00
Maxim Dounin 7cc223cc54 Merge of r4985, r4986, r4987, r4988, r4989, r5002: access_log gzip.
*) Access log: fixed redundant buffer reallocation.  Previously a new
   buffer was allocated for every "access_log" directive with the same
   file path and "buffer=" parameters, while only one buffer per file
   is used.

*) Reopening log files code moved to a separate function.  The code
   refactored in a way to call custom handler that can do appropriate
   cleanup work (if any), like flushing buffers, finishing compress
   streams, finalizing connections to log daemon, etc..

*) Access log: the "flush" parameter of the "access_log" directive.

*) Configure: added the NGX_ZLIB define.  This was introduced for
   conditional compilation of the code that requires the zlib library.

*) Access log: the "gzip" parameter of the "access_log" directive.
   Note: this requires zlib version 1.2.0.4 or above to work.

*) The data pointer in ngx_open_file_t objects must be initialized.
   Uninitialized pointer may result in arbitrary segfaults if access_log
   is used without buffer and without variables in file path.
   Patch by Tatsuhiko Kubo (ticket #268).
2013-02-11 14:34:00 +00:00
Maxim Dounin f2d783ed9e Merge of r4967: ngx_write_fd() and ngx_read_fd() errors handling.
The ngx_write_fd() and ngx_read_fd() functions return -1 in case of error,
so the incorrect comparison with NGX_FILE_ERROR (which is 0 on windows
platforms) might result in inaccurate error message in the error log.

Also the ngx_errno global variable is being set only if the returned value
is -1.
2013-02-10 03:55:18 +00:00
Maxim Dounin 3428ae9ab1 Merge of r4933, r4933: shared memory fixes.
*) Fixed location of debug message in ngx_shmtx_lock().

*) Core: don't reuse shared memory zone that changed ownership (ticket #210).

   nginx doesn't allow the same shared memory zone to be used for different
   purposes, but failed to check this on reconfiguration.  If a shared memory
   zone was used for another purpose in the new configuration, nginx attempted
   to reuse it and crashed.
2012-12-10 18:17:32 +00:00
Maxim Dounin f4fd2d59a3 Merge of r4870, r4871, r4890, r4895: minor fixes.
*) Made sure to initialize the entire ngx_file_t structure.
   Found by Coverity.

*) Correct plural form for "path" in the whole source base.

*) Removed conditional compilation from waitpid() error test.

   There are reports that call to a signal handler for an exited process
   despite waitpid() already called for the process may happen on Linux
   as well.

*) Style, parentheses instead of braces in misc/GNUMakefile.
2012-11-12 18:39:51 +00:00
Maxim Dounin cc1bb6ebdf Merge of r4778, r4782, r4783, r4824, r4830, r4834: minor fixes.
*) Reorder checks in ngx_shared_memory_add() for more consistent
   error messages.

*) Added "const" to ngx_memcpy() with NGX_MEMCPY_LIMIT defined.  This
   fixes warning produced during compilation of the ngx_http_geoip_module
   due to const qualifier being discarded.

*) Fixed possible use of old cached times if runtime went backwards.

   If ngx_time_sigsafe_update() updated only ngx_cached_err_log_time, and
   then clock was adjusted backwards, the cached_time[slot].sec might
   accidentally match current seconds on next ngx_time_update() call,
   resulting in various cached times not being updated.

   Fix is to clear the cached_time[slot].sec to explicitly mark cached times
   are stale and need updating.

*) Radix tree preallocation fix.  The preallocation size was calculated
   incorrectly and was always 8 due to sizeof(ngx_radix_tree_t) accidentally
   used instead of sizeof(ngx_radix_node_t).

*) Fixed overflow if ngx_slab_alloc() is called with very big "size"
   argument.

*) Write filter: replaced unneeded loop with one to free chains.
   Noted by Gabor Lekeny.
2012-09-24 18:34:04 +00:00
Maxim Konovalov 0330b7ef84 Copyright updated. 2012-01-18 15:07:43 +00:00
Maxim Dounin 9d2d3aee6d 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
Ruslan Ermilov 0826f5639c 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 12bbdf5d86 A new fix for the case when ssl_session_cache defined, but ssl is not
enabled in any server. The previous r1033 does not help when unused zone
becomes used after reconfiguration, so it is backed out.

The initial thought was to make SSL modules independed from SSL implementation
and to keep OpenSSL code dependance as much as in separate files.
2011-08-04 11:12:30 +00:00
Igor Sysoev 018038fcf1 reuse keepalive connections if there are no free worker connections
patch by Maxim Dounin
2011-04-04 12:26:53 +00:00
Igor Sysoev 7c48ce89c5 the -q switch 2010-09-02 13:43:02 +00:00
Igor Sysoev 1796c210b5 fix IPv6 listen socket handling while reconfiguring 2010-06-30 12:01:56 +00:00
Igor Sysoev df4aaffdbe *) delete no longer used unix domain sockets
*) fix unix domain socket comparison
2010-06-04 13:34:23 +00:00
Igor Sysoev b172591b1c *) 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 72d46f41f8 *) 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 911b118ad5 use lowcase only hostname 2009-10-21 17:04:13 +00:00
Igor Sysoev 3b3b8717c8 restore environ, this fixes segfault on reconfiguration failure when
perl module creates new environment
2009-09-18 09:21:14 +00:00
Igor Sysoev fdbadce11c fix comment 2009-09-18 09:12:40 +00:00
Igor Sysoev 05e1e263c7 win32 master process had aready closed listening sockets 2009-06-06 12:53:55 +00:00
Igor Sysoev dd0d5fba54 a signaller process should stop configuration processing just after
it is able to get pid file, this allows to not open log files, etc.
2009-06-06 12:41:31 +00:00
Igor Sysoev 4caaeef170 return NULL instead of NGX_CONF_ERROR on a create conf failure 2009-06-02 16:09:44 +00:00
Igor Sysoev 4c5403bbf7 test that zone has the same addresses in different processes 2009-06-02 13:57:59 +00:00
Igor Sysoev 96e846f670 use correct name 2009-05-05 13:12:59 +00:00
Igor Sysoev 4709d5d80f *) refactor error_log processing: listen socket log might inherit built-in
error_log with zero level, and r2447, r2466, r2467 were not enough
*) remove bogus "stderr" level
*) some functions and fields renames
2009-04-30 13:53:42 +00:00
Igor Sysoev 5b0c886626 uniform ngx_file_info() interface with ngx_fd_info() 2009-04-29 19:28:52 +00:00
Igor Sysoev 0ae870d26b -p and --prefix= 2009-04-27 11:32:33 +00:00
Igor Sysoev ddba51983f issue start up errors and warning on both stderr and error_log 2009-04-23 11:13:12 +00:00
Igor Sysoev a0ad107cee implement "-s signal" option for Unix 2009-04-21 20:25:49 +00:00
Igor Sysoev 613828e9c2 style fix: remove tabs 2009-04-21 19:38:02 +00:00
Igor Sysoev 783a4563b5 Win32 master/workers model 2009-04-20 06:08:47 +00:00
Igor Sysoev 2668e22fa1 show -t results on stderr 2009-04-19 16:06:09 +00:00
Igor Sysoev 523bf6b61f support attaching to an existent Win32 shared memory 2009-04-18 19:27:28 +00:00
Igor Sysoev 1b247358f5 fix the previous commit 2009-04-17 19:09:08 +00:00
Igor Sysoev 692c1103da 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 6cc13ed833 style fix 2009-04-08 19:51:30 +00:00
Igor Sysoev 7e67ab9ba4 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 2af47be63f adopt NGX_FILE_TRUNCATE for win32 2009-04-08 19:03:41 +00:00
Igor Sysoev 0b33dc60c5 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 a701f1956d win32 ngx_open_file() supports utf8 names and NGX_FILE_APPEND 2009-03-30 14:51:51 +00:00
Igor Sysoev 12c14b31e3 small optimization: " == NGX_ERROR" > " != NGX_OK" 2009-02-24 10:42:23 +00:00
Igor Sysoev e2dc4550af a prelimiary IPv6 support, HTTP listen 2009-02-21 07:02:02 +00:00
Igor Sysoev 451b7b2fbc revert the previous commit and r2447 change in src/core/ngx_cycle.c 2009-01-26 14:31:49 +00:00
Igor Sysoev bab6e29561 default error_log has zero level, the bug has been introduced in r2447 2009-01-26 14:11:09 +00:00
Igor Sysoev a188821842 set the error level as default http error_log level 2009-01-16 14:00:05 +00:00
Igor Sysoev 96dfdc49a6 compatibility with glibc 2.3, warn_unused_result attribute for write() 2008-11-11 16:17:45 +00:00
Igor Sysoev 865600609c ngx_timezone_update() 2008-08-30 19:52:07 +00:00
Igor Sysoev bfe44ae438 -g switch 2008-06-30 12:35:16 +00:00
Igor Sysoev 0ebc285aa0 *) back out r2040
*) refactor ngx_palloc()
*) introduce ngx_pnalloc()
*) additional pool blocks have smaller header
2008-06-17 15:00:30 +00:00
Igor Sysoev 4b020d55bd $hostname variable 2008-05-16 14:39:06 +00:00