Commit Graph
100 Commits
Author SHA1 Message Date
Valentin Bartenev 806a9b2515 Added tag 1.21.0 for changeset f804aaf7eee1 2020-11-19 21:13:19 +03:00
Valentin Bartenev 9e85732e9a Generated Dockerfiles for Unit 1.21.0. 2020-11-19 21:12:30 +03:00
Valentin Bartenev fa1a3298ef Added version 1.21.0 CHANGES. 2020-11-19 19:59:18 +03:00
Valentin Bartenev fb80502513 HTTP parser: allowed more characters in header field names.
Previously, all requests that contained in header field names characters other
than alphanumeric, or "-", or "_" were rejected with a 400 "Bad Request" error
response.

Now, the parser allows the same set of characters as specified in RFC 7230,
including: "!", "#", "$", "%", "&", "'", "*", "+", ".", "^", "`", "|", and "~".
Header field names that contain only these characters are considered valid.

Also, there's a new option introduced: "discard_unsafe_fields".  It accepts
boolean value and it is set to "true" by default.

When this option is "true", all header field names that contain characters
in valid range, but other than alphanumeric or "-" are skipped during parsing.
When the option is "false", these header fields aren't skipped.

Requests with non-valid characters in header field names according to
RFC 7230 are rejected regardless of "discard_unsafe_fields" setting.

This closes #422 issue on GitHub.
2020-11-17 16:50:06 +03:00
Valentin Bartenev e30db59168 PHP: implementation of the fastcgi_finish_request() function.
This closes #219 issue on GitHub.
2020-11-11 12:09:54 +03:00
Valentin Bartenev cb28b41311 PHP: prevention of consuming unread request body on finalization.
The php_request_shutdown() function calls sapi_deactivate() that tries to read
request body into a dummy buffer.  In our case it's just waste of CPU cycles.

This change is also required for the following implementation of the
fastcgi_finish_request() function, where the request context can be
cleared by the time of finalization.
2020-11-11 12:09:49 +03:00
Valentin Bartenev d03b217f33 Fixed building test app without debug.
Compilers complained about unused variables after 37e2a3ea1bf1.
2020-11-01 13:22:11 +03:00
Valentin Bartenev 50af47fd7c Isolation: fixed passing custom options to nmount().
The "iov" array was filled incorrectly when custom mounting options were set.
2020-10-30 07:55:26 +03:00
Valentin Bartenev 434c3228d9 Increased request memory pool size.
Previous value was too small, which reduced efficiency of the pool causing
a lot of additional allocations even for simple request and response.
2020-10-26 22:26:02 +03:00
Valentin Bartenev 84136eb49d Configure: using comma instead of space for passing -rpath value.
This variant will be more interoperable across various systems
and it's already used in Ruby module.

Otherwise, configure tests fail on NetBSD with:

  gcc: Missing argument for -Wl,-rpath
2020-10-26 22:24:32 +03:00
Valentin Bartenev 0919166145 Fixed building with Python 3.9.
PyUnicode_GET_SIZE() in deprecated since 3.3 and will be removed in 3.12.
In version 3.9 it was explicitly marked by deprecation warning causing
compilation error with Unit.

PyUnicode_GET_LENGTH() must be used instead.
2020-10-13 01:37:39 +03:00
Valentin Bartenev c4f2a58aaf Version bump. 2020-10-13 01:37:39 +03:00
Valentin Bartenev ad516735a6 Adjusted tag 1.20.0 to include 0e985b300673. 2020-10-08 19:09:16 +03:00
Valentin Bartenev 7d77d50568 Updated 1.20.0 CHANGES to include pytest migration. 2020-10-08 19:04:40 +03:00
Valentin Bartenev 10468ed22b Added tag 1.20.0 for changeset f7e9cf490512 2020-10-08 18:55:50 +03:00
Valentin Bartenev 03d965b49c Generated Dockerfiles for Unit 1.20.0. 2020-10-08 18:32:48 +03:00
Valentin Bartenev f221ddbe66 Added version 1.20.0 CHANGES. 2020-10-08 18:32:36 +03:00
Valentin Bartenev 2821b3347c PHP: compatibility with 8.0.0 RC1.
This closes #474 PR on GitHub.
2020-10-06 18:12:05 +03:00
Valentin Bartenev 645683f432 Tests: fixed loading selected module version.
Previously, for PHP, Ruby, and Perl the latest version was always loaded
in multi-version tests.
2020-10-07 22:04:54 +03:00
Valentin Bartenev 3f513f434f Router: fixed "not empty" pattern matching.
The "!" pattern should be opposite to "", i.e. match only non-empty values.
But after 3c00af54b937 it was equal to "!*", which is wrong.
2020-10-07 20:06:30 +03:00
Valentin Bartenev 67d33fac66 MIME: added AVIF and APNG image formats.
AVIF is a modern image format based on the AV1 video codec.  It generally has
better compression than other widely used formats (WebP, JPEG, PNG, and GIF)
and is designed to supersede them.  Support was already added to the latest
version of Chrome.

