summaryrefslogtreecommitdiffhomepage
path: root/src/event/modules (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-09-07Events: fixed style and wrong error handling in the iocp module.Maxim Dounin1-4/+3
2021-03-28Events: fixed "port_dissociate() failed" alerts with eventport.Maxim Dounin1-1/+1
If an attempt is made to delete an event which was already reported, port_dissociate() returns an error. Fix is avoid doing anything if ev->active is not set. Possible alternative approach would be to avoid calling ngx_del_event() at all if ev->active is not set. This approach, however, will require something else to re-add the other event of the connection, since both read and write events are dissociated if an event is reported on a file descriptor. Currently ngx_eventport_del_event() re-associates write event if called to delete read event, and vice versa.
2019-10-17Events: available bytes calculation via ioctl(FIONREAD).Maxim Dounin7-2/+7
This makes it possible to avoid looping for a long time while working with a fast enough peer when data are added to the socket buffer faster than we are able to read and process them (ticket #1431). This is basically what we already do on FreeBSD with kqueue, where information about the number of bytes in the socket buffer is returned by the kevent() call. With other event methods rev->available is now set to -1 when the socket is ready for reading. Later in ngx_recv() and ngx_recv_chain(), if full buffer is received, real number of bytes in the socket buffer is retrieved using ioctl(FIONREAD). Reading more than this number of bytes ensures that even with edge-triggered event methods the event will be triggered again, so it is safe to stop processing of the socket and switch to other connections. Using ioctl(FIONREAD) only after reading a full buffer is an optimization. With this approach we only call ioctl(FIONREAD) when there are at least two recv()/readv() calls.
2019-01-28Removed --test-build-eventport workaround for old FreeBSD versions.Sergey Kandaurov1-2/+0
2019-01-24Win32: detection of connect() errors in select().Maxim Dounin1-4/+13
On Windows, connect() errors are only reported via exceptfds descriptor set from select(). Previously exceptfds was set to NULL, and connect() errors were not detected at all, so connects to closed ports were waiting till a timeout occurred. Since ongoing connect() means that there will be a write event active, except descriptor set is copied from the write one. While it is possible to construct except descriptor set as a concatenation of both read and write descriptor sets, this looks unneeded. With this change, connect() errors are properly detected now when using select(). Note well that it is not possible to detect connect() errors with WSAPoll() (see https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/).
2019-01-24Win32: added WSAPoll() support.Maxim Dounin1-0/+435
WSAPoll() is only available with Windows Vista and newer (and only available during compilation if _WIN32_WINNT >= 0x0600). To make sure the code works with Windows XP, we do not redefine _WIN32_WINNT, but instead load WSAPoll() dynamically if it is not available during compilation. Also, sockets are not guaranteed to be small integers on Windows. So an index array is used instead of NGX_USE_FD_EVENT to map events to connections.
2019-01-24Events: fixed copying of old events in poll init.Maxim Dounin1-1/+1
Previously, the code incorrectly assumed "ngx_event_t *" elements instead of "struct pollfd". This is mostly cosmetic change, as this code is never called now.
2018-01-16Fixed --test-build-eventport on macOS 10.12 and later.Ruslan Ermilov1-0/+2
In macOS 10.12, CLOCK_REALTIME and clockid_t were added, but not timer_t.
2017-03-06Added missing "static" specifiers found by gcc -Wtraditional.Ruslan Ermilov2-2/+2
2017-03-02Added missing static specifiers.Eran Kornblau8-11/+11
2016-11-21Events: improved error event handling for UDP sockets.Dmitry Volyntsev4-30/+19
Normally, the epoll module calls the read and write handlers depending on whether EPOLLIN and EPOLLOUT are reported by epoll_wait(). No error processing is done in the module, the handlers are expected to get an error when doing I/O. If an error event is reported without EPOLLIN and EPOLLOUT, the module set both EPOLLIN and EPOLLOUT to ensure the error event is handled at least in one active handler. This works well unless the error is delivered along with only one of EPOLLIN or EPOLLOUT, and the corresponding handler does not do any I/O. For example, it happened when getting EPOLLERR|EPOLLOUT from epoll_wait() upon receiving "ICMP port unreachable" while proxying UDP. As the write handler had nothing to send it was not able to detect and log an error, and did not switch to the next upstream. The fix is to unconditionally set EPOLLIN and EPOLLOUT in case of an error event. In the aforementioned case, this causes the read handler to be called which does recv() and detects an error. In addition to the epoll module, analogous changes were made in devpoll/eventport/poll.
2016-09-15Stream: filters.Roman Arutyunyan1-0/+2
2016-07-15Events: support for EPOLLEXCLUSIVE.Valentin Bartenev1-0/+7
This flag appeared in Linux 4.5 and is useful for avoiding thundering herd problem. The current Linux kernel implementation walks the list of exclusive waiters, and queues an event to each epfd, until it finds the first waiter that has threads blocked on it via epoll_wait().
2016-07-15Style: sorted epoll flags.Valentin Bartenev1-3/+3
2016-05-18Events: close descriptors on errors in ngx_epoll_test_rdhup().Maxim Dounin1-5/+18
2016-05-18Events: changed ngx_epoll_test_rdhup() to use existing epollfd.Maxim Dounin1-12/+3
2016-05-18Fixed work with --test-build-epoll after f7849bfb6d21.Maxim Dounin1-66/+70
2016-05-16Fixed an error log message about epoll_wait() timeout.Valentin Bartenev1-2/+2
The errno value is unset in case of epoll_wait() timeout.
2016-05-13Improved EPOLLRDHUP handling.Valentin Bartenev1-1/+71
When it's known that the kernel supports EPOLLRDHUP, there is no need in additional recv() call to get EOF or error when the flag is absent in the event generated by the kernel. A special runtime test is done at startup to detect if EPOLLRDHUP is actually supported by the kernel because epoll_ctl() silently ignores unknown flags. With this knowledge it's now possible to drop the "ready" flag for partial read. Previously, the "ready" flag was kept until the recv() returned EOF or error. In particular, this change allows the lingering close heuristics (which relies on the "ready" flag state) to actually work on Linux, and not wait for more data in most cases. The "available" flag is now used in the read event with the semantics similar to the corresponding counter in kqueue.
2016-04-08Removed redundant "u" format specifier.Ruslan Ermilov1-1/+1
It is implied for "x" and "X".
2016-03-31Fixed logging.Sergey Kandaurov1-1/+1
2016-03-31Events: fixed logging.Sergey Kandaurov2-12/+19
2016-03-30Events: fixed test building with eventport on OS X.Ruslan Ermilov1-1/+1
Broken in d17f0584006f (1.9.13).
2016-03-30Style.Ruslan Ermilov1-22/+22
2016-03-21Events: fixed test building with devpoll and eventport on Linux.Sergey Kandaurov2-1/+3
Avoid POLLREMOVE and itimerspec redefinition.
2016-03-18Fixed timeouts with threaded sendfile() and subrequests.Maxim Dounin1-0/+3
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-15Events: fixed error logging in devpoll.Roman Arutyunyan1-1/+1
2015-05-06Events: made a failure to create a notification channel non-fatal.Ruslan Ermilov1-1/+1
This may happen if eventfd() returns ENOSYS, notably seen on CentOS 5.4. Such a failure will now just disable the notification mechanism and let the callers cope with it, instead of failing to start worker processes. If thread pools are not configured, this can safely be ignored.
2015-04-23Removed the obsolete rtsig module.Ruslan Ermilov1-735/+0
2015-04-22Removed the obsolete aio module.Ruslan Ermilov2-172/+1
2015-03-26Removed NGX_OLD_THREADS from select and poll modules.Ruslan Ermilov2-20/+0
These modules can't be compiled on win32.
2015-03-27Events: fixed possible crash on start or reload.Valentin Bartenev1-2/+2
The main thread could wake up and start processing the notify event before the handler was set.
2015-03-20Removed unix ngx_threaded and related ngx_process_changes.Ruslan Ermilov10-95/+9
2015-03-20Removed old pthread implementation.Ruslan Ermilov1-50/+0
2015-03-14Events: implemented eventport notification mechanism.Ruslan Ermilov1-1/+34
2015-03-14Events: implemented kqueue notification mechanism.Valentin Bartenev1-0/+76
2015-03-14Events: implemented epoll notification mechanism.Valentin Bartenev1-2/+139
2015-03-14Thread pools implementation.Valentin Bartenev10-0/+10
2015-03-04Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov3-5/+5
It's mostly dead code and the original idea of worker threads has been rejected.
2015-03-12Events: fixed typo in the error message.Ruslan Ermilov1-1/+1
2014-10-11Win32: fixed wrong type cast.Kouhei Sutou1-1/+1
GetQueuedCompletionStatus() document on MSDN says the following signature: http://msdn.microsoft.com/en-us/library/windows/desktop/aa364986.aspx BOOL WINAPI GetQueuedCompletionStatus( _In_ HANDLE CompletionPort, _Out_ LPDWORD lpNumberOfBytes, _Out_ PULONG_PTR lpCompletionKey, _Out_ LPOVERLAPPED *lpOverlapped, _In_ DWORD dwMilliseconds ); In the latest specification, the type of the third argument (lpCompletionKey) is PULONG_PTR not LPDWORD.
2014-09-01Events: processing of posted events changed from LIFO to FIFO.Valentin Bartenev8-9/+18
In theory, this can provide a bit better distribution of latencies. Also it simplifies the code, since ngx_queue_t is now used instead of custom implementation.
2014-09-01Events: removed broken thread support from posted events.Valentin Bartenev8-148/+47
It's mostly dead code. And the idea of thread support for this task has been deprecated.
2014-08-10Events: removed unused variable in ngx_poll_process_events().Maxim Dounin1-4/+1
2014-08-07Events: format specifier fixes.Yves Crespin2-6/+6
2014-08-07Events: changed nevents type to unsigned in poll module.Yves Crespin1-6/+6
2014-05-23Events: use eventfd() instead of syscall(SYS_eventfd) if possible.Ruslan Ermilov1-4/+4
This fixes --with-file-aio support on systems that lack eventfd() syscall, notably aarch64 Linux. The syscall(SYS_eventfd) may still be necessary on systems that have eventfd() syscall in the kernel but lack it in glibc, e.g. as seen in the current CentOS 5 release.
2013-07-12Events: support for EPOLLRDHUP (ticket #320).Valentin Bartenev1-5/+13
Since Linux 2.6.17, epoll is able to report about peer half-closed connection using special EPOLLRDHUP flag on a read event.
2013-09-04Win32: MinGW GCC compatibility.Maxim Dounin2-3/+3
Several warnings silenced, notably (ngx_socket_t) -1 is now checked on socket operations instead of -1, as ngx_socket_t is unsigned on win32 and gcc complains on comparison. With this patch, it's now possible to compile nginx using mingw gcc, with options we normally compile on win32.
2013-09-02Added the NGX_EBADF define.Valentin Bartenev1-1/+1