Lines Matching refs:rbuf

63 static int nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf,
97 nxt_unit_read_buf_t *rbuf);
125 nxt_port_mmap_header_t **hdr, nxt_unit_read_buf_t *rbuf);
127 nxt_unit_recv_msg_t *recv_msg, nxt_unit_read_buf_t *rbuf);
138 static int nxt_unit_read_buf(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf);
142 nxt_inline int nxt_unit_is_read_queue(nxt_unit_read_buf_t *rbuf);
143 nxt_inline int nxt_unit_is_read_socket(nxt_unit_read_buf_t *rbuf);
144 nxt_inline int nxt_unit_is_shm_ack(nxt_unit_read_buf_t *rbuf);
145 nxt_inline int nxt_unit_is_quit(nxt_unit_read_buf_t *rbuf);
175 nxt_unit_read_buf_t *rbuf);
179 nxt_unit_read_buf_t *rbuf);
181 nxt_unit_read_buf_t *rbuf);
183 nxt_unit_read_buf_t *rbuf);
185 nxt_unit_read_buf_t *rbuf);
973 nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf, in nxt_unit_process_msg() argument
989 rc = nxt_socket_msg_oob_get_fds(&rbuf->oob, recv_msg.fd); in nxt_unit_process_msg()
996 if (nxt_slow_path(rbuf->size < (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_process_msg()
997 if (nxt_slow_path(rbuf->size == 0)) { in nxt_unit_process_msg()
1005 nxt_unit_alert(ctx, "message too small (%d bytes)", (int) rbuf->size); in nxt_unit_process_msg()
1011 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_process_msg()
1024 recv_msg.size = rbuf->size - sizeof(nxt_port_msg_t); in nxt_unit_process_msg()
1042 rc = nxt_unit_mmap_read(ctx, &recv_msg, rbuf); in nxt_unit_process_msg()
1172 memset(rbuf->buf, 0xAC, rbuf->size); in nxt_unit_process_msg()
1174 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_process_msg()
2787 nxt_unit_read_buf_t *rbuf; in nxt_unit_read_buf_get() local
2793 rbuf = nxt_unit_read_buf_get_impl(ctx_impl); in nxt_unit_read_buf_get()
2797 rbuf->oob.size = 0; in nxt_unit_read_buf_get()
2799 return rbuf; in nxt_unit_read_buf_get()
2807 nxt_unit_read_buf_t *rbuf; in nxt_unit_read_buf_get_impl() local
2813 rbuf = nxt_container_of(link, nxt_unit_read_buf_t, link); in nxt_unit_read_buf_get_impl()
2815 return rbuf; in nxt_unit_read_buf_get_impl()
2818 rbuf = nxt_unit_malloc(&ctx_impl->ctx, sizeof(nxt_unit_read_buf_t)); in nxt_unit_read_buf_get_impl()
2820 if (nxt_fast_path(rbuf != NULL)) { in nxt_unit_read_buf_get_impl()
2821 rbuf->ctx_impl = ctx_impl; in nxt_unit_read_buf_get_impl()
2824 return rbuf; in nxt_unit_read_buf_get_impl()
2830 nxt_unit_read_buf_t *rbuf) in nxt_unit_read_buf_release() argument
2838 nxt_queue_insert_head(&ctx_impl->free_rbuf, &rbuf->link); in nxt_unit_read_buf_release()
3649 nxt_unit_read_buf_t *rbuf; in nxt_unit_wait_shm_ack() local
3654 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_wait_shm_ack()
3655 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_wait_shm_ack()
3660 res = nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_wait_shm_ack()
3664 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_wait_shm_ack()
3669 if (nxt_unit_is_shm_ack(rbuf)) { in nxt_unit_wait_shm_ack()
3670 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_wait_shm_ack()
3676 nxt_queue_insert_tail(&ctx_impl->pending_rbuf, &rbuf->link); in nxt_unit_wait_shm_ack()
3680 if (nxt_unit_is_quit(rbuf)) { in nxt_unit_wait_shm_ack()
4008 nxt_unit_read_buf_t *rbuf; in nxt_unit_incoming_mmap() local
4069 nxt_queue_each(rbuf, &awaiting_rbuf, nxt_unit_read_buf_t, link) { in nxt_unit_incoming_mmap()
4071 ctx_impl = rbuf->ctx_impl; in nxt_unit_incoming_mmap()
4075 nxt_queue_insert_head(&ctx_impl->pending_rbuf, &rbuf->link); in nxt_unit_incoming_mmap()
4171 nxt_unit_read_buf_t *rbuf) in nxt_unit_check_rbuf_mmap() argument
4196 nxt_queue_insert_tail(&mm->awaiting_rbuf, &rbuf->link); in nxt_unit_check_rbuf_mmap()
4217 nxt_unit_read_buf_t *rbuf) in nxt_unit_mmap_read() argument
4270 &hdr, rbuf); in nxt_unit_mmap_read()
4579 nxt_unit_read_buf_t *rbuf; in nxt_unit_run_once_impl() local
4581 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_run_once_impl()
4582 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_run_once_impl()
4586 rc = nxt_unit_read_buf(ctx, rbuf); in nxt_unit_run_once_impl()
4588 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_run_once_impl()
4593 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_run_once_impl()
4610 nxt_unit_read_buf(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf) in nxt_unit_read_buf() argument
4622 return nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_read_buf()
4633 res = nxt_unit_port_queue_recv(ctx_impl->read_port, rbuf); in nxt_unit_read_buf()
4635 if (nxt_unit_is_read_socket(rbuf)) { in nxt_unit_read_buf()
4647 (int) rbuf->size); in nxt_unit_read_buf()
4655 res = nxt_unit_app_queue_recv(ctx, lib->shared_port, rbuf); in nxt_unit_read_buf()
4686 rbuf->size = -1; in nxt_unit_read_buf()
4696 res = nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_read_buf()
4705 res = nxt_unit_shared_port_recv(ctx, lib->shared_port, rbuf); in nxt_unit_read_buf()
4742 nxt_unit_read_buf_t *rbuf; in nxt_unit_process_pending_rbuf() local
4763 nxt_queue_each(rbuf, &pending_rbuf, nxt_unit_read_buf_t, link) { in nxt_unit_process_pending_rbuf()
4766 rc = nxt_unit_process_msg(&ctx_impl->ctx, rbuf, NULL); in nxt_unit_process_pending_rbuf()
4769 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_process_pending_rbuf()
4854 nxt_unit_read_buf_t *rbuf; in nxt_unit_run_ctx() local
4864 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_run_ctx()
4865 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_run_ctx()
4872 rc = nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_run_ctx()
4877 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_run_ctx()
4897 nxt_unit_is_read_queue(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_read_queue() argument
4901 if (nxt_fast_path(rbuf->size == (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_is_read_queue()
4902 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_is_read_queue()
4912 nxt_unit_is_read_socket(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_read_socket() argument
4914 if (nxt_fast_path(rbuf->size == 1)) { in nxt_unit_is_read_socket()
4915 return rbuf->buf[0] == _NXT_PORT_MSG_READ_SOCKET; in nxt_unit_is_read_socket()
4923 nxt_unit_is_shm_ack(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_shm_ack() argument
4927 if (nxt_fast_path(rbuf->size == (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_is_shm_ack()
4928 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_is_shm_ack()
4938 nxt_unit_is_quit(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_quit() argument
4942 if (nxt_fast_path(rbuf->size == (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_is_quit()
4943 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_is_quit()
4957 nxt_unit_read_buf_t *rbuf; in nxt_unit_run_shared() local
4966 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_run_shared()
4967 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_run_shared()
4974 rc = nxt_unit_shared_port_recv(ctx, lib->shared_port, rbuf); in nxt_unit_run_shared()
4980 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_run_shared()
4984 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_run_shared()
5001 nxt_unit_read_buf_t *rbuf; in nxt_unit_dequeue_request() local
5014 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_dequeue_request()
5015 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_dequeue_request()
5019 rc = nxt_unit_app_queue_recv(ctx, lib->shared_port, rbuf); in nxt_unit_dequeue_request()
5021 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_dequeue_request()
5025 (void) nxt_unit_process_msg(ctx, rbuf, &req); in nxt_unit_dequeue_request()
5055 nxt_unit_read_buf_t *rbuf; in nxt_unit_process_port_msg_impl() local
5063 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_process_port_msg_impl()
5064 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_process_port_msg_impl()
5069 rc = nxt_unit_shared_port_recv(ctx, port, rbuf); in nxt_unit_process_port_msg_impl()
5072 rc = nxt_unit_ctx_port_recv(ctx, port, rbuf); in nxt_unit_process_port_msg_impl()
5076 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_process_port_msg_impl()
5080 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_process_port_msg_impl()
5184 nxt_unit_read_buf_t *rbuf; in nxt_unit_ctx_free() local
5222 nxt_queue_each(rbuf, &ctx_impl->free_rbuf, nxt_unit_read_buf_t, link) in nxt_unit_ctx_free()
5224 if (rbuf != &ctx_impl->ctx_read_buf) { in nxt_unit_ctx_free()
5225 nxt_unit_free(&ctx_impl->ctx, rbuf); in nxt_unit_ctx_free()
6034 nxt_unit_read_buf_t *rbuf) in nxt_unit_ctx_port_recv() argument
6051 nxt_unit_rbuf_cpy(rbuf, port_impl->socket_rbuf); in nxt_unit_ctx_port_recv()
6056 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6062 res = nxt_unit_port_queue_recv(port, rbuf); in nxt_unit_ctx_port_recv()
6065 if (nxt_unit_is_read_socket(rbuf)) { in nxt_unit_ctx_port_recv()
6077 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6087 res = nxt_unit_port_recv(ctx, port, rbuf); in nxt_unit_ctx_port_recv()
6094 if (nxt_unit_is_read_queue(rbuf)) { in nxt_unit_ctx_port_recv()
6096 (int) port->id.pid, (int) port->id.id, (int) rbuf->size); in nxt_unit_ctx_port_recv()
6103 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6117 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6135 nxt_unit_rbuf_cpy(port_impl->socket_rbuf, rbuf); in nxt_unit_ctx_port_recv()
6137 rbuf->oob.size = 0; in nxt_unit_ctx_port_recv()
6155 nxt_unit_read_buf_t *rbuf) in nxt_unit_shared_port_recv() argument
6164 res = nxt_unit_app_queue_recv(ctx, port, rbuf); in nxt_unit_shared_port_recv()
6171 res = nxt_unit_port_recv(ctx, port, rbuf); in nxt_unit_shared_port_recv()
6176 if (nxt_unit_is_read_queue(rbuf)) { in nxt_unit_shared_port_recv()
6180 (int) port->id.pid, (int) port->id.id, (int) rbuf->size); in nxt_unit_shared_port_recv()
6192 nxt_unit_read_buf_t *rbuf) in nxt_unit_port_recv() argument
6202 oob_size = sizeof(rbuf->oob.buf); in nxt_unit_port_recv()
6204 rbuf->size = lib->callbacks.port_recv(ctx, port, in nxt_unit_port_recv()
6205 rbuf->buf, sizeof(rbuf->buf), in nxt_unit_port_recv()
6206 rbuf->oob.buf, &oob_size); in nxt_unit_port_recv()
6209 (int) port->id.pid, (int) port->id.id, (int) rbuf->size); in nxt_unit_port_recv()
6211 if (nxt_slow_path(rbuf->size < 0)) { in nxt_unit_port_recv()
6215 rbuf->oob.size = oob_size; in nxt_unit_port_recv()
6219 iov[0].iov_base = rbuf->buf; in nxt_unit_port_recv()
6220 iov[0].iov_len = sizeof(rbuf->buf); in nxt_unit_port_recv()
6226 rbuf->size = nxt_recvmsg(fd, iov, 1, &rbuf->oob); in nxt_unit_port_recv()
6228 if (nxt_slow_path(rbuf->size == -1)) { in nxt_unit_port_recv()
6248 nxt_unit_debug(ctx, "recvmsg(%d): %d", fd, (int) rbuf->size); in nxt_unit_port_recv()
6255 nxt_unit_port_queue_recv(nxt_unit_port_t *port, nxt_unit_read_buf_t *rbuf) in nxt_unit_port_queue_recv() argument
6261 rbuf->size = nxt_port_queue_recv(port_impl->queue, rbuf->buf); in nxt_unit_port_queue_recv()
6263 return (rbuf->size == -1) ? NXT_UNIT_AGAIN : NXT_UNIT_OK; in nxt_unit_port_queue_recv()
6269 nxt_unit_read_buf_t *rbuf) in nxt_unit_app_queue_recv() argument
6287 rbuf->size = nxt_app_queue_recv(queue, rbuf->buf, &cookie); in nxt_unit_app_queue_recv()
6289 nxt_unit_debug(NULL, "app_queue_recv: %d", (int) rbuf->size); in nxt_unit_app_queue_recv()
6291 if (rbuf->size >= (ssize_t) sizeof(nxt_port_msg_t)) { in nxt_unit_app_queue_recv()
6292 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_app_queue_recv()
6322 return (rbuf->size == -1) ? NXT_UNIT_AGAIN : NXT_UNIT_OK; in nxt_unit_app_queue_recv()