APNG extends PNG to permit animated images that work similarly to animated GIF.
It's supported by most modern browsers.

Also removed duplicated ".svg" entry.
2020-09-29 23:23:32 +03:00
Valentin Bartenev 70c2a4645e Vars: added $host.
This closes #407 issue on GitHub.
2020-08-28 19:34:49 +03:00
Valentin Bartenev dcfa92c161 Configuration: removed "reschedule_timeout" option.
It's not used since cbcd76704c90.

This option is a leftover from previous IPC between router and applications
processes.  It was never documented, though.

Thanks to 洪志道 (Hong Zhi Dao).
2020-08-21 20:50:04 +03:00
Valentin Bartenev 9bf6efc55a Configuration: improved error message of invalid listener address.
Thanks to 洪志道 (Hong Zhi Dao).
This closes #466 issue on GitHub.
2020-08-19 15:36:57 +03:00
Valentin Bartenev a13018fecb Version bump. 2020-08-17 11:57:55 +03:00
Valentin Bartenev 6473d4b65a Added tag 1.19.0 for changeset 86cdf66f8274 2020-08-13 19:22:57 +03:00
Valentin Bartenev ba445d31f1 Generated Dockerfiles for Unit 1.19.0. 2020-08-13 19:22:41 +03:00
Valentin Bartenev b8c7bc5a47 Added version 1.19.0 CHANGES. 2020-08-13 19:22:41 +03:00
Valentin Bartenev a58f224e26 Fixed typo in return value check.
Found by Coverity (CID 361277).
2020-08-13 03:45:54 +03:00
Valentin Bartenev 93146616cf Basic variables support. 2020-08-13 02:46:54 +03:00
Valentin Bartenev 91280b4c0b Ruby: fixed gem mount paths.
The gem paths must depend on the specified interpreter.
Also, gemdir looks redundant as it's already included in Gem.default_path().
2020-08-09 01:00:44 +03:00
Valentin Bartenev 317fabc83e Ruby: simplified commands in ./configure script.
There is no reason to use printf instead of just print.

No functional changes.
2020-08-09 01:00:44 +03:00
Valentin Bartenev 7e1d800f08 Ruby: removed unused variable from ./configure script. 2020-08-09 01:00:44 +03:00
Valentin Bartenev 0d7a6885a3 Configure: verifying the Ruby library path.
An attempt to build a Ruby module for a custom Ruby installation that has the
same major version as the system Ruby may unexpectedly cause the use of the
system Ruby library.

This closes #449 issue on GitHub.
2020-08-08 23:52:31 +03:00
Valentin Bartenev b0ff245ca8 Improved mkstemp() error reporting.
The invocation parameters should be logged as well, notably the path of the file
that is failed to be created.

Also, log level changed to ALERT as it's quite critical error.
2020-08-05 16:11:20 +03:00
Valentin Bartenev 2b53c7bbbd Fixed nxt_conn_accept_alloc() behavior in low memory conditions.
Earlier, if nxt_mp_create() failed to allocate memory while accepting a new
connection, the resulting NULL was subsequently passed to nxt_mp_destroy(),
crashing the process.

More, if nxt_mp_create() was successful but nxt_sockaddr_cache_alloc() failed,
the connection object wasn't destroyed properly, leaving the connection counter
in an inconsistent state.  Repeated, this condition lowered the connection
capacity of the process and could eventually prevent it from accepting
connections altogether.
2020-08-05 14:55:34 +03:00
Valentin Bartenev 10f90f0d48 Configuration: added checking for presence of mandatory fields. 2020-07-24 20:25:20 +03:00
Valentin Bartenev 2a71a8a9f4 Added missing ending indicator in object members validation lists.
This fixes undefined behaviour due to array over-read if an unknown parameter
is specified in an uidmap, a gidmap, or a php target object.
2020-07-24 20:25:15 +03:00
Valentin Bartenev d86e0a7aec PHP: logging in request context when possible. 2020-07-21 20:27:37 +03:00
Valentin Bartenev f46ef1b121 PHP: fixed incorrect time in interpreter error log messages.
Previously, the log message callback used a generic log function, that relied on the process time cache.
Since there were no time update calls in the application processes, all log lines were printed with the
same time, usually correlated with the process start.

