Lines Matching refs:lib

45 static int nxt_unit_ctx_init(nxt_unit_impl_t *lib,
49 nxt_inline void nxt_unit_lib_use(nxt_unit_impl_t *lib);
50 nxt_inline void nxt_unit_lib_release(nxt_unit_impl_t *lib);
134 static nxt_unit_process_t *nxt_unit_process_find(nxt_unit_impl_t *lib,
136 static nxt_unit_process_t *nxt_unit_process_pop_first(nxt_unit_impl_t *lib);
160 static void nxt_unit_remove_port(nxt_unit_impl_t *lib, nxt_unit_ctx_t *ctx,
162 static nxt_unit_port_t *nxt_unit_remove_port_unsafe(nxt_unit_impl_t *lib,
164 static void nxt_unit_remove_pid(nxt_unit_impl_t *lib, pid_t pid);
165 static void nxt_unit_remove_process(nxt_unit_impl_t *lib,
408 nxt_unit_impl_t *lib; member
433 nxt_unit_impl_t *lib; in nxt_unit_init() local
438 lib = nxt_unit_create(init); in nxt_unit_init()
439 if (nxt_slow_path(lib == NULL)) { in nxt_unit_init()
456 lib->log_fd = init->log_fd; in nxt_unit_init()
471 &lib->log_fd, &ready_stream, &shm_limit, in nxt_unit_init()
477 lib->shm_mmap_limit = (shm_limit + PORT_MMAP_DATA_SIZE - 1) in nxt_unit_init()
479 lib->request_limit = request_limit; in nxt_unit_init()
482 if (nxt_slow_path(lib->shm_mmap_limit < 1)) { in nxt_unit_init()
483 lib->shm_mmap_limit = 1; in nxt_unit_init()
486 lib->pid = read_port.id.pid; in nxt_unit_init()
487 nxt_unit_pid = lib->pid; in nxt_unit_init()
489 ctx = &lib->main_ctx.ctx; in nxt_unit_init()
496 lib->router_port = nxt_unit_add_port(ctx, &router_port, NULL); in nxt_unit_init()
497 if (nxt_slow_path(lib->router_port == NULL)) { in nxt_unit_init()
524 lib->main_ctx.read_port = nxt_unit_add_port(ctx, &read_port, mem); in nxt_unit_init()
525 if (nxt_slow_path(lib->main_ctx.read_port == NULL)) { in nxt_unit_init()
550 lib->shared_port = nxt_unit_add_port(ctx, &shared_port, mem); in nxt_unit_init()
551 if (nxt_slow_path(lib->shared_port == NULL)) { in nxt_unit_init()
579 nxt_unit_ctx_release(&lib->main_ctx.ctx); in nxt_unit_init()
589 nxt_unit_impl_t *lib; in nxt_unit_create() local
592 lib = nxt_unit_malloc(NULL, in nxt_unit_create()
594 if (nxt_slow_path(lib == NULL)) { in nxt_unit_create()
600 rc = pthread_mutex_init(&lib->mutex, NULL); in nxt_unit_create()
607 lib->unit.data = init->data; in nxt_unit_create()
608 lib->callbacks = init->callbacks; in nxt_unit_create()
610 lib->request_data_size = init->request_data_size; in nxt_unit_create()
611 lib->shm_mmap_limit = (init->shm_limit + PORT_MMAP_DATA_SIZE - 1) in nxt_unit_create()
613 lib->request_limit = init->request_limit; in nxt_unit_create()
615 lib->processes.slot = NULL; in nxt_unit_create()
616 lib->ports.slot = NULL; in nxt_unit_create()
618 lib->log_fd = STDERR_FILENO; in nxt_unit_create()
620 nxt_queue_init(&lib->contexts); in nxt_unit_create()
622 lib->use_count = 0; in nxt_unit_create()
623 lib->request_count = 0; in nxt_unit_create()
624 lib->router_port = NULL; in nxt_unit_create()
625 lib->shared_port = NULL; in nxt_unit_create()
627 rc = nxt_unit_ctx_init(lib, &lib->main_ctx, init->ctx_data); in nxt_unit_create()
629 pthread_mutex_destroy(&lib->mutex); in nxt_unit_create()
633 cb = &lib->callbacks; in nxt_unit_create()
638 pthread_mutex_destroy(&lib->mutex); in nxt_unit_create()
642 nxt_unit_mmaps_init(&lib->incoming); in nxt_unit_create()
643 nxt_unit_mmaps_init(&lib->outgoing); in nxt_unit_create()
645 return lib; in nxt_unit_create()
649 nxt_unit_free(NULL, lib); in nxt_unit_create()
656 nxt_unit_ctx_init(nxt_unit_impl_t *lib, nxt_unit_ctx_impl_t *ctx_impl, in nxt_unit_ctx_init() argument
662 ctx_impl->ctx.unit = &lib->unit; in nxt_unit_ctx_init()
671 nxt_unit_lib_use(lib); in nxt_unit_ctx_init()
673 pthread_mutex_lock(&lib->mutex); in nxt_unit_ctx_init()
675 nxt_queue_insert_tail(&lib->contexts, &ctx_impl->link); in nxt_unit_ctx_init()
677 pthread_mutex_unlock(&lib->mutex); in nxt_unit_ctx_init()
702 ctx_impl->req.req.unit = &lib->unit; in nxt_unit_ctx_init()
739 nxt_unit_lib_use(nxt_unit_impl_t *lib) in nxt_unit_lib_use() argument
741 nxt_atomic_fetch_add(&lib->use_count, 1); in nxt_unit_lib_use()
746 nxt_unit_lib_release(nxt_unit_impl_t *lib) in nxt_unit_lib_release() argument
751 c = nxt_atomic_fetch_add(&lib->use_count, -1); in nxt_unit_lib_release()
755 pthread_mutex_lock(&lib->mutex); in nxt_unit_lib_release()
757 process = nxt_unit_process_pop_first(lib); in nxt_unit_lib_release()
759 pthread_mutex_unlock(&lib->mutex); in nxt_unit_lib_release()
764 nxt_unit_remove_process(lib, process); in nxt_unit_lib_release()
767 pthread_mutex_destroy(&lib->mutex); in nxt_unit_lib_release()
769 if (nxt_fast_path(lib->router_port != NULL)) { in nxt_unit_lib_release()
770 nxt_unit_port_release(lib->router_port); in nxt_unit_lib_release()
773 if (nxt_fast_path(lib->shared_port != NULL)) { in nxt_unit_lib_release()
774 nxt_unit_port_release(lib->shared_port); in nxt_unit_lib_release()
777 nxt_unit_mmaps_destroy(&lib->incoming); in nxt_unit_lib_release()
778 nxt_unit_mmaps_destroy(&lib->outgoing); in nxt_unit_lib_release()
780 nxt_unit_free(NULL, lib); in nxt_unit_lib_release()
933 nxt_unit_impl_t *lib; in nxt_unit_ready() local
936 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_ready()
939 msg.pid = lib->pid; in nxt_unit_ready()
966 nxt_unit_impl_t *lib; in nxt_unit_process_msg() local
969 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_process_msg()
1074 if (dup2(recv_msg.fd[0], lib->log_fd) == -1) { in nxt_unit_process_msg()
1076 port_msg->stream, recv_msg.fd[0], lib->log_fd, in nxt_unit_process_msg()
1125 nxt_unit_remove_pid(lib, pid); in nxt_unit_process_msg()
1232 nxt_unit_impl_t *lib; in nxt_unit_ctx_ready() local
1243 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_ctx_ready()
1246 if (&lib->main_ctx == ctx_impl && lib->callbacks.ready_handler != NULL) { in nxt_unit_ctx_ready()
1247 return lib->callbacks.ready_handler(ctx); in nxt_unit_ctx_ready()
1250 if (&lib->main_ctx != ctx_impl) { in nxt_unit_ctx_ready()
1252 if (nxt_slow_path(!lib->main_ctx.ready)) { in nxt_unit_ctx_ready()
1255 nxt_unit_quit(ctx, lib->main_ctx.quit_param); in nxt_unit_ctx_ready()
1260 if (lib->callbacks.add_port != NULL) { in nxt_unit_ctx_ready()
1261 lib->callbacks.add_port(ctx, lib->shared_port); in nxt_unit_ctx_ready()
1274 nxt_unit_impl_t *lib; in nxt_unit_process_req_headers() local
1364 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_process_req_headers()
1382 if (lib->callbacks.data_handler == NULL) { in nxt_unit_process_req_headers()
1388 lib->callbacks.request_handler(req); in nxt_unit_process_req_headers()
1403 nxt_unit_impl_t *lib; in nxt_unit_process_req_body() local
1436 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_process_req_body()
1438 if (lib->callbacks.data_handler != NULL) { in nxt_unit_process_req_body()
1439 lib->callbacks.data_handler(req); in nxt_unit_process_req_body()
1445 lib->callbacks.request_handler(req); in nxt_unit_process_req_body()
1458 nxt_unit_impl_t *lib; in nxt_unit_request_check_response_port() local
1466 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_request_check_response_port()
1469 pthread_mutex_lock(&lib->mutex); in nxt_unit_request_check_response_port()
1471 port = nxt_unit_port_hash_find(&lib->ports, port_id, 0); in nxt_unit_request_check_response_port()
1478 pthread_mutex_unlock(&lib->mutex); in nxt_unit_request_check_response_port()
1495 pthread_mutex_unlock(&lib->mutex); in nxt_unit_request_check_response_port()
1507 pthread_mutex_unlock(&lib->mutex); in nxt_unit_request_check_response_port()
1519 res = nxt_unit_port_hash_add(&lib->ports, port); in nxt_unit_request_check_response_port()
1524 pthread_mutex_unlock(&lib->mutex); in nxt_unit_request_check_response_port()
1531 process = nxt_unit_process_find(lib, port_id->pid, 0); in nxt_unit_request_check_response_port()
1536 nxt_unit_port_hash_find(&lib->ports, port_id, 1); in nxt_unit_request_check_response_port()
1538 pthread_mutex_unlock(&lib->mutex); in nxt_unit_request_check_response_port()
1563 pthread_mutex_unlock(&lib->mutex); in nxt_unit_request_check_response_port()
1581 nxt_unit_impl_t *lib; in nxt_unit_send_req_headers_ack() local
1585 lib = nxt_container_of(req->ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_send_req_headers_ack()
1592 msg.pid = lib->pid; in nxt_unit_send_req_headers_ack()
1610 nxt_unit_impl_t *lib; in nxt_unit_process_websocket() local
1624 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_process_websocket()
1625 cb = &lib->callbacks; in nxt_unit_process_websocket()
1715 nxt_unit_impl_t *lib; in nxt_unit_process_shm_ack() local
1718 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_process_shm_ack()
1719 cb = &lib->callbacks; in nxt_unit_process_shm_ack()
1732 nxt_unit_impl_t *lib; in nxt_unit_request_info_get() local
1739 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_request_info_get()
1747 + lib->request_data_size); in nxt_unit_request_info_get()
1768 req_impl->req.data = lib->request_data_size ? req_impl->extra_data : NULL; in nxt_unit_request_info_get()
2627 nxt_unit_impl_t *lib; in nxt_unit_mmap_buf_send() local
2631 lib = nxt_container_of(req->ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_mmap_buf_send()
2640 m.msg.pid = lib->pid; in nxt_unit_mmap_buf_send()
2688 nxt_atomic_fetch_add(&lib->outgoing.allocated_chunks, in nxt_unit_mmap_buf_send()
2692 (int) lib->outgoing.allocated_chunks); in nxt_unit_mmap_buf_send()
3247 nxt_unit_impl_t *lib; in nxt_unit_request_done() local
3286 lib = nxt_container_of(req->unit, nxt_unit_impl_t, unit); in nxt_unit_request_done()
3289 msg.pid = lib->pid; in nxt_unit_request_done()
3483 nxt_unit_impl_t *lib; in nxt_unit_mmap_get() local
3486 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_mmap_get()
3488 pthread_mutex_lock(&lib->outgoing.mutex); in nxt_unit_mmap_get()
3492 outgoing_size = lib->outgoing.size; in nxt_unit_mmap_get()
3494 mm_end = lib->outgoing.elts + outgoing_size; in nxt_unit_mmap_get()
3496 for (mm = lib->outgoing.elts; mm < mm_end; mm++) { in nxt_unit_mmap_get()
3544 if (outgoing_size >= lib->shm_mmap_limit) { in nxt_unit_mmap_get()
3546 pthread_mutex_unlock(&lib->outgoing.mutex); in nxt_unit_mmap_get()
3552 if (nxt_slow_path(lib->outgoing.allocated_chunks + min_n in nxt_unit_mmap_get()
3553 >= lib->shm_mmap_limit * PORT_MMAP_CHUNK_COUNT)) in nxt_unit_mmap_get()
3581 pthread_mutex_lock(&lib->outgoing.mutex); in nxt_unit_mmap_get()
3591 nxt_atomic_fetch_add(&lib->outgoing.allocated_chunks, *n); in nxt_unit_mmap_get()
3594 (int) lib->outgoing.allocated_chunks); in nxt_unit_mmap_get()
3596 pthread_mutex_unlock(&lib->outgoing.mutex); in nxt_unit_mmap_get()
3607 nxt_unit_impl_t *lib; in nxt_unit_send_oosm() local
3609 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_send_oosm()
3612 msg.pid = lib->pid; in nxt_unit_send_oosm()
3620 res = nxt_unit_port_send(ctx, lib->router_port, &msg, sizeof(msg), NULL); in nxt_unit_send_oosm()
3735 nxt_unit_impl_t *lib; in nxt_unit_new_mmap() local
3738 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_new_mmap()
3740 mm = nxt_unit_mmap_at(&lib->outgoing, lib->outgoing.size); in nxt_unit_new_mmap()
3768 hdr->id = lib->outgoing.size - 1; in nxt_unit_new_mmap()
3769 hdr->src_pid = lib->pid; in nxt_unit_new_mmap()
3783 pthread_mutex_unlock(&lib->outgoing.mutex); in nxt_unit_new_mmap()
3792 hdr->id, (int) lib->pid, (int) port->id.pid); in nxt_unit_new_mmap()
3797 pthread_mutex_lock(&lib->outgoing.mutex); in nxt_unit_new_mmap()
3805 lib->outgoing.size--; in nxt_unit_new_mmap()
3818 nxt_unit_impl_t *lib; in nxt_unit_shm_open() local
3820 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_shm_open()
3822 lib->pid, (void *) (uintptr_t) pthread_self()); in nxt_unit_shm_open()
3890 nxt_unit_impl_t *lib; in nxt_unit_send_mmap() local
3893 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_send_mmap()
3896 msg.pid = lib->pid; in nxt_unit_send_mmap()
3991 nxt_unit_impl_t *lib; in nxt_unit_incoming_mmap() local
3996 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_incoming_mmap()
4022 (int) pid, (int) hdr->dst_pid, (int) lib->pid); in nxt_unit_incoming_mmap()
4031 pthread_mutex_lock(&lib->incoming.mutex); in nxt_unit_incoming_mmap()
4033 mm = nxt_unit_mmap_at(&lib->incoming, hdr->id); in nxt_unit_incoming_mmap()
4052 pthread_mutex_unlock(&lib->incoming.mutex); in nxt_unit_incoming_mmap()
4207 nxt_unit_impl_t *lib; in nxt_unit_mmap_read() local
4246 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_mmap_read()
4248 mmaps = &lib->incoming; in nxt_unit_mmap_read()
4298 nxt_unit_impl_t *lib; in nxt_unit_get_mmap() local
4306 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_get_mmap()
4311 m.msg.pid = lib->pid; in nxt_unit_get_mmap()
4319 res = nxt_unit_port_send(ctx, lib->router_port, &m, sizeof(m), NULL); in nxt_unit_get_mmap()
4335 nxt_unit_impl_t *lib; in nxt_unit_mmap_release() local
4352 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_mmap_release()
4354 if (hdr->src_pid == lib->pid && freed_chunks != 0) { in nxt_unit_mmap_release()
4355 nxt_atomic_fetch_add(&lib->outgoing.allocated_chunks, -freed_chunks); in nxt_unit_mmap_release()
4358 (int) lib->outgoing.allocated_chunks); in nxt_unit_mmap_release()
4361 if (hdr->dst_pid == lib->pid in nxt_unit_mmap_release()
4375 nxt_unit_impl_t *lib; in nxt_unit_send_shm_ack() local
4377 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_send_shm_ack()
4380 msg.pid = lib->pid; in nxt_unit_send_shm_ack()
4388 res = nxt_unit_port_send(ctx, lib->router_port, &msg, sizeof(msg), NULL); in nxt_unit_send_shm_ack()
4435 nxt_unit_impl_t *lib; in nxt_unit_process_get() local
4439 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_process_get()
4443 if (nxt_lvlhsh_find(&lib->processes, &lhq) == NXT_OK) { in nxt_unit_process_get()
4460 process->lib = lib; in nxt_unit_process_get()
4467 switch (nxt_lvlhsh_insert(&lib->processes, &lhq)) { in nxt_unit_process_get()
4485 nxt_unit_process_find(nxt_unit_impl_t *lib, pid_t pid, int remove) in nxt_unit_process_find() argument
4493 rc = nxt_lvlhsh_delete(&lib->processes, &lhq); in nxt_unit_process_find()
4496 rc = nxt_lvlhsh_find(&lib->processes, &lhq); in nxt_unit_process_find()
4512 nxt_unit_process_pop_first(nxt_unit_impl_t *lib) in nxt_unit_process_pop_first() argument
4514 return nxt_lvlhsh_retrieve(&lib->processes, &lvlhsh_processes_proto, NULL); in nxt_unit_process_pop_first()
4599 nxt_unit_impl_t *lib; in nxt_unit_read_buf() local
4613 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_read_buf()
4640 res = nxt_unit_app_queue_recv(ctx, lib->shared_port, rbuf); in nxt_unit_read_buf()
4645 fds[1].fd = lib->shared_port->in_fd; in nxt_unit_read_buf()
4690 res = nxt_unit_shared_port_recv(ctx, lib->shared_port, rbuf); in nxt_unit_read_buf()
4709 nxt_unit_impl_t *lib; in nxt_unit_chk_ready() local
4713 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_chk_ready()
4716 && (lib->request_limit == 0 in nxt_unit_chk_ready()
4717 || lib->request_count < lib->request_limit)); in nxt_unit_chk_ready()
4772 nxt_unit_impl_t *lib; in nxt_unit_process_ready_req() local
4797 lib = nxt_container_of(ctx_impl->ctx.unit, nxt_unit_impl_t, unit); in nxt_unit_process_ready_req()
4824 if (lib->callbacks.data_handler == NULL) { in nxt_unit_process_ready_req()
4829 lib->callbacks.request_handler(&req_impl->req); in nxt_unit_process_ready_req()
4941 nxt_unit_impl_t *lib; in nxt_unit_run_shared() local
4946 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_run_shared()
4959 rc = nxt_unit_shared_port_recv(ctx, lib->shared_port, rbuf); in nxt_unit_run_shared()
4985 nxt_unit_impl_t *lib; in nxt_unit_dequeue_request() local
4991 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_dequeue_request()
5004 rc = nxt_unit_app_queue_recv(ctx, lib->shared_port, rbuf); in nxt_unit_dequeue_request()
5039 nxt_unit_impl_t *lib; in nxt_unit_process_port_msg_impl() local
5042 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_process_port_msg_impl()
5044 if (port == lib->shared_port && !nxt_unit_chk_ready(ctx)) { in nxt_unit_process_port_msg_impl()
5053 if (port == lib->shared_port) { in nxt_unit_process_port_msg_impl()
5093 nxt_unit_impl_t *lib; in nxt_unit_ctx_alloc() local
5098 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_ctx_alloc()
5101 + lib->request_data_size); in nxt_unit_ctx_alloc()
5108 rc = nxt_unit_ctx_init(lib, new_ctx, data); in nxt_unit_ctx_alloc()
5143 rc = nxt_unit_send_port(&new_ctx->ctx, lib->router_port, port, queue_fd); in nxt_unit_ctx_alloc()
5167 nxt_unit_impl_t *lib; in nxt_unit_ctx_free() local
5173 lib = nxt_container_of(ctx_impl->ctx.unit, nxt_unit_impl_t, unit); in nxt_unit_ctx_free()
5216 pthread_mutex_lock(&lib->mutex); in nxt_unit_ctx_free()
5220 pthread_mutex_unlock(&lib->mutex); in nxt_unit_ctx_free()
5223 nxt_unit_remove_port(lib, NULL, &ctx_impl->read_port->id); in nxt_unit_ctx_free()
5227 if (ctx_impl != &lib->main_ctx) { in nxt_unit_ctx_free()
5228 nxt_unit_free(&lib->main_ctx.ctx, ctx_impl); in nxt_unit_ctx_free()
5231 nxt_unit_lib_release(lib); in nxt_unit_ctx_free()
5261 nxt_unit_impl_t *lib; in nxt_unit_create_port() local
5265 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_create_port()
5296 pthread_mutex_lock(&lib->mutex); in nxt_unit_create_port()
5298 process = nxt_unit_process_get(ctx, lib->pid); in nxt_unit_create_port()
5300 pthread_mutex_unlock(&lib->mutex); in nxt_unit_create_port()
5308 nxt_unit_port_id_init(&new_port.id, lib->pid, process->next_port_id++); in nxt_unit_create_port()
5314 pthread_mutex_unlock(&lib->mutex); in nxt_unit_create_port()
5334 nxt_unit_impl_t *lib; in nxt_unit_send_port() local
5342 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_send_port()
5345 m.msg.pid = lib->pid; in nxt_unit_send_port()
5421 nxt_unit_impl_t *lib; in nxt_unit_add_port() local
5426 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_add_port()
5428 pthread_mutex_lock(&lib->mutex); in nxt_unit_add_port()
5430 old_port = nxt_unit_port_hash_find(&lib->ports, &port->id, 0); in nxt_unit_add_port()
5479 if (lib->callbacks.add_port == NULL && ready) { in nxt_unit_add_port()
5488 pthread_mutex_unlock(&lib->mutex); in nxt_unit_add_port()
5490 if (lib->callbacks.add_port != NULL && ready) { in nxt_unit_add_port()
5491 lib->callbacks.add_port(ctx, old_port); in nxt_unit_add_port()
5493 pthread_mutex_lock(&lib->mutex); in nxt_unit_add_port()
5502 pthread_mutex_unlock(&lib->mutex); in nxt_unit_add_port()
5538 rc = nxt_unit_port_hash_add(&lib->ports, &new_port->port); in nxt_unit_add_port()
5562 if (lib->callbacks.add_port == NULL) { in nxt_unit_add_port()
5573 pthread_mutex_unlock(&lib->mutex); in nxt_unit_add_port()
5579 if (lib->callbacks.add_port != NULL && new_port != NULL && ready) { in nxt_unit_add_port()
5580 lib->callbacks.add_port(ctx, &new_port->port); in nxt_unit_add_port()
5584 pthread_mutex_lock(&lib->mutex); in nxt_unit_add_port()
5593 pthread_mutex_unlock(&lib->mutex); in nxt_unit_add_port()
5632 nxt_unit_remove_port(nxt_unit_impl_t *lib, nxt_unit_ctx_t *ctx, in nxt_unit_remove_port() argument
5638 pthread_mutex_lock(&lib->mutex); in nxt_unit_remove_port()
5640 port = nxt_unit_remove_port_unsafe(lib, port_id); in nxt_unit_remove_port()
5648 pthread_mutex_unlock(&lib->mutex); in nxt_unit_remove_port()
5650 if (lib->callbacks.remove_port != NULL && port != NULL) { in nxt_unit_remove_port()
5651 lib->callbacks.remove_port(&lib->unit, ctx, port); in nxt_unit_remove_port()
5661 nxt_unit_remove_port_unsafe(nxt_unit_impl_t *lib, nxt_unit_port_id_t *port_id) in nxt_unit_remove_port_unsafe() argument
5665 port = nxt_unit_port_hash_find(&lib->ports, port_id, 1); in nxt_unit_remove_port_unsafe()
5682 nxt_unit_remove_pid(nxt_unit_impl_t *lib, pid_t pid) in nxt_unit_remove_pid() argument
5686 pthread_mutex_lock(&lib->mutex); in nxt_unit_remove_pid()
5688 process = nxt_unit_process_find(lib, pid, 1); in nxt_unit_remove_pid()
5692 pthread_mutex_unlock(&lib->mutex); in nxt_unit_remove_pid()
5697 nxt_unit_remove_process(lib, process); in nxt_unit_remove_pid()
5699 if (lib->callbacks.remove_pid != NULL) { in nxt_unit_remove_pid()
5700 lib->callbacks.remove_pid(&lib->unit, pid); in nxt_unit_remove_pid()
5706 nxt_unit_remove_process(nxt_unit_impl_t *lib, nxt_unit_process_t *process) in nxt_unit_remove_process() argument
5717 nxt_unit_remove_port_unsafe(lib, &port->port.id); in nxt_unit_remove_process()
5721 pthread_mutex_unlock(&lib->mutex); in nxt_unit_remove_process()
5727 if (lib->callbacks.remove_port != NULL) { in nxt_unit_remove_process()
5728 lib->callbacks.remove_port(&lib->unit, NULL, &port->port); in nxt_unit_remove_process()
5743 nxt_unit_impl_t *lib; in nxt_unit_quit() local
5754 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_quit()
5767 cb = &lib->callbacks; in nxt_unit_quit()
5773 cb->remove_port(&lib->unit, ctx, lib->shared_port); in nxt_unit_quit()
5817 nxt_unit_remove_port(lib, ctx, &ctx_impl->read_port->id); in nxt_unit_quit()
5821 if (ctx != &lib->main_ctx.ctx || skip_graceful_broadcast) { in nxt_unit_quit()
5827 m.msg.pid = lib->pid; in nxt_unit_quit()
5831 pthread_mutex_lock(&lib->mutex); in nxt_unit_quit()
5833 nxt_queue_each(ctx_impl, &lib->contexts, nxt_unit_ctx_impl_t, link) { in nxt_unit_quit()
5847 pthread_mutex_unlock(&lib->mutex); in nxt_unit_quit()
5855 nxt_unit_impl_t *lib; in nxt_unit_get_port() local
5863 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_get_port()
5868 m.msg.pid = lib->pid; in nxt_unit_get_port()
5878 res = nxt_unit_port_send(ctx, lib->router_port, &m, sizeof(m), NULL); in nxt_unit_get_port()
5895 nxt_unit_impl_t *lib; in nxt_unit_port_send() local
5898 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_port_send()
5921 if (lib->callbacks.port_send == NULL) { in nxt_unit_port_send()
5930 ret = lib->callbacks.port_send(ctx, port, &msg, in nxt_unit_port_send()
5958 if (lib->callbacks.port_send != NULL) { in nxt_unit_port_send()
5959 ret = lib->callbacks.port_send(ctx, port, buf, buf_size, in nxt_unit_port_send()
6182 nxt_unit_impl_t *lib; in nxt_unit_port_recv() local
6184 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_port_recv()
6186 if (lib->callbacks.port_recv != NULL) { in nxt_unit_port_recv()
6189 rbuf->size = lib->callbacks.port_recv(ctx, port, in nxt_unit_port_recv()
6259 nxt_unit_impl_t *lib; in nxt_unit_app_queue_recv() local
6280 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_app_queue_recv()
6282 if (lib->request_limit != 0) { in nxt_unit_app_queue_recv()
6283 nxt_atomic_fetch_add(&lib->request_count, 1); in nxt_unit_app_queue_recv()
6285 if (nxt_slow_path(lib->request_count >= lib->request_limit)) { in nxt_unit_app_queue_recv()
6290 m.msg.pid = lib->pid; in nxt_unit_app_queue_recv()
6294 (void) nxt_unit_port_send(ctx, lib->main_ctx.read_port, in nxt_unit_app_queue_recv()
6571 nxt_unit_impl_t *lib; in nxt_unit_log() local
6574 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_log()
6576 pid = lib->pid; in nxt_unit_log()
6577 log_fd = lib->log_fd; in nxt_unit_log()
6614 nxt_unit_impl_t *lib; in nxt_unit_req_log() local
6618 lib = nxt_container_of(req->ctx->unit, nxt_unit_impl_t, unit); in nxt_unit_req_log()
6620 pid = lib->pid; in nxt_unit_req_log()
6621 log_fd = lib->log_fd; in nxt_unit_req_log()