Commit Graph

1605 Commits

Author SHA1 Message Date
Max Romanov
762511c510 Fixing request_app_link reference counting.
Racing conditions reproduced periodically on test_python_process_switch.
2020-07-23 14:25:46 +03:00
Max Romanov
9641fb0ef1 Fixing various router crashes on exit caused by runtime pool free.
Currently, the router exits without waiting for the worker threads to stop.
There is a short gap between the runtime memory pool's free and the exit, during
which a worker thread may try to access a runtime structure.  In turn, this may
cause a crash.  For now, it is better to keep this memory allocated.
2020-07-23 14:25:21 +03:00
Max Romanov
d3c8d62280 PHP: using nxt_unit_default_init() for module structure init.
Using this function in all language modules helps to avoid code duplication
and reduce the size of future patches.
2020-07-23 14:25:12 +03:00
Max Romanov
137c1e736f Fixing main and application port structs file descriptor init.
Correct value for non-initialized file descriptor is -1, because most of the
checks in libunit compares file descriptor with -1 before performing an
action.  Using 0 as default value, may cause to close file descriptor #0, this
may affect application logic.

It is not required to list this patch in changelog because impact is not seen
by end users.
2020-07-23 14:24:55 +03:00
Max Romanov
fa696569f9 PHP: removing assertion to fix build on macOS.
The nxt_assert macro uses nxt_thread_context, which caused the following linker
error when using it in the library:

ld: illegal thread local variable reference to regular symbol
_nxt_thread_context for architecture x86_64
2020-07-23 14:24:16 +03:00
Max Romanov
661c223eda Tests: switching stdout to blocking before printing log.
This is another attempt to fix the following error message:
BlockingIOError: [Errno 11] write could not complete without blocking
2020-07-22 10:05:10 +03:00
Max Romanov
ef71948196 Fixing buffer overflow check in discovery.
Incorrect check prevents Unit to start without modules.

This issue was introduced in 4a3ec07f4b19.
2020-07-22 10:04:57 +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
Konstantin Pavlov
55bac9153b Docker: run entrypoint scripts for unitd-debug as well. 2020-07-13 15:06:26 +03:00
Axel Duch
b6792b00ae Router: route patterns multi wildcards fix.
Matching 'start' and 'end' position now adjusted to avoid false matching.

This is related to #434 issue on Github.
Thanks to 洪志道 (Hong Zhi Dao).
2020-07-10 10:28:53 +01:00
Igor Sysoev
18fbfc3d50 Destroying temporary router configuration.
The lifespan of a listening socket is longer than both router
configuration's and temporary router configuration's lifespan,
so the sockets should be stored in persistent queues. Safety
is ensured by the fact that the router processes only one new
configuration at any time.
2020-07-06 15:32:20 +03:00
Axel Duch
a9a21f6fe4 Router: route patterns multi wildcards support. 2020-07-04 03:24:07 +01:00
Andrei Zeliankou
9bd6baefae Tests: fixed opcache detection.
opcache_get_status() returns array, so square brackets
should be used to access "opcache_enabled" value.
2020-06-26 04:23:47 +01:00
Andrei Zeliankou
6e55f03dcd Tests: added chunked tests. 2020-06-24 04:11:09 +01:00
Igor Sysoev
65799c7252 Upstream chunked transfer encoding support. 2020-06-23 14:16:45 +03:00
Igor Sysoev
f671d1bc54 Decreased level of some socket close() errors. 2020-06-23 14:16:43 +03:00
Tiago Natel de Moura
f8ba5d6c00 Isolation: fixed build when features aren't detected. 2020-06-23 12:11:27 +01:00
Tiago Natel de Moura
0326cefef5 Python: fixed interpreter path in ./configure. 2020-06-23 11:01:20 +01:00
Andrei Belov
22c917bead Packages: added Fedora 32 support. 2020-06-16 15:02:29 +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
Tiago Natel de Moura
d3ca5fb47a Packages: fixed java configure script.
Now the configure script appends /server to --lib-path argument.
2020-05-28 17:04:00 +01: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
Tiago Natel de Moura
08b765ae42 Tests: Added rootfs tests. 2020-05-28 14:59:52 +01:00
Tiago Natel de Moura
e2b53e16c6 Added "rootfs" feature. 2020-05-28 14:57:41 +01:00
Tiago Natel de Moura
e9e5ddd5a5 Refactor of process management.
The process abstraction has changed to:

  setup(task, process)
  start(task, process_data)
  prefork(task, process, mp)

The prefork() occurs in the main process right before fork.

The file src/nxt_main_process.c is completely free of process
specific logic.

The creation of a process now supports a PROCESS_CREATED state.  The
The setup() function of each process can set its state to either
created or ready.  If created, a MSG_PROCESS_CREATED is sent to main
process, where external setup can be done (required for rootfs under
container).

The core processes (discovery, controller and router) doesn't need
external setup, then they all proceeds to their start() function
straight away.

In the case of applications, the load of the module happens at the
process setup() time and The module's init() function has changed
to be the start() of the process.

The module API has changed to:

  setup(task, process, conf)
  start(task, data)

As a direct benefit of the PROCESS_CREATED message, the clone(2) of
processes using pid namespaces now doesn't need to create a pipe
to make the child block until parent setup uid/gid mappings nor it
needs to receive the child pid.
2020-03-09 16:28:25 +00:00
Max Romanov
aacf11152c Moving nxt_stream_ident to shared memory.
This aims to avoid stream id clashes after router restart.
2020-05-28 12:41:00 +03:00
Max Romanov
de368f033d Added NULL check for engine->port.
This is required to handle REMOVE_PID messages if router engine
initialization is incomplete.
2020-05-28 12:40:54 +03:00
Max Romanov
89b1e88f8f Closing unsent file descriptors from port queue.
After a process exits, all ports linked to it from other processes
should be closed.  All unsent file descriptors in port queue, marked as
"close after send", should be closed to avoid resource leakage.
2020-05-28 12:40:49 +03:00
Andrei Zeliankou
fa4d4b6120 Tests: print unit.log in case of errors.
Thanks to hongzhidao.
2020-05-20 23:06:56 +01: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
Remi Collet
140b81208e PHP: building with PHP 8 (development version). 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
Andrei Zeliankou
82471c1dd3 Tests: added tests for "targets" option. 2020-05-15 04:21:25 +01:00
Andrei Zeliankou
ea841400f5 Tests: added test for encoding in the "pass" option. 2020-05-15 04:21:10 +01:00
Andrei Zeliankou
ce4a2bbd05 Tests: style. 2020-05-15 04:20:56 +01:00
Andrei Zeliankou
cf73fb8093 Tests: test_proxy_invalid simplified. 2020-05-15 04:20:45 +01:00
Axel Duch
26f407e24a Tests: decode uri and args. 2020-05-14 12:29:22 +02:00
Axel Duch
ee1e248f4b Router: decode uri and args. 2020-05-14 12:29:06 +02: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
Andrei Zeliankou
d803ec39bc Tests: added respawn tests. 2020-05-12 17:59:47 +01:00
Max Romanov
3ec72362b9 Waiting for router instead of reporting to user on config update. 2020-05-12 16:25:24 +03:00
Max Romanov
50f9816daa Blocking config change when applying the initial router config. 2020-05-12 16:25:16 +03:00
Valentin Bartenev
f291f24938 Version bump. 2020-05-12 11:15:03 +03:00