Unit does not work correctly

Valentin V. Bartenev vbart at nginx.com
Tue Oct 2 15:46:57 UTC 2018


On Tuesday 02 October 2018 15:41:43 Алексей Бердников wrote:
> Hello. 
> 
> I have a problem with Unit on Ubuntu 18.04.1. After running
> Unit and Creating Configuration Objects, one Unit "test_app"
> application process will be started. I'm sending a request
> with curl http://localhost:8400/ command. Only one request
> will be processed correctly. There will be no response to
> the second and next requests. After completion of the
> process with the command kill -9 UnitPID, the newly
> launched process will work also.
> 
[..]

Thank you for the report, please try the following patch.

  wbr, Valentin V. Bartenev


diff --git a/src/nxt_port.c b/src/nxt_port.c
--- a/src/nxt_port.c
+++ b/src/nxt_port.c
@@ -276,6 +276,8 @@ nxt_port_new_port_handler(nxt_task_t *ta
 
     nxt_process_use(task, process, -1);
 
+    nxt_fd_nonblocking(task, msg->fd);
+
     port->pair[0] = -1;
     port->pair[1] = msg->fd;
     port->max_size = new_port_msg->max_size;
diff --git a/src/nxt_unit.c b/src/nxt_unit.c
--- a/src/nxt_unit.c
+++ b/src/nxt_unit.c
@@ -510,7 +510,7 @@ int
 nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id,
     void *buf, size_t buf_size, void *oob, size_t oob_size)
 {
-    int                           fd, rc;
+    int                           fd, rc, nb;
     pid_t                         pid;
     nxt_queue_t                   incoming_buf;
     struct cmsghdr                *cm;
@@ -611,6 +611,15 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx
                        port_msg->stream, (int) new_port_msg->pid,
                        (int) new_port_msg->id, fd);
 
+        nb = 0;
+
+        if (nxt_slow_path(ioctl(fd, FIONBIO, &nb) == -1)) {
+            nxt_unit_alert(ctx, "#%"PRIu32": new_port: ioctl(%d, FIONBIO, 0) "
+                           "failed: %s (%d)", fd, strerror(errno), errno);
+
+            goto fail;
+        }
+
         nxt_unit_port_id_init(&new_port.id, new_port_msg->pid,
                               new_port_msg->id);
 



More information about the unit mailing list