Deleted
Added
unit.cpp (1543:42f27153db91) | unit.cpp (1547:cbcd76704c90) |
---|---|
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; | 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_id_t port_id; | 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{ | 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 nxt_unit_run_once((nxt_unit_ctx_t *) handle->data); | 354 port_data_t *data; 355 356 data = (port_data_t *) handle->data; 357 358 nxt_unit_process_port_msg(data->ctx, data->port); |
355} 356 357 358int 359Unit::add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port) 360{ 361 int err; 362 Unit *obj; --- 28 unchanged lines hidden (view full) --- 391 if (err < 0) { 392 nxt_unit_warn(ctx, "Failed to start uv.poll"); 393 return NXT_UNIT_ERROR; 394 } 395 396 port->data = data; 397 398 data->ctx = ctx; | 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; |
399 data->port_id = port->id; 400 data->poll.data = ctx; | 403 data->port = port; 404 data->poll.data = data; |
401 } 402 403 return NXT_UNIT_OK; 404} 405 406 | 405 } 406 407 return NXT_UNIT_OK; 408} 409 410 |
407inline bool 408operator == (const nxt_unit_port_id_t &p1, const nxt_unit_port_id_t &p2) 409{ 410 return p1.pid == p2.pid && p1.id == p2.id; 411} 412 413 | |
414void 415Unit::remove_port(nxt_unit_t *unit, nxt_unit_port_t *port) 416{ 417 port_data_t *data; 418 419 if (port->data != NULL) { 420 data = (port_data_t *) port->data; 421 | 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 |
422 if (data->port_id == port->id) { | 419 if (data->port == port) { |
423 uv_poll_stop(&data->poll); 424 | 420 uv_poll_stop(&data->poll); 421 |
425 data->poll.data = data; | |
426 uv_close((uv_handle_t *) &data->poll, delete_port_data); 427 } 428 } 429} 430 431 432static void 433delete_port_data(uv_handle_t* handle) --- 599 unchanged lines hidden --- | 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 --- |