summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-03-30Version bump.Ruslan Ermilov1-2/+2
2016-03-29Win32: replaced NGX_EXDEV with more appropriate error code.Maxim Dounin1-5/+1
Correct error code for NGX_EXDEV on Windows is ERROR_NOT_SAME_DEVICE, "The system cannot move the file to a different disk drive". Previously used ERROR_WRONG_DISK is about wrong diskette in the drive and is not appropriate. There is no real difference though, as MoveFile() is able to copy files between disk drives, and will fail with ERROR_ACCESS_DENIED when asked to copy directories. The ERROR_NOT_SAME_DEVICE error is only used by MoveFileEx() when called without the MOVEFILE_COPY_ALLOWED flag.
2016-03-29Win32: additional error code NGX_EEXIST_FILE (ticket #910).Maxim Dounin3-3/+10
On Windows there are two possible error codes which correspond to the EEXIST error code: ERROR_FILE_EXISTS used by CreateFile(CREATE_NEW), and ERROR_ALREADY_EXISTS used by CreateDirectory(). MoveFile() seems to use both: ERROR_ALREADY_EXISTS when moving within one filesystem, and ERROR_FILE_EXISTS when copying a file to a different drive.
2016-03-28Upstream: proxy_next_upstream non_idempotent.Maxim Dounin6-1/+12
By default, requests with non-idempotent methods (POST, LOCK, PATCH) are no longer retried in case of errors if a request was already sent to a backend. Previous behaviour can be restored by using "proxy_next_upstream ... non_idempotent".
2016-03-28Upstream: cached connections now tested against next_upstream.Maxim Dounin1-49/+42
Much like normal connections, cached connections are now tested against u->conf->next_upstream, and u->state->status is now always set. This allows to disable additional tries even with upstream keepalive by using "proxy_next_upstream off".
2016-03-28Fixed --test-build-*.Ruslan Ermilov3-4/+5
Fixes various aspects of --test-build-devpoll, --test-build-eventport, and --test-build-epoll. In particular, if --test-build-devpoll was used on Linux, then "devpoll" event method would be preferred over "epoll". Also, wrong definitions of event macros were chosen.
2016-03-28Sub filter: fixed allocation alignment.Roman Arutyunyan1-4/+4
2016-02-26Core: allow strings without null-termination in ngx_parse_url().Piotr Sikora1-2/+4
This fixes buffer over-read while using variables in the "proxy_pass", "fastcgi_pass", "scgi_pass", and "uwsgi_pass" directives, where result of string evaluation isn't null-terminated. Found with MemorySanitizer. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-03-25Fixed socket inheritance on reload and binary upgrade.Roman Arutyunyan2-0/+20
On nginx reload or binary upgrade, an attempt is made to inherit listen sockets from the previous configuration. Previously, no check for socket type was made and the inherited socket could have the wrong type. On binary upgrade, socket type was not detected at all. Wrong socket type could lead to errors on that socket due to different logic and unsupported syscalls. For example, a UDP socket, inherited as TCP, lead to the following error after arrival of a datagram: "accept() failed (102: Operation not supported on socket)".
2016-03-18Stream: additional logging for UDP.Vladimir Homutov2-5/+10
2016-03-23Win32: fixed build after 384154fc634f.Dmitry Volyntsev1-3/+2
2016-03-23Stream: detect port absence in proxy_pass with IP literal.Roman Arutyunyan1-1/+1
This is a clone of http commit 26c127bab5ef.
2016-03-23Resolver: added support for SRV records.Dmitry Volyntsev3-27/+992
2016-03-23Resolver: do not enable resolve timer if provided timeout is zero.Dmitry Volyntsev1-20/+24
2016-03-23Resolver: introduced valid field in resolver responses.Dmitry Volyntsev2-0/+8
It hints the amount of time a response could be considered as valid.
2016-03-23Core: introduced the NGX_DEBUG_PALLOC macro.Valentin Bartenev1-0/+4
It allows to turn off accumulation of small pool allocations into a big preallocated chunk of memory. This is useful for debugging memory access with sanitizer, since such accumulation can cover buffer overruns from being detected.
2016-03-23Core: use ngx_palloc_small() to allocate ngx_pool_large_t.Valentin Bartenev1-2/+2
This structure cannot be allocated as a large block anyway, otherwise that will result in infinite recursion, since each large allocation requires to allocate another ngx_pool_large_t. The room for the structure is guaranteed by the NGX_MIN_POOL_SIZE constant.
2016-03-23Core: introduced the ngx_palloc_small() function.Valentin Bartenev1-33/+26
It deduplicates some code for allocations from memory pool. No functional changes.
2016-03-23Core: moved logging before freeing large blocks of pool.Valentin Bartenev1-9/+10
This fixes use-after-free memory access with enabled debug log when pool->log is allocated as a large block.
2016-03-22Backed out server_tokens changes.Maxim Dounin5-163/+45
Backed out changesets: cf3e75cfa951, 6b72414dfb4f, 602dc42035fe, e5076b96fd01.
2016-03-23Cache: fixed slots accounting error introduced in c9d680b00744.Dmitry Volyntsev1-2/+2
2016-03-22Reconsidered server_tokens with an empty value.Ruslan Ermilov3-20/+11
An empty value will be treated as "off".
2016-03-21HTTP/2: improved debugging of sending control frames.Valentin Bartenev1-2/+13
2016-03-21Events: fixed test building with devpoll and eventport on Linux.Sergey Kandaurov2-1/+3
Avoid POLLREMOVE and itimerspec redefinition.
2016-03-18Fix build with -Wmissing-prototypes.Piotr Sikora1-2/+2
Broken in 5eb4d7541107 (1.9.6), fix somehow missed in 3600bbfb43e3. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-03-18Cache: added watermark to reduce IO load when keys_zone is full.Dmitry Volyntsev2-5/+34
When a keys_zone is full then each next request to the cache is penalized. That is, the cache has to evict older files to get a slot from the keys_zone synchronously. The patch introduces new behavior in this scenario. Manager will try to maintain available free slots in the keys_zone by cleaning old files in the background.
2016-03-18Cache: report error if slab allocator fails during cache loading.Dmitry Volyntsev2-0/+8
2016-03-18Threads: writing via threads pools in event pipe.Maxim Dounin5-21/+214
The "aio_write" directive is introduced, which enables use of aio for writing. Currently it is meaningful only with "aio threads". Note that aio operations can be done by both event pipe and output chain, so proper mapping between r->aio and p->aio is provided when calling ngx_event_pipe() and in output filter. In collaboration with Valentin Bartenev.
2016-03-18Threads: offloading of temp files writing to thread pools.Maxim Dounin4-14/+164
The ngx_thread_write_chain_to_file() function introduced, which uses ngx_file_t thread_handler, thread_ctx and thread_task fields. The task context structure (ngx_thread_file_ctx_t) is the same for both reading and writing, and can be safely shared as long as operations are serialized. The task->handler field is now always set (and not only when task is allocated), as the same task can be used with different handlers. The thread_write flag is introduced in the ngx_temp_file_t structure to explicitly enable use of ngx_thread_write_chain_to_file() in ngx_write_chain_to_temp_file() when supported by caller. In collaboration with Valentin Bartenev.
2016-03-18Threads: task pointer stored in ngx_file_t.Maxim Dounin5-11/+18
This simplifies the interface of the ngx_thread_read() function. Additionally, most of the thread operations now explicitly set file->thread_task, file->thread_handler and file->thread_ctx, to facilitate use of thread operations in other places. (Potential problems remain with sendfile in threads though - it uses file->thread_handler as set in ngx_output_chain(), and it should not be overwritten to an incompatible one.) In collaboration with Valentin Bartenev.
2016-03-18Fixed timeouts with threaded sendfile() and subrequests.Maxim Dounin2-10/+14
If a write event happens after sendfile() but before we've got the sendfile results in the main thread, this write event will be ignored. And if no more events will happen, the connection will hang. Removing the events works in the simple cases, but not always, as in some cases events are added back by an unrelated code. E.g., the upstream module adds write event in the ngx_http_upstream_init() to track client aborts. Fix is to use wev->complete instead. It is now set to 0 before a sendfile() task is posted, and it is set to 1 once a write event happens. If on completion of the sendfile() task wev->complete is 1, we know that an event happened while we were executing sendfile(), and the socket is still ready for writing even if sendfile() did not sent all the data or returned EAGAIN.
2016-03-16Style.Ruslan Ermilov1-4/+4
2016-03-15Truncation detection in sendfilev() on Solaris.Maxim Dounin1-0/+23
While sendfilev() is documented to return -1 with EINVAL set if the file was truncated, at least Solaris 11 silently returns 0, and this results in CPU hog. Added a test to complain appropriately if 0 is returned.
2016-03-15Truncation detection in sendfile() on Linux.Maxim Dounin1-0/+26
This addresses connection hangs as observed in ticket #504, and CPU hogs with "aio threads; sendfile on" as reported in the mailing list, see http://mailman.nginx.org/pipermail/nginx-ru/2016-March/057638.html. The alert is identical to one used on FreeBSD.
2016-01-20Stream: UDP proxy.Roman Arutyunyan20-105/+726
2016-03-15Stream: post first read events from client and upstream.Roman Arutyunyan1-12/+10
The main proxy function ngx_stream_proxy_process() can terminate the stream session. The code, following it, should check its return code to make sure the session still exists. This happens in client and upstream initialization functions. Swapping ngx_stream_proxy_process() call with the code, that follows it, leaves the same problem vice versa. In future ngx_stream_proxy_process() will call ngx_stream_proxy_next_upstream() making it too complicated to know if stream session still exists after this call. Now ngx_stream_proxy_process() is called from posted event handlers in both places with no code following it. The posted event is automatically removed once session is terminated.
2016-03-15Win32: fixed build after cf3e75cfa951.Ruslan Ermilov1-0/+4
2016-03-15Win32: fixed build after cf3e75cfa951.Ruslan Ermilov1-0/+4
2016-03-15Added variables support to server_tokens.Ruslan Ermilov5-47/+166
It can now be set to "off" conditionally, e.g. using the map directive. An empty value will disable the emission of the Server: header and the signature in error messages generated by nginx. Any other value is treated as "on", meaning that full nginx version is emitted in the Server: header and error messages generated by nginx.
2016-03-14Fixed handling of EAGAIN with sendfile in threads.Valentin Bartenev1-1/+6
2016-03-15Events: fixed error logging in devpoll.Roman Arutyunyan1-1/+1
2016-03-14Fixed compilation with -Wmissing-prototypes.Sergey Kandaurov2-2/+2
2016-03-08Upstream: avoid closing client connection in edge case.Justin Li1-0/+5
If proxy_cache is enabled, and proxy_no_cache tests true, it was previously possible for the client connection to be closed after a 304. The fix is to recheck r->header_only after the final cacheability is determined, and end the request if no longer cacheable. Example configuration: proxy_cache foo; proxy_cache_bypass 1; proxy_no_cache 1; If a client sends If-None-Match, and the upstream server returns 200 with a matching ETag, no body should be returned to the client. At the start of ngx_http_upstream_send_response proxy_no_cache is not yet tested, thus cacheable is still 1 and downstream_error is set. However, by the time the downstream_error check is done in process_request, proxy_no_cache has been tested and cacheable is set to 0. The client connection is then closed, regardless of keepalive.
2016-03-10Upstream: fixed "zero size buf" alerts with cache (ticket #918).Maxim Dounin1-1/+2
If caching was used, "zero size buf in output" alerts might appear in logs if a client prematurely closed connection. Alerts appeared in the following situation: - writing to client returned an error, so event pipe drained all busy buffers leaving body output filters in an invalid state; - when upstream response was fully received, ngx_http_upstream_finalize_request() tried to flush all pending data. Fix is to avoid flushing body if p->downstream_error is set.
2016-03-03Copy filter: fixed sendfile aio handlers to set ctx->aio.Maxim Dounin2-5/+12
Sendfile handlers (aio preload and thread handler) are called within ctx->output_filter() in ngx_output_chain(), and hence ctx->aio cannot be set directly in ngx_output_chain(). Meanwhile, it must be set to make sure loop within ngx_output_chain() will be properly terminated. There are no known cases that trigger the problem, though in theory something like aio + sub filter (something that needs body in memory, and can also free some memory buffers) + sendfile can result in "task already active" and "second aio post" alerts. The fix is to set ctx->aio in ngx_http_copy_aio_sendfile_preload() and ngx_http_copy_thread_handler(). For consistency, ctx->aio is no longer set explicitly in ngx_output_chain_copy_buf(), as it's now done in ngx_http_copy_thread_handler().
2016-03-03Fixed sendfile in threads (or with aio preload) and subrequests.Maxim Dounin2-0/+24
If sendfile in threads is used, it is possible that multiple subrequests will trigger multiple ngx_linux_sendfile_thread() calls, as operations are only serialized in output chain based on r->aio, that is, on subrequest level. This resulted in "task #N already active" alerts, in particular, when running proxy_store.t with "aio threads; sendfile on;". Fix is to tolerate duplicate calls, with an additional safety check that the file is the same as previously used. The same problem also affects "aio on; sendfile on;" on FreeBSD (previously known as "aio sendfile;"), where aio->preload_handler() could be called multiple times due to similar reasons, resulting in "second aio post" alerts. Fix is the same as well. It is also believed that similar problems can arise if a filter calls the next body filter multiple times for some reason. These are mostly theoretical though.
2016-03-03Introduced the ngx_chain_to_iovec() function.Valentin Bartenev1-50/+60
It's similar to ngx_output_chain_to_iovec() and uses only preallocated memory.
2016-03-01Request body: moved handling of the last part in the save filter.Valentin Bartenev1-69/+40
No functional changes.
2016-02-25Dynamic modules: removed unnecessary initialization.Ruslan Ermilov1-1/+0
It became unnecessary after 85dea406e18f.
2016-02-25Version bump.Ruslan Ermilov1-2/+2