summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-03-30 14:18:41 +0300
committerMax Romanov <max.romanov@nginx.com>2020-03-30 14:18:41 +0300
commitab7b42a072e741b226749c416440f89fcaff3d2c (patch)
tree6f354e73a9cd446cefa80dcb0b466e6ceaa5b025
parent82b899b1365431951afc1da9b2b30065ac98fc94 (diff)
downloadunit-ab7b42a072e741b226749c416440f89fcaff3d2c.tar.gz
unit-ab7b42a072e741b226749c416440f89fcaff3d2c.tar.bz2
Handling change file message in libunit.
This is required for proper log file rotation action.
Diffstat (limited to '')
-rw-r--r--src/nxt_unit.c10
-rw-r--r--test/python/log_body/wsgi.py2
-rw-r--r--test/test_usr1.py1
3 files changed, 11 insertions, 2 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c
index 77e36771..55926431 100644
--- a/src/nxt_unit.c
+++ b/src/nxt_unit.c
@@ -767,6 +767,16 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id,
case _NXT_PORT_MSG_CHANGE_FILE:
nxt_unit_debug(ctx, "#%"PRIu32": change_file: fd %d",
port_msg->stream, recv_msg.fd);
+
+ if (dup2(recv_msg.fd, lib->log_fd) == -1) {
+ nxt_unit_alert(ctx, "#%"PRIu32": dup2(%d, %d) failed: %s (%d)",
+ port_msg->stream, recv_msg.fd, lib->log_fd,
+ strerror(errno), errno);
+
+ goto fail;
+ }
+
+ rc = NXT_UNIT_OK;
break;
case _NXT_PORT_MSG_MMAP:
diff --git a/test/python/log_body/wsgi.py b/test/python/log_body/wsgi.py
index 9dcb1b0c..0ec07a68 100644
--- a/test/python/log_body/wsgi.py
+++ b/test/python/log_body/wsgi.py
@@ -2,7 +2,7 @@ def application(environ, start_response):
content_length = int(environ.get('CONTENT_LENGTH', 0))
body = bytes(environ['wsgi.input'].read(content_length))
- environ['wsgi.errors'].write(body)
+ environ['wsgi.errors'].write(body.decode())
environ['wsgi.errors'].flush()
start_response('200', [('Content-Length', '0')])
diff --git a/test/test_usr1.py b/test/test_usr1.py
index 2b4f394b..204e2e0c 100644
--- a/test/test_usr1.py
+++ b/test/test_usr1.py
@@ -51,7 +51,6 @@ class TestUSR1(TestApplicationPython):
self.search_in_log(r'/usr1', log_new), 'rename new 2'
)
- @unittest.skip('not yet')
def test_usr1_unit_log(self):
self.load('log_body')