Now, a non-cached logging function from libunit is used.
2020-07-21 20:27:37 +03:00
Valentin Bartenev f69d470752 Fixed non-debug log time format in libunit.
This makes log format used in libunit consistent with the daemon, where milliseconds are printed only in the
debug log level.

Currently a compile time switch is used, since there's no support for runtime changing of a log level for now.
But in the future this should be a runtime condition, similar to nxt_log_time_handler().
2020-07-21 20:27:37 +03:00
Valentin Bartenev 5fa3108e63 Version bump. 2020-06-08 16:09:07 +03:00
Valentin Bartenev 829bf07c7c Adjusted tag 1.18.0 to include 9e14c63773be. 2020-05-28 19:32:52 +03:00
Valentin Bartenev 9d8e476c4e Added tag 1.18.0 for changeset a34bc498d976 2020-05-28 18:04:47 +03:00
Valentin Bartenev ebf86b34d1 Generated Dockerfiles for Unit 1.18.0. 2020-05-28 17:34:06 +03:00
Valentin Bartenev 943865fc77 Added version 1.18.0 CHANGES. 2020-05-28 17:34:06 +03:00
Valentin Bartenev b2e6ef7beb Static: fixed potential undefined behavior in memcpy().
According to the C standard, pointer arguments passed to memcpy() calls shall
still have valid values.  NULL is considered as invalid.

Found with GCC Static Analyzer.
2020-05-20 11:18:03 +03:00
Valentin Bartenev d0de6df839 Fixed global constant declaration (appeared in 9af10e099d09).
This fixes building with GCC 10, which is default to -fno-common.
See: https://gcc.gnu.org/gcc-10/porting_to.html
2020-05-15 21:32:07 +03:00
Valentin Bartenev 79f5e531fe Router: removed two unused assignments.
This should resolve some static analyzers warnings.
2020-05-15 17:08:37 +03:00
Valentin Bartenev 376d758dd7 PHP: implemented "targets" option.
This allows to specify multiple subsequent targets inside PHP applications.
For example:

  {
      "listeners": {
          "*:80": {
              "pass": "routes"
          }
      },

      "routes": [
          {
              "match": {
                  "uri": "/info"
              },

              "action": {
                  "pass": "applications/my_app/phpinfo"
              }
          },
          {
              "match": {
                  "uri": "/hello"
              },

              "action": {
                  "pass": "applications/my_app/hello"
              }
          },
          {
              "action": {
                  "pass": "applications/my_app/rest"
              }
          }
      ],

      "applications": {
          "my_app": {
              "type": "php",
              "targets": {
                  "phpinfo": {
                      "script": "phpinfo.php",
                      "root": "/www/data/admin",
                  },

                  "hello": {
                      "script": "hello.php",
                      "root": "/www/data/test",
                  },

                  "rest": {
                      "root": "/www/data/example.com",
                      "index": "index.php"
                  },
              }
          }
      }
  }
2020-05-14 13:15:01 +03:00
Valentin Bartenev 0174c971b5 Configuration: URI encoding in the "pass" option.
This is useful to escape "/" in path fragments.  For example, in order
to reference the application named "foo/bar":

  {
      "pass": "applications/foo%2Fbar"
  }
2020-05-14 13:15:00 +03:00
Valentin Bartenev f291f24938 Version bump. 2020-05-12 11:15:03 +03:00
Valentin Bartenev 9877087756 Added tag 1.17.0 for changeset 4b13438632bc 2020-04-16 18:21:09 +03:00
Valentin Bartenev 4d62989f5c Generated Dockerfiles for Unit 1.17.0. 2020-04-16 17:49:09 +03:00
Valentin Bartenev e377820b6c Added version 1.17.0 CHANGES. 2020-04-16 17:49:09 +03:00
Valentin Bartenev c7f5c1c664 Controller: improved handling of unix domain control socket.
One of the ways to detect Unit's startup and subsequent readiness to accept
commands relies on waiting for the control socket file to be created.
Earlier, it was unreliable due to a race condition between the client's
connect() and the daemon's listen() calls after the socket's bind() call.

Now, unix domain listening sockets are created with a nxt_listen_socket_create()
call as follows:

   s = socket();
   unlink("path/to/socket.tmp")
   bind(s, "path/to/socket.tmp");
   listen(s);
   rename("path/to/socket.tmp", "path/to/socket");

This eliminates a time-lapse when the socket file is already created but nobody
is listening on it yet, which therefore prevents the condition described above.

