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);
959 nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf, in nxt_unit_process_msg() argument
975 rc = nxt_socket_msg_oob_get_fds(&rbuf->oob, recv_msg.fd); in nxt_unit_process_msg()
982 if (nxt_slow_path(rbuf->size < (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_process_msg()
983 if (nxt_slow_path(rbuf->size == 0)) { in nxt_unit_process_msg()
991 nxt_unit_alert(ctx, "message too small (%d bytes)", (int) rbuf->size); in nxt_unit_process_msg()
997 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_process_msg()
1010 recv_msg.size = rbuf->size - sizeof(nxt_port_msg_t); in nxt_unit_process_msg()
1028 rc = nxt_unit_mmap_read(ctx, &recv_msg, rbuf); in nxt_unit_process_msg()
1158 memset(rbuf->buf, 0xAC, rbuf->size); in nxt_unit_process_msg()
1160 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_process_msg()
2772 nxt_unit_read_buf_t *rbuf; in nxt_unit_read_buf_get() local
2778 rbuf = nxt_unit_read_buf_get_impl(ctx_impl); in nxt_unit_read_buf_get()
2782 rbuf->oob.size = 0; in nxt_unit_read_buf_get()
2784 return rbuf; in nxt_unit_read_buf_get()
2792 nxt_unit_read_buf_t *rbuf; in nxt_unit_read_buf_get_impl() local
2798 rbuf = nxt_container_of(link, nxt_unit_read_buf_t, link); in nxt_unit_read_buf_get_impl()
2800 return rbuf; in nxt_unit_read_buf_get_impl()
2803 rbuf = nxt_unit_malloc(&ctx_impl->ctx, sizeof(nxt_unit_read_buf_t)); in nxt_unit_read_buf_get_impl()
2805 if (nxt_fast_path(rbuf != NULL)) { in nxt_unit_read_buf_get_impl()
2806 rbuf->ctx_impl = ctx_impl; in nxt_unit_read_buf_get_impl()
2809 return rbuf; in nxt_unit_read_buf_get_impl()
2815 nxt_unit_read_buf_t *rbuf) in nxt_unit_read_buf_release() argument
2823 nxt_queue_insert_head(&ctx_impl->free_rbuf, &rbuf->link); in nxt_unit_read_buf_release()
3634 nxt_unit_read_buf_t *rbuf; in nxt_unit_wait_shm_ack() local
3639 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_wait_shm_ack()
3640 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_wait_shm_ack()
3645 res = nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_wait_shm_ack()
3649 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_wait_shm_ack()
3654 if (nxt_unit_is_shm_ack(rbuf)) { in nxt_unit_wait_shm_ack()
3655 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_wait_shm_ack()
3661 nxt_queue_insert_tail(&ctx_impl->pending_rbuf, &rbuf->link); in nxt_unit_wait_shm_ack()
3665 if (nxt_unit_is_quit(rbuf)) { in nxt_unit_wait_shm_ack()
3993 nxt_unit_read_buf_t *rbuf; in nxt_unit_incoming_mmap() local
4054 nxt_queue_each(rbuf, &awaiting_rbuf, nxt_unit_read_buf_t, link) { in nxt_unit_incoming_mmap()
4056 ctx_impl = rbuf->ctx_impl; in nxt_unit_incoming_mmap()
4060 nxt_queue_insert_head(&ctx_impl->pending_rbuf, &rbuf->link); in nxt_unit_incoming_mmap()
4156 nxt_unit_read_buf_t *rbuf) in nxt_unit_check_rbuf_mmap() argument
4181 nxt_queue_insert_tail(&mm->awaiting_rbuf, &rbuf->link); in nxt_unit_check_rbuf_mmap()
4202 nxt_unit_read_buf_t *rbuf) in nxt_unit_mmap_read() argument
4255 &hdr, rbuf); in nxt_unit_mmap_read()
4564 nxt_unit_read_buf_t *rbuf; in nxt_unit_run_once_impl() local
4566 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_run_once_impl()
4567 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_run_once_impl()
4571 rc = nxt_unit_read_buf(ctx, rbuf); in nxt_unit_run_once_impl()
4573 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_run_once_impl()
4578 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_run_once_impl()
4595 nxt_unit_read_buf(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf) in nxt_unit_read_buf() argument
4607 return nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_read_buf()
4618 res = nxt_unit_port_queue_recv(ctx_impl->read_port, rbuf); in nxt_unit_read_buf()
4620 if (nxt_unit_is_read_socket(rbuf)) { in nxt_unit_read_buf()
4632 (int) rbuf->size); in nxt_unit_read_buf()
4640 res = nxt_unit_app_queue_recv(ctx, lib->shared_port, rbuf); in nxt_unit_read_buf()
4671 rbuf->size = -1; in nxt_unit_read_buf()
4681 res = nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_read_buf()
4690 res = nxt_unit_shared_port_recv(ctx, lib->shared_port, rbuf); in nxt_unit_read_buf()
4727 nxt_unit_read_buf_t *rbuf; in nxt_unit_process_pending_rbuf() local
4748 nxt_queue_each(rbuf, &pending_rbuf, nxt_unit_read_buf_t, link) { in nxt_unit_process_pending_rbuf()
4751 rc = nxt_unit_process_msg(&ctx_impl->ctx, rbuf, NULL); in nxt_unit_process_pending_rbuf()
4754 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_process_pending_rbuf()
4839 nxt_unit_read_buf_t *rbuf; in nxt_unit_run_ctx() local
4849 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_run_ctx()
4850 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_run_ctx()
4857 rc = nxt_unit_ctx_port_recv(ctx, ctx_impl->read_port, rbuf); in nxt_unit_run_ctx()
4862 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_run_ctx()
4882 nxt_unit_is_read_queue(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_read_queue() argument
4886 if (nxt_fast_path(rbuf->size == (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_is_read_queue()
4887 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_is_read_queue()
4897 nxt_unit_is_read_socket(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_read_socket() argument
4899 if (nxt_fast_path(rbuf->size == 1)) { in nxt_unit_is_read_socket()
4900 return rbuf->buf[0] == _NXT_PORT_MSG_READ_SOCKET; in nxt_unit_is_read_socket()
4908 nxt_unit_is_shm_ack(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_shm_ack() argument
4912 if (nxt_fast_path(rbuf->size == (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_is_shm_ack()
4913 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_is_shm_ack()
4923 nxt_unit_is_quit(nxt_unit_read_buf_t *rbuf) in nxt_unit_is_quit() argument
4927 if (nxt_fast_path(rbuf->size == (ssize_t) sizeof(nxt_port_msg_t))) { in nxt_unit_is_quit()
4928 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_is_quit()
4942 nxt_unit_read_buf_t *rbuf; in nxt_unit_run_shared() local
4951 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_run_shared()
4952 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_run_shared()
4959 rc = nxt_unit_shared_port_recv(ctx, lib->shared_port, rbuf); in nxt_unit_run_shared()
4965 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_run_shared()
4969 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_run_shared()
4986 nxt_unit_read_buf_t *rbuf; in nxt_unit_dequeue_request() local
4999 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_dequeue_request()
5000 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_dequeue_request()
5004 rc = nxt_unit_app_queue_recv(ctx, lib->shared_port, rbuf); in nxt_unit_dequeue_request()
5006 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_dequeue_request()
5010 (void) nxt_unit_process_msg(ctx, rbuf, &req); in nxt_unit_dequeue_request()
5040 nxt_unit_read_buf_t *rbuf; in nxt_unit_process_port_msg_impl() local
5048 rbuf = nxt_unit_read_buf_get(ctx); in nxt_unit_process_port_msg_impl()
5049 if (nxt_slow_path(rbuf == NULL)) { in nxt_unit_process_port_msg_impl()
5054 rc = nxt_unit_shared_port_recv(ctx, port, rbuf); in nxt_unit_process_port_msg_impl()
5057 rc = nxt_unit_ctx_port_recv(ctx, port, rbuf); in nxt_unit_process_port_msg_impl()
5061 nxt_unit_read_buf_release(ctx, rbuf); in nxt_unit_process_port_msg_impl()
5065 rc = nxt_unit_process_msg(ctx, rbuf, NULL); in nxt_unit_process_port_msg_impl()
5169 nxt_unit_read_buf_t *rbuf; in nxt_unit_ctx_free() local
5207 nxt_queue_each(rbuf, &ctx_impl->free_rbuf, nxt_unit_read_buf_t, link) in nxt_unit_ctx_free()
5209 if (rbuf != &ctx_impl->ctx_read_buf) { in nxt_unit_ctx_free()
5210 nxt_unit_free(&ctx_impl->ctx, rbuf); in nxt_unit_ctx_free()
6019 nxt_unit_read_buf_t *rbuf) in nxt_unit_ctx_port_recv() argument
6036 nxt_unit_rbuf_cpy(rbuf, port_impl->socket_rbuf); in nxt_unit_ctx_port_recv()
6041 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6047 res = nxt_unit_port_queue_recv(port, rbuf); in nxt_unit_ctx_port_recv()
6050 if (nxt_unit_is_read_socket(rbuf)) { in nxt_unit_ctx_port_recv()
6062 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6072 res = nxt_unit_port_recv(ctx, port, rbuf); in nxt_unit_ctx_port_recv()
6079 if (nxt_unit_is_read_queue(rbuf)) { in nxt_unit_ctx_port_recv()
6081 (int) port->id.pid, (int) port->id.id, (int) rbuf->size); in nxt_unit_ctx_port_recv()
6088 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6102 (int) rbuf->size); in nxt_unit_ctx_port_recv()
6120 nxt_unit_rbuf_cpy(port_impl->socket_rbuf, rbuf); in nxt_unit_ctx_port_recv()
6122 rbuf->oob.size = 0; in nxt_unit_ctx_port_recv()
6140 nxt_unit_read_buf_t *rbuf) in nxt_unit_shared_port_recv() argument
6149 res = nxt_unit_app_queue_recv(ctx, port, rbuf); in nxt_unit_shared_port_recv()
6156 res = nxt_unit_port_recv(ctx, port, rbuf); in nxt_unit_shared_port_recv()
6161 if (nxt_unit_is_read_queue(rbuf)) { in nxt_unit_shared_port_recv()
6165 (int) port->id.pid, (int) port->id.id, (int) rbuf->size); in nxt_unit_shared_port_recv()
6177 nxt_unit_read_buf_t *rbuf) in nxt_unit_port_recv() argument
6187 oob_size = sizeof(rbuf->oob.buf); in nxt_unit_port_recv()
6189 rbuf->size = lib->callbacks.port_recv(ctx, port, in nxt_unit_port_recv()
6190 rbuf->buf, sizeof(rbuf->buf), in nxt_unit_port_recv()
6191 rbuf->oob.buf, &oob_size); in nxt_unit_port_recv()
6194 (int) port->id.pid, (int) port->id.id, (int) rbuf->size); in nxt_unit_port_recv()
6196 if (nxt_slow_path(rbuf->size < 0)) { in nxt_unit_port_recv()
6200 rbuf->oob.size = oob_size; in nxt_unit_port_recv()
6204 iov[0].iov_base = rbuf->buf; in nxt_unit_port_recv()
6205 iov[0].iov_len = sizeof(rbuf->buf); in nxt_unit_port_recv()
6211 rbuf->size = nxt_recvmsg(fd, iov, 1, &rbuf->oob); in nxt_unit_port_recv()
6213 if (nxt_slow_path(rbuf->size == -1)) { in nxt_unit_port_recv()
6233 nxt_unit_debug(ctx, "recvmsg(%d): %d", fd, (int) rbuf->size); in nxt_unit_port_recv()
6240 nxt_unit_port_queue_recv(nxt_unit_port_t *port, nxt_unit_read_buf_t *rbuf) in nxt_unit_port_queue_recv() argument
6246 rbuf->size = nxt_port_queue_recv(port_impl->queue, rbuf->buf); in nxt_unit_port_queue_recv()
6248 return (rbuf->size == -1) ? NXT_UNIT_AGAIN : NXT_UNIT_OK; in nxt_unit_port_queue_recv()
6254 nxt_unit_read_buf_t *rbuf) in nxt_unit_app_queue_recv() argument
6272 rbuf->size = nxt_app_queue_recv(queue, rbuf->buf, &cookie); in nxt_unit_app_queue_recv()
6274 nxt_unit_debug(NULL, "app_queue_recv: %d", (int) rbuf->size); in nxt_unit_app_queue_recv()
6276 if (rbuf->size >= (ssize_t) sizeof(nxt_port_msg_t)) { in nxt_unit_app_queue_recv()
6277 port_msg = (nxt_port_msg_t *) rbuf->buf; in nxt_unit_app_queue_recv()
6307 return (rbuf->size == -1) ? NXT_UNIT_AGAIN : NXT_UNIT_OK; in nxt_unit_app_queue_recv()