summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2016-03-31Fixed ngx_os_signal_process() prototype.Ruslan Ermilov2-3/+3
2016-03-31Fixed ngx_pid_t formatting in ngx_sprintf() and logging.Sergey Kandaurov1-1/+1
2016-03-31Fixed logging.Sergey Kandaurov9-15/+15
2016-03-30Style.Ruslan Ermilov4-20/+20
2016-03-29Win32: additional error code NGX_EEXIST_FILE (ticket #910).Maxim Dounin1-0/+1
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-28Fixed --test-build-*.Ruslan Ermilov1-1/+1
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-18Threads: offloading of temp files writing to thread pools.Maxim Dounin2-14/+154
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 Dounin2-6/+6
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 Dounin1-10/+11
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-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 Arutyunyan7-0/+63
2016-03-14Fixed handling of EAGAIN with sendfile in threads.Valentin Bartenev1-1/+6
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-02-18Core: added support for more than 64 CPUs in worker_cpu_affinity.Vladimir Homutov3-32/+30
2016-02-04Dynamic modules: dlopen() support.Maxim Dounin7-0/+72
2016-02-04Dynamic modules: changed ngx_modules to cycle->modules.Maxim Dounin1-15/+15
2015-12-02Core: fix typo in error message.Piotr Sikora1-1/+1
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-11-17Used the pwritev() syscall for writing files where possible.Valentin Bartenev1-3/+35
It is more effective, because it doesn't require a separate lseek().
2015-11-17Moved file writev() handling code to a separate function.Valentin Bartenev1-32/+51
No functional changes.
2015-11-17Handled EINTR from write() and pwrite() syscalls.Valentin Bartenev1-3/+20
This is in addition to 6fce16b1fc10.
2015-11-17Adjusted file->sys_offset after the write() syscall.Valentin Bartenev1-0/+1
This fixes suboptimal behavior caused by surplus lseek() for sequential writes on systems without pwrite(). A consecutive read after write might result in an error on systems without pread() and pwrite(). Fortunately, at the moment there are no widely used systems without these syscalls.
2015-09-02Fixed building --with-debug, broken by 6fce16b1fc10.Valentin Bartenev1-1/+1
2015-09-02Writing to some file systems can be interrupted.Valentin Bartenev1-1/+12
At least such behavior was observed with CephFS, see: http://mailman.nginx.org/pipermail/nginx/2015-July/048188.html.
2015-08-11Core: idle connections now closed only once on exiting.Valentin Bartenev1-17/+2
Iterating through all connections takes a lot of CPU time, especially with large number of worker connections configured. As a result nginx processes used to consume CPU time during graceful shutdown. To mitigate this we now only do a full scan for idle connections when shutdown signal is received. Transitions of connections to idle ones are now expected to be avoided if the ngx_exiting flag is set. The upstream keepalive module was modified to follow this.
2015-06-16Core: added support for writing to stdout.Vladimir Homutov1-0/+1
2015-05-25Configure: GNU Hurd properly recognized.Maxim Dounin1-0/+8
With this change it's no longer needed to pass -D_GNU_SOURCE manually, and -D_FILE_OFFSET_BITS=64 is set to use 64-bit off_t. Note that nginx currently fails to work properly with master process enabled on GNU Hurd, as fcntl(F_SETOWN) returns EOPNOTSUPP for sockets as of GNU Hurd 0.6. Additionally, our strerror() preloading doesn't work well with GNU Hurd, as it uses large numbers for most errors.
2015-05-20Introduced worker number, ngx_worker.Maxim Dounin2-0/+3
2015-04-23Removed the "worker_rlimit_sigpending" directive.Ruslan Ermilov1-13/+0
It was only needed by the just removed rtsig module.
2015-04-23Removed the obsolete rtsig module.Ruslan Ermilov3-41/+0
2015-04-22Removed the obsolete aio module.Ruslan Ermilov6-405/+1
2015-04-06Used the correct type for the AIO preload handler return value.Valentin Bartenev1-2/+2
2015-03-20Removed busy locks.Ruslan Ermilov1-3/+0
2015-03-20Removed unix ngx_threaded and related ngx_process_changes.Ruslan Ermilov2-2/+0
2015-03-20Removed old pthread implementation.Ruslan Ermilov4-584/+0
2015-03-20Removed old FreeBSD rfork() thread implementation.Ruslan Ermilov5-965/+0
2015-03-14Added support for offloading Linux sendfile() in thread pools.Valentin Bartenev1-8/+183
2015-03-14Added support for offloading read() in thread pools.Valentin Bartenev2-0/+114
2015-03-14Thread pools implementation.Valentin Bartenev5-1/+384
2015-03-04Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov3-11/+11
It's mostly dead code and the original idea of worker threads has been rejected.
2015-02-27Refactored ngx_linux_sendfile_chain() even more.Valentin Bartenev1-46/+60
The code that calls sendfile() was cut into a separate function. This simplifies EINTR processing, yet is needed for the following changes that add threads support.
2015-02-11Refactored sendfile() AIO preload.Valentin Bartenev4-47/+112
This reduces layering violation and simplifies the logic of AIO preread, since it's now triggered by the send chain function itself without falling back to the copy filter. The context of AIO operation is now stored per file buffer, which makes it possible to properly handle cases when multiple buffers come from different locations, each with its own configuration.
2015-01-13Fixed sendfile() trailers on OS X (8e903522c17a, 1.7.8).Maxim Dounin1-0/+3
The trailer.count variable was not initialized if there was a header, resulting in "sendfile() failed (22: Invalid argument)" alerts on OS X if the "sendfile" directive was used. The bug was introduced in 8e903522c17a (1.7.8).
2014-12-24Fixed building with musl libc (ticket #685).Maxim Dounin1-0/+2
2014-11-19Style.Valentin Bartenev1-2/+2
2014-11-19Fixed type of sendfile() return value on Linux.Valentin Bartenev1-6/+6
There was no real problem since the amount of bytes can be sent is limited by NGX_SENDFILE_MAXSIZE to less than 2G. But that can be changed in the future
2014-08-13Moved writev() handling code to a separate function.Valentin Bartenev5-102/+60
This reduces code duplication and unifies debug logging of the writev() syscall among various send chain functions.
2014-08-13Merged conditions in the ngx_*_sendfile_chain() functions.Valentin Bartenev3-27/+10
No functional changes.
2014-08-13Moved the code for coalescing file buffers to a separate function.Valentin Bartenev3-72/+9