Also, it allows reliably detecting whether the socket is being used or simply
wasn't cleaned after the daemon stopped abruptly.  A successful connection to
the socket file means the daemon has been started; otherwise, the file can be
overwritten.
2020-04-08 15:15:24 +03:00
Valentin Bartenev a6d9efcee1 Controller: fixed cleaning up of control socket file in some cases.
Previously, the unix domain control socket file might have been left
in the file system after a failed nxt_listen_socket_create() call.
2020-04-08 15:15:24 +03:00
Valentin Bartenev 555d595f38 Removed unused code related to testing of address binding. 2020-04-08 15:15:24 +03:00
Valentin Bartenev 27c1e26856 Controller: eliminated extra control socket's sockaddr copying. 2020-04-08 15:15:24 +03:00
Valentin Bartenev be943c9fd4 Fixed build with Clang 10, broken by 32578e837322.
This silences the -Wimplicit-int-float-conversion warning.
2020-04-01 18:33:48 +03:00
Valentin Bartenev 68c6b67ffc Configuration: support for rational numbers. 2020-03-30 19:37:58 +03:00
Valentin Bartenev c63b498f94 Implemented "location" option for "return" action.
This allows to specify redirects:

  {
      "action": {
          "return": 301,
          "location": "https://www.example.com/"
      }
  }
