Lines Matching refs:mmap_buf

52     nxt_unit_mmap_buf_t *mmap_buf);
54 nxt_unit_mmap_buf_t *mmap_buf);
55 nxt_inline void nxt_unit_mmap_buf_unlink(nxt_unit_mmap_buf_t *mmap_buf);
88 static void nxt_unit_mmap_buf_release(nxt_unit_mmap_buf_t *mmap_buf);
90 nxt_unit_mmap_buf_t *mmap_buf, int last);
91 static void nxt_unit_mmap_buf_free(nxt_unit_mmap_buf_t *mmap_buf);
92 static void nxt_unit_free_outgoing_buf(nxt_unit_mmap_buf_t *mmap_buf);
114 uint32_t min_size, nxt_unit_mmap_buf_t *mmap_buf, char *local_buf);
787 nxt_unit_mmap_buf_t *mmap_buf) in nxt_unit_mmap_buf_insert() argument
789 mmap_buf->next = *head; in nxt_unit_mmap_buf_insert()
791 if (mmap_buf->next != NULL) { in nxt_unit_mmap_buf_insert()
792 mmap_buf->next->prev = &mmap_buf->next; in nxt_unit_mmap_buf_insert()
795 *head = mmap_buf; in nxt_unit_mmap_buf_insert()
796 mmap_buf->prev = head; in nxt_unit_mmap_buf_insert()
802 nxt_unit_mmap_buf_t *mmap_buf) in nxt_unit_mmap_buf_insert_tail() argument
808 nxt_unit_mmap_buf_insert(prev, mmap_buf); in nxt_unit_mmap_buf_insert_tail()
813 nxt_unit_mmap_buf_unlink(nxt_unit_mmap_buf_t *mmap_buf) in nxt_unit_mmap_buf_unlink() argument
817 prev = mmap_buf->prev; in nxt_unit_mmap_buf_unlink()
819 if (mmap_buf->next != NULL) { in nxt_unit_mmap_buf_unlink()
820 mmap_buf->next->prev = prev; in nxt_unit_mmap_buf_unlink()
824 *prev = mmap_buf->next; in nxt_unit_mmap_buf_unlink()
2335 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_response_send() local
2361 mmap_buf = nxt_container_of(req->response_buf, nxt_unit_mmap_buf_t, buf); in nxt_unit_response_send()
2363 rc = nxt_unit_mmap_buf_send(req, mmap_buf, 0); in nxt_unit_response_send()
2369 nxt_unit_mmap_buf_free(mmap_buf); in nxt_unit_response_send()
2391 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_response_buf_alloc() local
2405 mmap_buf = nxt_unit_mmap_buf_get(req->ctx); in nxt_unit_response_buf_alloc()
2406 if (nxt_slow_path(mmap_buf == NULL)) { in nxt_unit_response_buf_alloc()
2412 mmap_buf->req = req; in nxt_unit_response_buf_alloc()
2414 nxt_unit_mmap_buf_insert_tail(&req_impl->outgoing_buf, mmap_buf); in nxt_unit_response_buf_alloc()
2417 size, size, mmap_buf, in nxt_unit_response_buf_alloc()
2420 nxt_unit_mmap_buf_release(mmap_buf); in nxt_unit_response_buf_alloc()
2427 return &mmap_buf->buf; in nxt_unit_response_buf_alloc()
2434 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_mmap_buf_get() local
2444 mmap_buf = nxt_unit_malloc(ctx, sizeof(nxt_unit_mmap_buf_t)); in nxt_unit_mmap_buf_get()
2445 if (nxt_slow_path(mmap_buf == NULL)) { in nxt_unit_mmap_buf_get()
2450 mmap_buf = ctx_impl->free_buf; in nxt_unit_mmap_buf_get()
2452 nxt_unit_mmap_buf_unlink(mmap_buf); in nxt_unit_mmap_buf_get()
2457 mmap_buf->ctx_impl = ctx_impl; in nxt_unit_mmap_buf_get()
2459 mmap_buf->hdr = NULL; in nxt_unit_mmap_buf_get()
2460 mmap_buf->free_ptr = NULL; in nxt_unit_mmap_buf_get()
2462 return mmap_buf; in nxt_unit_mmap_buf_get()
2467 nxt_unit_mmap_buf_release(nxt_unit_mmap_buf_t *mmap_buf) in nxt_unit_mmap_buf_release() argument
2469 nxt_unit_mmap_buf_unlink(mmap_buf); in nxt_unit_mmap_buf_release()
2471 pthread_mutex_lock(&mmap_buf->ctx_impl->mutex); in nxt_unit_mmap_buf_release()
2473 nxt_unit_mmap_buf_insert(&mmap_buf->ctx_impl->free_buf, mmap_buf); in nxt_unit_mmap_buf_release()
2475 pthread_mutex_unlock(&mmap_buf->ctx_impl->mutex); in nxt_unit_mmap_buf_release()
2553 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_buf_send() local
2557 mmap_buf = nxt_container_of(buf, nxt_unit_mmap_buf_t, buf); in nxt_unit_buf_send()
2559 req = mmap_buf->req; in nxt_unit_buf_send()
2578 rc = nxt_unit_mmap_buf_send(req, mmap_buf, 0); in nxt_unit_buf_send()
2584 nxt_unit_mmap_buf_free(mmap_buf); in nxt_unit_buf_send()
2594 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_buf_send_done() local
2597 mmap_buf = nxt_container_of(buf, nxt_unit_mmap_buf_t, buf); in nxt_unit_buf_send_done()
2599 req = mmap_buf->req; in nxt_unit_buf_send_done()
2601 rc = nxt_unit_mmap_buf_send(req, mmap_buf, 1); in nxt_unit_buf_send_done()
2603 nxt_unit_mmap_buf_free(mmap_buf); in nxt_unit_buf_send_done()
2615 nxt_unit_mmap_buf_t *mmap_buf, int last) in nxt_unit_mmap_buf_send() argument
2634 buf = &mmap_buf->buf; in nxt_unit_mmap_buf_send()
2635 hdr = mmap_buf->hdr; in nxt_unit_mmap_buf_send()
2685 mmap_buf->hdr = NULL; in nxt_unit_mmap_buf_send()
2695 if (nxt_slow_path(mmap_buf->plain_ptr == NULL in nxt_unit_mmap_buf_send()
2696 || mmap_buf->plain_ptr > buf->start - sizeof(m.msg))) in nxt_unit_mmap_buf_send()
2725 nxt_unit_free_outgoing_buf(mmap_buf); in nxt_unit_mmap_buf_send()
2739 nxt_unit_mmap_buf_free(nxt_unit_mmap_buf_t *mmap_buf) in nxt_unit_mmap_buf_free() argument
2741 nxt_unit_free_outgoing_buf(mmap_buf); in nxt_unit_mmap_buf_free()
2743 nxt_unit_mmap_buf_release(mmap_buf); in nxt_unit_mmap_buf_free()
2748 nxt_unit_free_outgoing_buf(nxt_unit_mmap_buf_t *mmap_buf) in nxt_unit_free_outgoing_buf() argument
2750 if (mmap_buf->hdr != NULL) { in nxt_unit_free_outgoing_buf()
2751 nxt_unit_mmap_release(&mmap_buf->ctx_impl->ctx, in nxt_unit_free_outgoing_buf()
2752 mmap_buf->hdr, mmap_buf->buf.start, in nxt_unit_free_outgoing_buf()
2753 mmap_buf->buf.end - mmap_buf->buf.start); in nxt_unit_free_outgoing_buf()
2755 mmap_buf->hdr = NULL; in nxt_unit_free_outgoing_buf()
2760 if (mmap_buf->free_ptr != NULL) { in nxt_unit_free_outgoing_buf()
2761 nxt_unit_free(&mmap_buf->ctx_impl->ctx, mmap_buf->free_ptr); in nxt_unit_free_outgoing_buf()
2763 mmap_buf->free_ptr = NULL; in nxt_unit_free_outgoing_buf()
2832 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_buf_next() local
2834 mmap_buf = nxt_container_of(buf, nxt_unit_mmap_buf_t, buf); in nxt_unit_buf_next()
2836 if (mmap_buf->next == NULL) { in nxt_unit_buf_next()
2840 return &mmap_buf->next->buf; in nxt_unit_buf_next()
2878 nxt_unit_mmap_buf_t mmap_buf; in nxt_unit_response_write_nb() local
2923 min_part_size, &mmap_buf, local_buf); in nxt_unit_response_write_nb()
2928 buf_size = mmap_buf.buf.end - mmap_buf.buf.free; in nxt_unit_response_write_nb()
2934 mmap_buf.buf.free = nxt_cpymem(mmap_buf.buf.free, in nxt_unit_response_write_nb()
2937 rc = nxt_unit_mmap_buf_send(req, &mmap_buf, 0); in nxt_unit_response_write_nb()
2961 nxt_unit_mmap_buf_t mmap_buf; in nxt_unit_response_write_cb() local
3023 &mmap_buf, local_buf); in nxt_unit_response_write_cb()
3028 buf = &mmap_buf.buf; in nxt_unit_response_write_cb()
3035 nxt_unit_free_outgoing_buf(&mmap_buf); in nxt_unit_response_write_cb()
3043 rc = nxt_unit_mmap_buf_send(req, &mmap_buf, 0); in nxt_unit_response_write_cb()
3096 nxt_unit_mmap_buf_t *mmap_buf, *preread_buf; in nxt_unit_request_readline_size() local
3122 mmap_buf = nxt_container_of(b, nxt_unit_mmap_buf_t, buf); in nxt_unit_request_readline_size()
3123 if (mmap_buf->next == NULL in nxt_unit_request_readline_size()
3132 nxt_unit_mmap_buf_insert(&mmap_buf->next, preread_buf); in nxt_unit_request_readline_size()
3146 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_request_preread() local
3153 mmap_buf = nxt_unit_mmap_buf_get(req->ctx); in nxt_unit_request_preread()
3154 if (nxt_slow_path(mmap_buf == NULL)) { in nxt_unit_request_preread()
3159 mmap_buf->free_ptr = nxt_unit_malloc(req->ctx, size); in nxt_unit_request_preread()
3160 if (nxt_slow_path(mmap_buf->free_ptr == NULL)) { in nxt_unit_request_preread()
3162 nxt_unit_mmap_buf_release(mmap_buf); in nxt_unit_request_preread()
3166 mmap_buf->plain_ptr = mmap_buf->free_ptr; in nxt_unit_request_preread()
3168 mmap_buf->hdr = NULL; in nxt_unit_request_preread()
3169 mmap_buf->buf.start = mmap_buf->free_ptr; in nxt_unit_request_preread()
3170 mmap_buf->buf.free = mmap_buf->buf.start; in nxt_unit_request_preread()
3171 mmap_buf->buf.end = mmap_buf->buf.start + size; in nxt_unit_request_preread()
3173 res = read(req->content_fd, mmap_buf->free_ptr, size); in nxt_unit_request_preread()
3178 nxt_unit_mmap_buf_free(mmap_buf); in nxt_unit_request_preread()
3191 mmap_buf->buf.end = mmap_buf->buf.free + res; in nxt_unit_request_preread()
3193 return mmap_buf; in nxt_unit_request_preread()
3324 nxt_unit_mmap_buf_t mmap_buf; in nxt_unit_websocket_sendv() local
3339 &mmap_buf, local_buf); in nxt_unit_websocket_sendv()
3344 buf = &mmap_buf.buf; in nxt_unit_websocket_sendv()
3371 rc = nxt_unit_mmap_buf_send(req, &mmap_buf, 0); in nxt_unit_websocket_sendv()
3382 &mmap_buf, local_buf); in nxt_unit_websocket_sendv()
3393 rc = nxt_unit_mmap_buf_send(req, &mmap_buf, 0); in nxt_unit_websocket_sendv()
3918 nxt_unit_mmap_buf_t *mmap_buf, char *local_buf) in nxt_unit_get_outgoing_buf() argument
3926 mmap_buf->free_ptr = NULL; in nxt_unit_get_outgoing_buf()
3927 mmap_buf->plain_ptr = local_buf; in nxt_unit_get_outgoing_buf()
3930 mmap_buf->free_ptr = nxt_unit_malloc(ctx, in nxt_unit_get_outgoing_buf()
3932 if (nxt_slow_path(mmap_buf->free_ptr == NULL)) { in nxt_unit_get_outgoing_buf()
3936 mmap_buf->plain_ptr = mmap_buf->free_ptr; in nxt_unit_get_outgoing_buf()
3939 mmap_buf->hdr = NULL; in nxt_unit_get_outgoing_buf()
3940 mmap_buf->buf.start = mmap_buf->plain_ptr + sizeof(nxt_port_msg_t); in nxt_unit_get_outgoing_buf()
3941 mmap_buf->buf.free = mmap_buf->buf.start; in nxt_unit_get_outgoing_buf()
3942 mmap_buf->buf.end = mmap_buf->buf.start + size; in nxt_unit_get_outgoing_buf()
3945 mmap_buf->buf.start, (int) size); in nxt_unit_get_outgoing_buf()
3956 mmap_buf->hdr = NULL; in nxt_unit_get_outgoing_buf()
3957 mmap_buf->buf.start = NULL; in nxt_unit_get_outgoing_buf()
3958 mmap_buf->buf.free = NULL; in nxt_unit_get_outgoing_buf()
3959 mmap_buf->buf.end = NULL; in nxt_unit_get_outgoing_buf()
3960 mmap_buf->free_ptr = NULL; in nxt_unit_get_outgoing_buf()
3968 mmap_buf->hdr = hdr; in nxt_unit_get_outgoing_buf()
3969 mmap_buf->buf.start = (char *) nxt_port_mmap_chunk_start(hdr, c); in nxt_unit_get_outgoing_buf()
3970 mmap_buf->buf.free = mmap_buf->buf.start; in nxt_unit_get_outgoing_buf()
3971 mmap_buf->buf.end = mmap_buf->buf.start + nchunks * PORT_MMAP_CHUNK_SIZE; in nxt_unit_get_outgoing_buf()
3972 mmap_buf->free_ptr = NULL; in nxt_unit_get_outgoing_buf()
3973 mmap_buf->ctx_impl = nxt_container_of(ctx, nxt_unit_ctx_impl_t, ctx); in nxt_unit_get_outgoing_buf()
5168 nxt_unit_mmap_buf_t *mmap_buf; in nxt_unit_ctx_free() local
5188 mmap_buf = ctx_impl->free_buf; in nxt_unit_ctx_free()
5189 nxt_unit_mmap_buf_unlink(mmap_buf); in nxt_unit_ctx_free()
5190 nxt_unit_free(&ctx_impl->ctx, mmap_buf); in nxt_unit_ctx_free()