Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-05-31Core: disabled SO_REUSEADDR on UDP sockets while testing config.Maxim Dounin
On Linux, SO_REUSEADDR allows completely duplicate UDP sockets, so using SO_REUSEADDR when testing configuration results in packets being dropped if there is an existing traffic on the sockets being tested (ticket #2187). While dropped packets are expected with UDP, it is better to avoid this when possible. With this change, SO_REUSEADDR is no longer set on datagram sockets when testing configuration.
2021-02-11Additional connections reuse.Maxim Dounin
If ngx_drain_connections() fails to immediately reuse any connections and there are no free connections, it now additionally tries to reuse a connection again. This helps to provide at least one free connection in case of HTTP/2 with lingering close, where merely trying to reuse a connection once does not free it, but makes it reusable again, waiting for lingering close.
2020-08-10Core: reusing connections in advance.Maxim Dounin
Reworked connections reuse, so closing connections is attempted in advance, as long as number of free connections is less than 1/16 of worker connections configured. This ensures that new connections can be handled even if closing a reusable connection requires some time, for example, for a lingering close (ticket #2017). The 1/16 ratio is selected to be smaller than 1/8 used for disabling accept when working with accept mutex, so nginx will try to balance new connections to different workers first, and will start reusing connections only if this won't help.
2020-08-10Core: added a warning about reusing connections.Maxim Dounin
Previously, reusing connections happened silently and was only visible in monitoring systems. This was shown to be not very user-friendly, and administrators often didn't realize there were too few connections available to withstand the load, and configured timeouts (keepalive_timeout and http2_idle_timeout) were effectively reduced to keep things running. To provide at least some information about this, a warning is now logged (at most once per second, to avoid flooding the logs).
2020-06-01Fixed removing of listening UNIX sockets when "changing binary".Ruslan Ermilov
When changing binary, sending a SIGTERM to the new binary's master process should not remove inherited UNIX sockets unless the old binary's master process has exited.
2018-07-12Events: moved sockets cloning to ngx_event_init_conf().Maxim Dounin
Previously, listenings sockets were not cloned if the worker_processes directive was specified after "listen ... reuseport". This also simplifies upcoming configuration check on the number of worker connections, as it needs to know the number of listening sockets before cloning.
2018-07-02Added FreeBSD support for "listen ... reuseport".Ruslan Ermilov
2018-06-04Stream: udp streams.Roman Arutyunyan
Previously, only one client packet could be processed in a udp stream session even though multiple response packets were supported. Now multiple packets coming from the same client address and port are delivered to the same stream session. If it's required to maintain a single stream of data, nginx should be configured in a way that all packets from a client are delivered to the same worker. On Linux and DragonFly BSD the "reuseport" parameter should be specified for this. Other systems do not currently provide appropriate mechanisms. For these systems a single stream of udp packets is only guaranteed in single-worker configurations. The proxy_response directive now specifies how many packets are expected in response to a single client packet.
2018-05-21Core: silenced getsockopt(TCP_FASTOPEN) messages on FreeBSD.Maxim Dounin
FreeBSD returns EINVAL when getsockopt(TCP_FASTOPEN) is called on a unix domain socket, resulting in "getsockopt(TCP_FASTOPEN) ... failed" messages during binary upgrade when unix domain listen sockets are present in the configuration. Added EINVAL to the list of ignored error codes.
2017-10-04Fixed buffer overread with unix sockets after accept().Maxim Dounin
Some OSes (notably macOS, NetBSD, and Solaris) allow unix socket addresses larger than struct sockaddr_un. Moreover, some of them (macOS, Solaris) return socklen of the socket address before it was truncated to fit the buffer provided. As such, on these systems socklen must not be used without additional check that it is within the buffer provided. Appropriate checks added to ngx_event_accept() (after accept()), ngx_event_recvmsg() (after recvmsg()), and ngx_set_inherited_sockets() (after getsockname()). We also obtain socket addresses via getsockname() in ngx_connection_local_sockaddr(), but it does not need any checks as it is only used for INET and INET6 sockets (as there can be no wildcard unix sockets).
2017-07-11Core: fixed error message on setsockopt(SO_REUSEPORT) failure.Maxim Dounin
The error is fatal when configuring a new socket, so the ", ignored" part is not appropriate and was removed.
2017-07-11Core: disabled SO_REUSEPORT when testing config (ticket #1300).Maxim Dounin
When closing a socket with SO_REUSEPORT, Linux drops all connections waiting in this socket's listen queue. Previously, it was believed to only result in connection resets when reconfiguring nginx to use smaller number of worker processes. It also results in connection resets during configuration testing though. Workaround is to avoid using SO_REUSEPORT when testing configuration. It should prevent listening sockets from being created if a conflicting socket already exists, while still preserving detection of other possible errors. It should also cover UDP sockets. The only downside of this approach seems to be that a configuration testing won't be able to properly report the case when nginx was compiled with SO_REUSEPORT, but the kernel is not able to set it. Such errors will be reported on a real start instead.
2017-05-26Introduced ngx_tcp_nodelay().Ruslan Ermilov
2017-01-20Improved connection draining with small number of connections.Maxim Dounin
Closing up to 32 connections might be too aggressive if worker_connections is set to a comparable number (and/or there are only a small number of reusable connections). If an occasional connection shorage happens in such a configuration, it leads to closing all reusable connections instead of gradually reducing keepalive timeout to a smaller value. To improve granularity in such configurations we now close no more than 1/8 of all reusable connections at once. Suggested by Joel Cunningham.
2017-01-20Added cycle parameter to ngx_drain_connections().Maxim Dounin
No functional changes, mostly style.
2016-10-05Core: use c->log while closing connection.Ruslan Ermilov
c->pool is not destroyed here since c52408583801.
2016-05-23Introduced the ngx_sockaddr_t type.Ruslan Ermilov
It's properly aligned and can hold any supported sockaddr.
2016-05-20Belatedly changed the ngx_create_listening() prototype.Ruslan Ermilov
The function is called only with "struct sockaddr *" since 0.7.58.
2016-03-30Style.Ruslan Ermilov
2016-03-25Fixed socket inheritance on reload and binary upgrade.Roman Arutyunyan
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-01-20Stream: UDP proxy.Roman Arutyunyan
2015-10-17Win32: fixed build with MinGW and MinGW-w64 gcc.Kouhei Sutou
This change fixes the "comparison between signed and unsigned integer expressions" warning, introduced in 5e6142609e48 (1.9.4).
2015-08-11Core: idle connections now closed only once on exiting.Valentin Bartenev
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-07-23Workaround for "configuration file test failed" under OpenVZ.Gena Makhomed
If nginx was used under OpenVZ and a container with nginx was suspended and resumed, configuration tests started to fail because of EADDRINUSE returned from listen() instead of bind(): # nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) nginx: configuration file /etc/nginx/nginx.conf test failed With this change EADDRINUSE errors returned by listen() are handled similarly to errors returned by bind(), and configuration tests work fine in the same environment: # nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful More details about OpenVZ suspend/resume bug: https://bugzilla.openvz.org/show_bug.cgi?id=2470
2015-05-20The "reuseport" option of the "listen" directive.Maxim Dounin
When configured, an individual listen socket on a given address is created for each worker process. This allows to reduce in-kernel lock contention on configurations with high accept rates, resulting in better performance. As of now it works on Linux and DragonFly BSD. Note that on Linux incoming connection requests are currently tied up to a specific listen socket, and if some sockets are closed, connection requests will be reset, see https://lwn.net/Articles/542629/. With nginx, this may happen if the number of worker processes is reduced. There is no such problem on DragonFly BSD. Based on previous work by Sepherosa Ziehau and Yingqi Lu.
2015-04-23Removed the obsolete rtsig module.Ruslan Ermilov
2015-04-22Removed the obsolete aio module.Ruslan Ermilov
2015-03-23Removed stub implementation of win32 mutexes.Ruslan Ermilov
2015-03-20Removed ngx_connection_t.lock.Ruslan Ermilov
2015-03-04Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov
It's mostly dead code and the original idea of worker threads has been rejected.
2015-02-17Core: make ngx_connection_local_sockaddr() always assign address.Roman Arutyunyan
Previously, this function checked for connection local address existence and returned error if it was missing. Now a new address is assigned in this case making it possible to call this function not only for accepted connections.
2014-09-01Events: processing of posted events changed from LIFO to FIFO.Valentin Bartenev
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 Bartenev
It's mostly dead code. And the idea of thread support for this task has been deprecated.
2014-06-26Core: plugged socket leak during configuration test.Maxim Dounin
This isn't really important as configuration testing shortly ends with a process termination which will free all sockets, though Coverity complains. Prodded by Coverity (CID 400872).
2014-02-22Core: allocate enough memory to hold IPv6 text address plus port.Ruslan Ermilov
2014-02-04Use ngx_socket_errno where appropriate.Piotr Sikora
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-01-31Core: handle getsockopt(TCP_FASTOPEN) failures.Piotr Sikora
Linux returns EOPNOTSUPP for non-TCP sockets and ENOPROTOOPT for TCP sockets, because getsockopt(TCP_FASTOPEN) is not implemented so far. While there, lower the log level from ALERT to NOTICE to match other getsockopt() failures. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-01-28Fixed TCP_DEFER_ACCEPT handling (ticket #353).Maxim Dounin
Backed out 05a56ebb084a, as it turns out that kernel can return connections without any delay if syncookies are used. This basically means we can't assume anything about connections returned with deferred accept set. To solve original problem the 05a56ebb084a tried to solve, i.e. to don't wait longer than needed if a connection was accepted after deferred accept timeout, this patch changes a timeout set with setsockopt(TCP_DEFER_ACCEPT) to 1 second, unconditionally. This is believed to be enough for speed improvements, and doesn't imply major changes to timeouts used. Note that before 2.6.32 connections were dropped after a timeout. Though it is believed that 1s is still appropriate for kernels before 2.6.32, as previously tcp_synack_retries controlled the actual timeout and 1s results in more than 1 minute actual timeout by default.
2013-12-19Fixed the first argument to getsockopt().Ruslan Ermilov
While here, always initialize the last argument.
2013-12-09Fixed handling of UNIX-domain sockets.Ruslan Ermilov
When evaluating $local_port, $server_port, and $server_addr, UNIX-domain sockets were mistakenly interpreted as IPv4 sockets.
2013-12-09Core: keep the length of the local sockaddr.Ruslan Ermilov
2013-12-03Added support for TCP_FASTOPEN supported in Linux >= 3.7.1.Mathew Rodley
--- auto/unix | 12 ++++++++++++ src/core/ngx_connection.c | 32 ++++++++++++++++++++++++++++++++ src/core/ngx_connection.h | 4 ++++ src/http/ngx_http.c | 4 ++++ src/http/ngx_http_core_module.c | 21 +++++++++++++++++++++ src/http/ngx_http_core_module.h | 3 +++ 6 files changed, 76 insertions(+)
2013-10-31Core: handling of getsockopt(TCP_DEFER_ACCEPT) failures.Maxim Dounin
Recent Linux versions started to return EOPNOTSUPP to getsockopt() calls on unix sockets, resulting in log pollution on binary upgrade. Such errors are silently ignored now.
2013-09-04Win32: MinGW GCC compatibility.Maxim Dounin
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-07-25On DragonFlyBSD, TCP_KEEPIDLE and TCP_KEEPINTVL are in msecs.Ruslan Ermilov
Based on a patch by Sepherosa Ziehau.
2013-07-25Style: reuse one int variable in ngx_configure_listening_sockets().Ruslan Ermilov
No functional changes.
2013-07-11Core: fixed possible use of an uninitialized variable.Vladimir Homutov
The call to ngx_sock_ntop() in ngx_connection_local_sockaddr() might be performed with the uninitialized "len" variable. The fix is to initialize variable to the size of corresponding socket address type. The issue was introduced in commit 05ba5bce31e0.
2013-07-11Core: extended ngx_sock_ntop() with socklen parameter.Vladimir Homutov
On Linux, sockaddr length is required to process unix socket addresses properly due to unnamed sockets (which don't have sun_path set at all) and abstract namespace sockets.
2013-03-25Use NGX_FILE_ERROR for handling file operations errors.Valentin Bartenev
On Win32 platforms 0 is used to indicate errors in file operations, so comparing against -1 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-16Status: introduced the "ngx_stat_waiting" counter.Valentin Bartenev
And corresponding variable $connections_waiting was added. Previously, waiting connections were counted as the difference between active connections and the sum of reading and writing connections. That made it impossible to count more than one request in one connection as reading or writing (as is the case for SPDY). Also, we no longer count connections in handshake state as waiting.