2020-03-21 01:39:00 +03:00
Valentin Bartenev 35d6f84426 Added nxt_is_complex_uri_encoded()/nxt_encode_complex_uri(). 2020-03-27 17:22:52 +03:00
Valentin Bartenev d4b4cb0438 Updated URI escaping table for better conformity with RFC 3986.
Now '>', '<', '"', '^', '\', '}', '|', '{', and '`' are also escaped.
2020-03-27 17:22:52 +03:00
Valentin Bartenev 8d727774e3 Implemented "return" action.
The "return" action can be used to immediately generate a simple HTTP response
with an arbitrary status:

  {
      "action": {
          "return": 404
      }
  }

This is especially useful for denying access to specific resources.
2020-03-27 17:22:52 +03:00
Valentin Bartenev 5f9c4754cb Initialization of the action object made more consistent. 2020-03-27 17:22:52 +03:00
Valentin Bartenev fd8e524b82 Configuration: fixed comments parsing.
Unclosed multi-line comments and "/" at the end of JSON shouldn't be allowed.
2020-03-25 19:14:15 +03:00
Valentin Bartenev b7f0e09de0 Version bump. 2020-03-16 13:27:10 +03:00
Valentin Bartenev b3c8a7b33a Added tag 1.16.0 for changeset 8bab088952dd 2020-03-12 18:35:33 +03:00
Valentin Bartenev 8f397c8ae5 Generated Dockerfiles for Unit 1.16.0. 2020-03-12 18:13:08 +03:00
Valentin Bartenev f6d53f69b8 Added version 1.16.0 CHANGES. 2020-03-12 18:13:07 +03:00
Valentin Bartenev 810b8dbb67 Tests: unitd stderr output redirected to unit.log.
A part of the debug log was printed to stderr before the log file was opened.
Now, this output is redirected to the same log file.
2020-03-06 20:08:38 +03:00
Valentin Bartenev 3617d4ed03 Tests: simplified unitd process running.
There are no reasons to wrap the Unit daemon in a separate Python process.
2020-03-06 20:08:29 +03:00
Valentin Bartenev afa2f86ecf PHP: added ZTS indication to ./configure output. 2020-03-04 15:24:27 +03:00
Valentin Bartenev 75cb2a947d PHP: rearranged feature checks in ./configure.
Now it prints version even if PHP was built without embed SAPI.
2020-03-04 15:24:27 +03:00
Valentin Bartenev a98de7f705 Added a "fallback" option to be used with the "share" action.
It allows proceeding to another action if a file isn't available.

An example:

    {
        "share": "/data/www/",

        "fallback": {
            "pass": "applications/php"
        }
    }

In the example above, an attempt is made first to serve a request with
a file from the "/data/www/" directory.  If there's no such file, the
request is passed to the "php" application.

Fallback actions may be nested:

    {
        "share": "/data/www/",

        "fallback": {
            "share": "/data/cache/",

            "fallback": {
                "proxy": "http://127.0.0.1:9000"
            }
        }
    }
2020-03-03 20:37:47 +03:00
Valentin Bartenev a60f856ce2 Improved validation of the "action" object.
Now it enforces the mutual exclusivity of "pass", "proxy", and "share" options.
2020-03-03 20:37:47 +03:00
Valentin Bartenev d198a105eb Configuration: removing UTF-8 BOM from the input JSON.
Some editors can add it to JSON files.
2020-02-20 17:58:24 +03:00
Valentin Bartenev 044b3afcda Configuration: stripping comments from the input JSON.
This allows to have JavaScript-like comments in the uploading JSON.
2020-02-20 17:58:24 +03:00
Valentin Bartenev 7a0383189c Version bump. 2020-02-19 19:13:51 +03:00
Valentin Bartenev 6e19090736 Added tag 1.15.0 for changeset 801ac82f80fb 2020-02-06 18:20:37 +03:00
Valentin Bartenev e6bb4c5493 Generated Dockerfiles for Unit 1.15.0. 2020-02-06 17:33:44 +03:00
Valentin Bartenev 672602d1ee Added version 1.15.0 CHANGES. 2020-02-06 17:33:44 +03:00
Valentin Bartenev f860c20a96 PHP: added check for the ".php" extension.
A check for the ".php" extension is added to prevent execution of files
with arbitrary extensions in cases where "index" and "script" options
aren't used.
2020-01-28 19:18:26 +03:00
Valentin Bartenev 4bad2cf1e9 Version bump. 2020-01-27 16:52:53 +03:00
Valentin Bartenev d2eac78c57 Updated copyright notice. 2020-01-27 16:52:45 +03:00
Valentin Bartenev 55f8e31ed7 Added tag 1.14.0 for changeset 6e28966ed1f2 2019-12-26 17:04:37 +03:00
Valentin Bartenev be8589d925 Generated Dockerfiles for Unit 1.14.0. 2019-12-26 17:03:21 +03:00
Valentin Bartenev 9403233328 Added version 1.14.0 CHANGES. 2019-12-26 17:03:21 +03:00
Valentin Bartenev 9224e94a8d Removed unused variables from "docs/Makefile".
They actually have been broken since 00d8049418cf,
where NXT_VERSION was removed from nxt_main.h.

Also, shebang is added.
2019-12-24 17:03:47 +03:00
Valentin Bartenev 51af6ac0a1 Python: pre-creation of objects for string constants.
This is an optimization to avoid creating them at runtime on each request.
2019-12-23 21:14:14 +03:00
Valentin Bartenev 0a27f137de Added tag 1.13.0 for changeset 3313bf222e6e 2019-11-14 19:25:20 +03:00
Valentin Bartenev 2241847efb Generated Dockerfiles for Unit 1.13.0. 2019-11-14 19:24:14 +03:00
Valentin Bartenev 182107c10e Added version 1.13.0 CHANGES. 2019-11-14 19:23:38 +03:00
Valentin Bartenev c2976fb337 Python: avoiding buffering of exception backtraces.
A quote from the Python 3 documentation:

 | When interactive, stdout and stderr streams are line-buffered.
 | Otherwise, they are block-buffered like regular text files.

As a result, if an exception occurred and PyErr_Print() was called, its output
could be buffered but not printed to the log for a while (ultimately, until
the interpreter finalization).  If the application process crashed shortly,
the backtrace was completely lost.

Buffering can be disabled by redefining the sys.stderr stream object.
However, interference with standard environment objects was deemed undesirable.
Instead, sys.stderr.flush() is called every time after printing exceptions.
A potential advantage here is that lines from backtraces won't be mixed
with other lines in the log.
2019-11-14 17:48:48 +03:00
Valentin Bartenev 4e41d90006 Python: removed wrong PyErr_Print() call.
PyCallable_Check() doesn't produce errors.

The needless call was introduced in fdd6ed28e3b9.
2019-11-14 17:48:48 +03:00
Valentin Bartenev b3db7a30c0 Python: optimized response object close() calling.
PyObject_HasAttrString() is just a wrapper over PyObject_GetAttrString(),
while PyObject_CallMethod() calls it as the first step.  As a result,
PyObject_GetAttrString() was called twice if close() was present.

To get rid of PyObject_HasAttrString() while keeping the same behaviour,
the PyObject_CallMethod() call has been decomposed into separate calls of
PyObject_GetAttrString() and PyObject_CallFunction().
2019-11-14 17:48:48 +03:00
Valentin Bartenev 75c2c23bb6 Python: fixed an object leak when response close() is called.
On success, PyObject_CallMethod() returns a new reference to
the result of the call, which previously got lost.

Also, error logging on failure was added.

The issue was introduced by b0148ec28c4d.
2019-11-14 17:48:48 +03:00
Valentin Bartenev c667bb446d Python: refactored nxt_python_request_handler(). 2019-11-14 17:48:48 +03:00
Valentin Bartenev cd6cb02be0 Python: fixed potential object leak in case of allocation error. 2019-11-14 17:48:48 +03:00