Deleted Added
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6#include "unit.h"
7
8#include <unistd.h>

--- 6 unchanged lines hidden (view full) ---

15
16static void delete_port_data(uv_handle_t* handle);
17
18napi_ref Unit::constructor_;
19
20
21struct port_data_t {
22 nxt_unit_ctx_t *ctx;
23 nxt_unit_port_t *port;
24 uv_poll_t poll;
25};
26
27
28struct req_data_t {
29 napi_ref sock_ref;
30 napi_ref resp_ref;
31 napi_ref conn_ref;

--- 314 unchanged lines hidden (view full) ---

346 nxt_unit_warn(ctx, "shm_ack_handler: %s", e.str);
347 }
348}
349
350
351static void
352nxt_uv_read_callback(uv_poll_t *handle, int status, int events)
353{
354 port_data_t *data;
355
356 data = (port_data_t *) handle->data;
357
358 nxt_unit_process_port_msg(data->ctx, data->port);
359}
360
361
362int
363Unit::add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port)
364{
365 int err;
366 Unit *obj;

--- 28 unchanged lines hidden (view full) ---

395 if (err < 0) {
396 nxt_unit_warn(ctx, "Failed to start uv.poll");
397 return NXT_UNIT_ERROR;
398 }
399
400 port->data = data;
401
402 data->ctx = ctx;
403 data->port = port;
404 data->poll.data = data;
405 }
406
407 return NXT_UNIT_OK;
408}
409
410
411void
412Unit::remove_port(nxt_unit_t *unit, nxt_unit_port_t *port)
413{
414 port_data_t *data;
415
416 if (port->data != NULL) {
417 data = (port_data_t *) port->data;
418
419 if (data->port == port) {
420 uv_poll_stop(&data->poll);
421
422 uv_close((uv_handle_t *) &data->poll, delete_port_data);
423 }
424 }
425}
426
427
428static void
429delete_port_data(uv_handle_t* handle)

--- 599 unchanged lines hidden ---