111Sigor@sysoev.ru 211Sigor@sysoev.ru /* 311Sigor@sysoev.ru * Copyright (C) Igor Sysoev 411Sigor@sysoev.ru * Copyright (C) NGINX, Inc. 511Sigor@sysoev.ru */ 611Sigor@sysoev.ru 711Sigor@sysoev.ru #include <nxt_main.h> 820Sigor@sysoev.ru #include <nxt_runtime.h> 911Sigor@sysoev.ru #include <nxt_port.h> 10163Smax.romanov@nginx.com #include <nxt_router.h> 1111Sigor@sysoev.ru 1211Sigor@sysoev.ru 1314Sigor@sysoev.ru static void nxt_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg); 1411Sigor@sysoev.ru 15163Smax.romanov@nginx.com static nxt_atomic_uint_t nxt_port_last_id = 1; 16163Smax.romanov@nginx.com 17163Smax.romanov@nginx.com 18163Smax.romanov@nginx.com nxt_port_t * 19163Smax.romanov@nginx.com nxt_port_new(nxt_port_id_t id, nxt_pid_t pid, nxt_process_type_t type) 20163Smax.romanov@nginx.com { 21163Smax.romanov@nginx.com nxt_mp_t *mp; 22163Smax.romanov@nginx.com nxt_port_t *port; 23163Smax.romanov@nginx.com 24163Smax.romanov@nginx.com mp = nxt_mp_create(1024, 128, 256, 32); 25163Smax.romanov@nginx.com 26163Smax.romanov@nginx.com if (nxt_slow_path(mp == NULL)) { 27163Smax.romanov@nginx.com return NULL; 28163Smax.romanov@nginx.com } 29163Smax.romanov@nginx.com 30163Smax.romanov@nginx.com port = nxt_mp_zalloc(mp, sizeof(nxt_port_t)); 31163Smax.romanov@nginx.com 32163Smax.romanov@nginx.com if (nxt_fast_path(port != NULL)) { 33163Smax.romanov@nginx.com port->id = id; 34163Smax.romanov@nginx.com port->pid = pid; 35163Smax.romanov@nginx.com port->type = type; 36163Smax.romanov@nginx.com port->mem_pool = mp; 37*190Smax.romanov@nginx.com port->next_stream = 1; 38163Smax.romanov@nginx.com 39163Smax.romanov@nginx.com nxt_queue_init(&port->messages); 40163Smax.romanov@nginx.com 41163Smax.romanov@nginx.com } else { 42163Smax.romanov@nginx.com nxt_mp_destroy(mp); 43163Smax.romanov@nginx.com } 44163Smax.romanov@nginx.com 45167Smax.romanov@nginx.com nxt_thread_log_debug("port %p %d:%d new, type %d", port, pid, id, type); 46167Smax.romanov@nginx.com 47163Smax.romanov@nginx.com return port; 48163Smax.romanov@nginx.com } 49163Smax.romanov@nginx.com 50163Smax.romanov@nginx.com 51163Smax.romanov@nginx.com nxt_bool_t 52163Smax.romanov@nginx.com nxt_port_release(nxt_port_t *port) 53163Smax.romanov@nginx.com { 54167Smax.romanov@nginx.com nxt_thread_log_debug("port %p %d:%d release, type %d", port, port->pid, 55167Smax.romanov@nginx.com port->id, port->type); 56167Smax.romanov@nginx.com 57163Smax.romanov@nginx.com if (port->pair[0] != -1) { 58163Smax.romanov@nginx.com nxt_fd_close(port->pair[0]); 59163Smax.romanov@nginx.com port->pair[0] = -1; 60163Smax.romanov@nginx.com } 61163Smax.romanov@nginx.com 62163Smax.romanov@nginx.com if (port->pair[1] != -1) { 63163Smax.romanov@nginx.com nxt_fd_close(port->pair[1]); 64163Smax.romanov@nginx.com port->pair[1] = -1; 65163Smax.romanov@nginx.com } 66163Smax.romanov@nginx.com 67163Smax.romanov@nginx.com if (port->type == NXT_PROCESS_WORKER) { 68163Smax.romanov@nginx.com if (nxt_router_app_remove_port(port) == 0) { 69163Smax.romanov@nginx.com return 0; 70163Smax.romanov@nginx.com } 71163Smax.romanov@nginx.com } 72163Smax.romanov@nginx.com 73163Smax.romanov@nginx.com if (port->link.next != NULL) { 74163Smax.romanov@nginx.com nxt_process_port_remove(port); 75163Smax.romanov@nginx.com } 76163Smax.romanov@nginx.com 77163Smax.romanov@nginx.com nxt_mp_release(port->mem_pool, port); 78163Smax.romanov@nginx.com 79163Smax.romanov@nginx.com return 1; 80163Smax.romanov@nginx.com } 81163Smax.romanov@nginx.com 82141Smax.romanov@nginx.com 83141Smax.romanov@nginx.com nxt_port_id_t 84141Smax.romanov@nginx.com nxt_port_get_next_id() 85141Smax.romanov@nginx.com { 86141Smax.romanov@nginx.com return nxt_atomic_fetch_add(&nxt_port_last_id, 1); 87141Smax.romanov@nginx.com } 88141Smax.romanov@nginx.com 8911Sigor@sysoev.ru 9011Sigor@sysoev.ru void 91141Smax.romanov@nginx.com nxt_port_reset_next_id() 92141Smax.romanov@nginx.com { 93141Smax.romanov@nginx.com nxt_port_last_id = 1; 94141Smax.romanov@nginx.com } 95141Smax.romanov@nginx.com 96141Smax.romanov@nginx.com 97141Smax.romanov@nginx.com void 98141Smax.romanov@nginx.com nxt_port_enable(nxt_task_t *task, nxt_port_t *port, 9914Sigor@sysoev.ru nxt_port_handler_t *handlers) 10011Sigor@sysoev.ru { 10114Sigor@sysoev.ru port->pid = nxt_pid; 10214Sigor@sysoev.ru port->handler = nxt_port_handler; 10314Sigor@sysoev.ru port->data = handlers; 10411Sigor@sysoev.ru 10577Smax.romanov@nginx.com nxt_port_read_enable(task, port); 10611Sigor@sysoev.ru } 10711Sigor@sysoev.ru 10811Sigor@sysoev.ru 10911Sigor@sysoev.ru void 11020Sigor@sysoev.ru nxt_port_write(nxt_task_t *task, nxt_runtime_t *rt, nxt_uint_t type, 11111Sigor@sysoev.ru nxt_fd_t fd, uint32_t stream, nxt_buf_t *b) 11211Sigor@sysoev.ru { 11320Sigor@sysoev.ru nxt_port_t *port; 11420Sigor@sysoev.ru nxt_process_t *process; 11520Sigor@sysoev.ru 11642Smax.romanov@nginx.com nxt_runtime_process_each(rt, process) 11742Smax.romanov@nginx.com { 11842Smax.romanov@nginx.com if (nxt_pid != process->pid) { 11942Smax.romanov@nginx.com nxt_process_port_each(process, port) { 12011Sigor@sysoev.ru 12142Smax.romanov@nginx.com (void) nxt_port_socket_write(task, port, type, 12242Smax.romanov@nginx.com fd, stream, 0, b); 12311Sigor@sysoev.ru 12442Smax.romanov@nginx.com } nxt_process_port_loop; 12511Sigor@sysoev.ru } 12611Sigor@sysoev.ru } 12742Smax.romanov@nginx.com nxt_runtime_process_loop; 12811Sigor@sysoev.ru } 12911Sigor@sysoev.ru 13011Sigor@sysoev.ru 13111Sigor@sysoev.ru static void 13214Sigor@sysoev.ru nxt_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 13311Sigor@sysoev.ru { 13414Sigor@sysoev.ru nxt_port_handler_t *handlers; 13511Sigor@sysoev.ru 136125Smax.romanov@nginx.com if (nxt_fast_path(msg->port_msg.type < NXT_PORT_MSG_MAX)) { 13711Sigor@sysoev.ru 13811Sigor@sysoev.ru nxt_debug(task, "port %d: message type:%uD", 13942Smax.romanov@nginx.com msg->port->socket.fd, msg->port_msg.type); 14011Sigor@sysoev.ru 14111Sigor@sysoev.ru handlers = msg->port->data; 14242Smax.romanov@nginx.com handlers[msg->port_msg.type](task, msg); 14311Sigor@sysoev.ru 14411Sigor@sysoev.ru return; 14511Sigor@sysoev.ru } 14611Sigor@sysoev.ru 14711Sigor@sysoev.ru nxt_log(task, NXT_LOG_CRIT, "port %d: unknown message type:%uD", 14842Smax.romanov@nginx.com msg->port->socket.fd, msg->port_msg.type); 14911Sigor@sysoev.ru } 15011Sigor@sysoev.ru 15111Sigor@sysoev.ru 15211Sigor@sysoev.ru void 15314Sigor@sysoev.ru nxt_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 15411Sigor@sysoev.ru { 15520Sigor@sysoev.ru nxt_runtime_quit(task); 15611Sigor@sysoev.ru } 15711Sigor@sysoev.ru 15811Sigor@sysoev.ru 15911Sigor@sysoev.ru void 16020Sigor@sysoev.ru nxt_port_send_new_port(nxt_task_t *task, nxt_runtime_t *rt, 161141Smax.romanov@nginx.com nxt_port_t *new_port, uint32_t stream) 16211Sigor@sysoev.ru { 163141Smax.romanov@nginx.com nxt_port_t *port; 16481Smax.romanov@nginx.com nxt_process_t *process; 16511Sigor@sysoev.ru 166141Smax.romanov@nginx.com nxt_debug(task, "new port %d for process %PI", 167141Smax.romanov@nginx.com new_port->pair[1], new_port->pid); 16811Sigor@sysoev.ru 16942Smax.romanov@nginx.com nxt_runtime_process_each(rt, process) 17042Smax.romanov@nginx.com { 17142Smax.romanov@nginx.com if (process->pid == new_port->pid || process->pid == nxt_pid) { 17211Sigor@sysoev.ru continue; 17311Sigor@sysoev.ru } 17411Sigor@sysoev.ru 175141Smax.romanov@nginx.com port = nxt_process_port_first(process); 176141Smax.romanov@nginx.com 177141Smax.romanov@nginx.com if (port->type == NXT_PROCESS_MASTER || 178141Smax.romanov@nginx.com port->type == NXT_PROCESS_CONTROLLER || 179141Smax.romanov@nginx.com port->type == NXT_PROCESS_ROUTER) { 180141Smax.romanov@nginx.com 181141Smax.romanov@nginx.com (void) nxt_port_send_port(task, port, new_port, stream); 182141Smax.romanov@nginx.com } 18311Sigor@sysoev.ru } 18442Smax.romanov@nginx.com nxt_runtime_process_loop; 18511Sigor@sysoev.ru } 18611Sigor@sysoev.ru 18711Sigor@sysoev.ru 18881Smax.romanov@nginx.com nxt_int_t 189141Smax.romanov@nginx.com nxt_port_send_port(nxt_task_t *task, nxt_port_t *port, nxt_port_t *new_port, 190141Smax.romanov@nginx.com uint32_t stream) 19181Smax.romanov@nginx.com { 19281Smax.romanov@nginx.com nxt_buf_t *b; 19381Smax.romanov@nginx.com nxt_port_msg_new_port_t *msg; 19481Smax.romanov@nginx.com 195122Smax.romanov@nginx.com b = nxt_buf_mem_ts_alloc(task, port->mem_pool, sizeof(nxt_port_data_t)); 19681Smax.romanov@nginx.com if (nxt_slow_path(b == NULL)) { 19781Smax.romanov@nginx.com return NXT_ERROR; 19881Smax.romanov@nginx.com } 19981Smax.romanov@nginx.com 20081Smax.romanov@nginx.com nxt_debug(task, "send port %FD to process %PI", 20181Smax.romanov@nginx.com new_port->pair[1], port->pid); 20281Smax.romanov@nginx.com 20381Smax.romanov@nginx.com b->mem.free += sizeof(nxt_port_msg_new_port_t); 20481Smax.romanov@nginx.com msg = (nxt_port_msg_new_port_t *) b->mem.pos; 20581Smax.romanov@nginx.com 20681Smax.romanov@nginx.com msg->id = new_port->id; 20781Smax.romanov@nginx.com msg->pid = new_port->pid; 20881Smax.romanov@nginx.com msg->max_size = port->max_size; 20981Smax.romanov@nginx.com msg->max_share = port->max_share; 21081Smax.romanov@nginx.com msg->type = new_port->type; 21181Smax.romanov@nginx.com 21281Smax.romanov@nginx.com return nxt_port_socket_write(task, port, NXT_PORT_MSG_NEW_PORT, 213141Smax.romanov@nginx.com new_port->pair[1], stream, 0, b); 21481Smax.romanov@nginx.com } 21581Smax.romanov@nginx.com 21681Smax.romanov@nginx.com 21711Sigor@sysoev.ru void 21814Sigor@sysoev.ru nxt_port_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 21911Sigor@sysoev.ru { 22011Sigor@sysoev.ru nxt_port_t *port; 22120Sigor@sysoev.ru nxt_process_t *process; 22220Sigor@sysoev.ru nxt_runtime_t *rt; 22314Sigor@sysoev.ru nxt_port_msg_new_port_t *new_port_msg; 22411Sigor@sysoev.ru 22520Sigor@sysoev.ru rt = task->thread->runtime; 22611Sigor@sysoev.ru 22742Smax.romanov@nginx.com new_port_msg = (nxt_port_msg_new_port_t *) msg->buf->mem.pos; 22842Smax.romanov@nginx.com msg->buf->mem.pos = msg->buf->mem.free; 22942Smax.romanov@nginx.com 230141Smax.romanov@nginx.com nxt_debug(task, "new port %d received for process %PI:%d", 231141Smax.romanov@nginx.com msg->fd, new_port_msg->pid, new_port_msg->id); 232141Smax.romanov@nginx.com 233141Smax.romanov@nginx.com port = nxt_runtime_port_find(rt, new_port_msg->pid, new_port_msg->id); 234141Smax.romanov@nginx.com if (port != NULL) { 235141Smax.romanov@nginx.com nxt_debug(task, "port %PI:%d already exists", new_port_msg->pid, 236141Smax.romanov@nginx.com new_port_msg->id); 237141Smax.romanov@nginx.com 238141Smax.romanov@nginx.com nxt_fd_close(msg->fd); 239141Smax.romanov@nginx.com msg->fd = -1; 240141Smax.romanov@nginx.com return; 241141Smax.romanov@nginx.com } 242141Smax.romanov@nginx.com 24342Smax.romanov@nginx.com process = nxt_runtime_process_get(rt, new_port_msg->pid); 24420Sigor@sysoev.ru if (nxt_slow_path(process == NULL)) { 24520Sigor@sysoev.ru return; 24620Sigor@sysoev.ru } 24720Sigor@sysoev.ru 248163Smax.romanov@nginx.com port = nxt_port_new(new_port_msg->id, new_port_msg->pid, 249163Smax.romanov@nginx.com new_port_msg->type); 25011Sigor@sysoev.ru if (nxt_slow_path(port == NULL)) { 25111Sigor@sysoev.ru return; 25211Sigor@sysoev.ru } 25311Sigor@sysoev.ru 254164Smax.romanov@nginx.com nxt_process_port_add(task, process, port); 25514Sigor@sysoev.ru 25614Sigor@sysoev.ru port->pair[0] = -1; 25711Sigor@sysoev.ru port->pair[1] = msg->fd; 25814Sigor@sysoev.ru port->max_size = new_port_msg->max_size; 25914Sigor@sysoev.ru port->max_share = new_port_msg->max_share; 26011Sigor@sysoev.ru 26114Sigor@sysoev.ru port->socket.task = task; 26214Sigor@sysoev.ru 26342Smax.romanov@nginx.com nxt_runtime_port_add(rt, port); 26442Smax.romanov@nginx.com 26511Sigor@sysoev.ru nxt_port_write_enable(task, port); 266141Smax.romanov@nginx.com 267141Smax.romanov@nginx.com msg->new_port = port; 268141Smax.romanov@nginx.com } 269141Smax.romanov@nginx.com 270141Smax.romanov@nginx.com 271141Smax.romanov@nginx.com void 272141Smax.romanov@nginx.com nxt_port_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 273141Smax.romanov@nginx.com { 274141Smax.romanov@nginx.com nxt_port_t *port; 275141Smax.romanov@nginx.com nxt_process_t *process; 276141Smax.romanov@nginx.com nxt_runtime_t *rt; 277141Smax.romanov@nginx.com 278141Smax.romanov@nginx.com rt = task->thread->runtime; 279141Smax.romanov@nginx.com 280141Smax.romanov@nginx.com process = nxt_runtime_process_get(rt, msg->port_msg.pid); 281141Smax.romanov@nginx.com if (nxt_slow_path(process == NULL)) { 282141Smax.romanov@nginx.com return; 283141Smax.romanov@nginx.com } 284141Smax.romanov@nginx.com 285141Smax.romanov@nginx.com process->ready = 1; 286141Smax.romanov@nginx.com 287141Smax.romanov@nginx.com port = nxt_process_port_first(process); 288141Smax.romanov@nginx.com if (nxt_slow_path(port == NULL)) { 289141Smax.romanov@nginx.com return; 290141Smax.romanov@nginx.com } 291141Smax.romanov@nginx.com 292141Smax.romanov@nginx.com nxt_debug(task, "process %PI ready", msg->port_msg.pid); 293141Smax.romanov@nginx.com 294141Smax.romanov@nginx.com if (nxt_runtime_is_master(rt)) { 295141Smax.romanov@nginx.com nxt_port_send_new_port(task, rt, port, msg->port_msg.stream); 296141Smax.romanov@nginx.com } 29711Sigor@sysoev.ru } 29811Sigor@sysoev.ru 29911Sigor@sysoev.ru 30011Sigor@sysoev.ru void 30142Smax.romanov@nginx.com nxt_port_mmap_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 30242Smax.romanov@nginx.com { 30342Smax.romanov@nginx.com nxt_runtime_t *rt; 30442Smax.romanov@nginx.com nxt_process_t *process; 30542Smax.romanov@nginx.com 30642Smax.romanov@nginx.com rt = task->thread->runtime; 30742Smax.romanov@nginx.com 30842Smax.romanov@nginx.com if (nxt_slow_path(msg->fd == -1)) { 30942Smax.romanov@nginx.com nxt_log(task, NXT_LOG_WARN, "invalid fd passed with mmap message"); 31042Smax.romanov@nginx.com 31142Smax.romanov@nginx.com return; 31242Smax.romanov@nginx.com } 31342Smax.romanov@nginx.com 31442Smax.romanov@nginx.com process = nxt_runtime_process_get(rt, msg->port_msg.pid); 31542Smax.romanov@nginx.com if (nxt_slow_path(process == NULL)) { 31642Smax.romanov@nginx.com nxt_log(task, NXT_LOG_WARN, "failed to get process #%PI", 31742Smax.romanov@nginx.com msg->port_msg.pid); 31842Smax.romanov@nginx.com 31942Smax.romanov@nginx.com goto fail_close; 32042Smax.romanov@nginx.com } 32142Smax.romanov@nginx.com 32242Smax.romanov@nginx.com nxt_port_incoming_port_mmap(task, process, msg->fd); 32342Smax.romanov@nginx.com 32442Smax.romanov@nginx.com fail_close: 32542Smax.romanov@nginx.com 32642Smax.romanov@nginx.com close(msg->fd); 32742Smax.romanov@nginx.com } 32842Smax.romanov@nginx.com 32942Smax.romanov@nginx.com 33042Smax.romanov@nginx.com void 33120Sigor@sysoev.ru nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt, nxt_uint_t slot, 33220Sigor@sysoev.ru nxt_fd_t fd) 33311Sigor@sysoev.ru { 33420Sigor@sysoev.ru nxt_buf_t *b; 33520Sigor@sysoev.ru nxt_port_t *port; 33620Sigor@sysoev.ru nxt_process_t *process; 33711Sigor@sysoev.ru 33814Sigor@sysoev.ru nxt_debug(task, "change log file #%ui fd:%FD", slot, fd); 33911Sigor@sysoev.ru 34042Smax.romanov@nginx.com nxt_runtime_process_each(rt, process) 34142Smax.romanov@nginx.com { 34242Smax.romanov@nginx.com if (nxt_pid == process->pid) { 34342Smax.romanov@nginx.com continue; 34442Smax.romanov@nginx.com } 34511Sigor@sysoev.ru 34642Smax.romanov@nginx.com port = nxt_process_port_first(process); 34711Sigor@sysoev.ru 34820Sigor@sysoev.ru b = nxt_buf_mem_alloc(port->mem_pool, sizeof(nxt_port_data_t), 0); 34911Sigor@sysoev.ru if (nxt_slow_path(b == NULL)) { 35011Sigor@sysoev.ru continue; 35111Sigor@sysoev.ru } 35211Sigor@sysoev.ru 35311Sigor@sysoev.ru *(nxt_uint_t *) b->mem.pos = slot; 35411Sigor@sysoev.ru b->mem.free += sizeof(nxt_uint_t); 35511Sigor@sysoev.ru 35620Sigor@sysoev.ru (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_CHANGE_FILE, 35742Smax.romanov@nginx.com fd, 0, 0, b); 35811Sigor@sysoev.ru } 35942Smax.romanov@nginx.com nxt_runtime_process_loop; 36011Sigor@sysoev.ru } 36111Sigor@sysoev.ru 36211Sigor@sysoev.ru 36311Sigor@sysoev.ru void 36414Sigor@sysoev.ru nxt_port_change_log_file_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 36511Sigor@sysoev.ru { 36620Sigor@sysoev.ru nxt_buf_t *b; 36720Sigor@sysoev.ru nxt_uint_t slot; 36820Sigor@sysoev.ru nxt_file_t *log_file; 36920Sigor@sysoev.ru nxt_runtime_t *rt; 37011Sigor@sysoev.ru 37120Sigor@sysoev.ru rt = task->thread->runtime; 37211Sigor@sysoev.ru 37311Sigor@sysoev.ru b = msg->buf; 37411Sigor@sysoev.ru slot = *(nxt_uint_t *) b->mem.pos; 37511Sigor@sysoev.ru 37620Sigor@sysoev.ru log_file = nxt_list_elt(rt->log_files, slot); 37711Sigor@sysoev.ru 37811Sigor@sysoev.ru nxt_debug(task, "change log file %FD:%FD", msg->fd, log_file->fd); 37911Sigor@sysoev.ru 38011Sigor@sysoev.ru /* 38111Sigor@sysoev.ru * The old log file descriptor must be closed at the moment when no 38211Sigor@sysoev.ru * other threads use it. dup2() allows to use the old file descriptor 38311Sigor@sysoev.ru * for new log file. This change is performed atomically in the kernel. 38411Sigor@sysoev.ru */ 38511Sigor@sysoev.ru if (nxt_file_redirect(log_file, msg->fd) == NXT_OK) { 38611Sigor@sysoev.ru 38711Sigor@sysoev.ru if (slot == 0) { 38811Sigor@sysoev.ru (void) nxt_file_stderr(log_file); 38911Sigor@sysoev.ru } 39011Sigor@sysoev.ru } 39111Sigor@sysoev.ru } 39211Sigor@sysoev.ru 39311Sigor@sysoev.ru 39411Sigor@sysoev.ru void 39514Sigor@sysoev.ru nxt_port_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 39611Sigor@sysoev.ru { 39742Smax.romanov@nginx.com size_t dump_size; 39811Sigor@sysoev.ru nxt_buf_t *b; 39911Sigor@sysoev.ru 40011Sigor@sysoev.ru b = msg->buf; 40142Smax.romanov@nginx.com dump_size = b->mem.free - b->mem.pos; 40211Sigor@sysoev.ru 40342Smax.romanov@nginx.com if (dump_size > 300) { 40442Smax.romanov@nginx.com dump_size = 300; 40542Smax.romanov@nginx.com } 40642Smax.romanov@nginx.com 40742Smax.romanov@nginx.com nxt_debug(task, "data: %*s", dump_size, b->mem.pos); 40811Sigor@sysoev.ru 40911Sigor@sysoev.ru b->mem.pos = b->mem.free; 41011Sigor@sysoev.ru } 41111Sigor@sysoev.ru 41211Sigor@sysoev.ru 41311Sigor@sysoev.ru void 414125Smax.romanov@nginx.com nxt_port_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 415125Smax.romanov@nginx.com { 416125Smax.romanov@nginx.com nxt_pid_t pid; 417125Smax.romanov@nginx.com nxt_runtime_t *rt; 418125Smax.romanov@nginx.com nxt_process_t *process; 419125Smax.romanov@nginx.com 420125Smax.romanov@nginx.com nxt_debug(task, "port remove pid handler"); 421125Smax.romanov@nginx.com 422125Smax.romanov@nginx.com rt = task->thread->runtime; 423125Smax.romanov@nginx.com pid = msg->port_msg.stream; 424125Smax.romanov@nginx.com 425*190Smax.romanov@nginx.com nxt_port_rpc_remove_peer(task, msg->port, pid); 426*190Smax.romanov@nginx.com 427125Smax.romanov@nginx.com process = nxt_runtime_process_find(rt, pid); 428125Smax.romanov@nginx.com 429125Smax.romanov@nginx.com if (process) { 430125Smax.romanov@nginx.com nxt_runtime_process_remove(rt, process); 431125Smax.romanov@nginx.com } 432125Smax.romanov@nginx.com } 433125Smax.romanov@nginx.com 434125Smax.romanov@nginx.com 435125Smax.romanov@nginx.com void 43614Sigor@sysoev.ru nxt_port_empty_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) 43711Sigor@sysoev.ru { 43811Sigor@sysoev.ru nxt_debug(task, "port empty handler"); 43911Sigor@sysoev.ru } 440