Groonga 3.0.9 Source Code Document
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
groonga
vendor
nginx-1.4.2
src
core
ngx_buf.h
Go to the documentation of this file.
1
2
/*
3
* Copyright (C) Igor Sysoev
4
* Copyright (C) Nginx, Inc.
5
*/
6
7
8
#ifndef _NGX_BUF_H_INCLUDED_
9
#define _NGX_BUF_H_INCLUDED_
10
11
12
#include <
ngx_config.h
>
13
#include <
ngx_core.h
>
14
15
16
typedef
void
*
ngx_buf_tag_t
;
17
18
typedef
struct
ngx_buf_s
ngx_buf_t
;
19
20
struct
ngx_buf_s
{
21
u_char *
pos
;
22
u_char *
last
;
23
off_t
file_pos
;
24
off_t
file_last
;
25
26
u_char *
start
;
/* start of buffer */
27
u_char *
end
;
/* end of buffer */
28
ngx_buf_tag_t
tag
;
29
ngx_file_t
*
file
;
30
ngx_buf_t
*
shadow
;
31
32
33
/* the buf's content could be changed */
34
unsigned
temporary
:1;
35
36
/*
37
* the buf's content is in a memory cache or in a read only memory
38
* and must not be changed
39
*/
40
unsigned
memory
:1;
41
42
/* the buf's content is mmap()ed and must not be changed */
43
unsigned
mmap
:1;
44
45
unsigned
recycled
:1;
46
unsigned
in_file
:1;
47
unsigned
flush
:1;
48
unsigned
sync
:1;
49
unsigned
last_buf
:1;
50
unsigned
last_in_chain
:1;
51
52
unsigned
last_shadow
:1;
53
unsigned
temp_file
:1;
54
55
/* STUB */
int
num
;
56
};
57
58
59
struct
ngx_chain_s
{
60
ngx_buf_t
*
buf
;
61
ngx_chain_t
*
next
;
62
};
63
64
65
typedef
struct
{
66
ngx_int_t
num
;
67
size_t
size
;
68
}
ngx_bufs_t
;
69
70
71
typedef
struct
ngx_output_chain_ctx_s
ngx_output_chain_ctx_t
;
72
73
typedef
ngx_int_t
(*
ngx_output_chain_filter_pt
)(
void
*ctx,
ngx_chain_t
*
in
);
74
75
#if (NGX_HAVE_FILE_AIO)
76
typedef
void (*ngx_output_chain_aio_pt)(
ngx_output_chain_ctx_t
*ctx,
77
ngx_file_t
*file);
78
#endif
79
80
struct
ngx_output_chain_ctx_s
{
81
ngx_buf_t
*
buf
;
82
ngx_chain_t
*
in
;
83
ngx_chain_t
*
free
;
84
ngx_chain_t
*
busy
;
85
86
unsigned
sendfile
:1;
87
unsigned
directio
:1;
88
#if (NGX_HAVE_ALIGNED_DIRECTIO)
89
unsigned
unaligned:1;
90
#endif
91
unsigned
need_in_memory
:1;
92
unsigned
need_in_temp
:1;
93
#if (NGX_HAVE_FILE_AIO)
94
unsigned
aio:1;
95
96
ngx_output_chain_aio_pt aio_handler;
97
#endif
98
99
off_t
alignment
;
100
101
ngx_pool_t
*
pool
;
102
ngx_int_t
allocated
;
103
ngx_bufs_t
bufs
;
104
ngx_buf_tag_t
tag
;
105
106
ngx_output_chain_filter_pt
output_filter
;
107
void
*
filter_ctx
;
108
};
109
110
111
typedef
struct
{
112
ngx_chain_t
*
out
;
113
ngx_chain_t
**
last
;
114
ngx_connection_t
*
connection
;
115
ngx_pool_t
*
pool
;
116
off_t
limit
;
117
}
ngx_chain_writer_ctx_t
;
118
119
120
#define NGX_CHAIN_ERROR (ngx_chain_t *) NGX_ERROR
121
122
123
#define ngx_buf_in_memory(b) (b->temporary || b->memory || b->mmap)
124
#define ngx_buf_in_memory_only(b) (ngx_buf_in_memory(b) && !b->in_file)
125
126
#define ngx_buf_special(b) \
127
((b->flush || b->last_buf || b->sync) \
128
&& !ngx_buf_in_memory(b) && !b->in_file)
129
130
#define ngx_buf_sync_only(b) \
131
(b->sync \
132
&& !ngx_buf_in_memory(b) && !b->in_file && !b->flush && !b->last_buf)
133
134
#define ngx_buf_size(b) \
135
(ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos): \
136
(b->file_last - b->file_pos))
137
138
ngx_buf_t
*
ngx_create_temp_buf
(
ngx_pool_t
*pool,
size_t
size);
139
ngx_chain_t
*
ngx_create_chain_of_bufs
(
ngx_pool_t
*pool,
ngx_bufs_t
*bufs);
140
141
142
#define ngx_alloc_buf(pool) ngx_palloc(pool, sizeof(ngx_buf_t))
143
#define ngx_calloc_buf(pool) ngx_pcalloc(pool, sizeof(ngx_buf_t))
144
145
ngx_chain_t
*
ngx_alloc_chain_link
(
ngx_pool_t
*pool);
146
#define ngx_free_chain(pool, cl) \
147
cl->next = pool->chain; \
148
pool->chain = cl
149
150
151
152
ngx_int_t
ngx_output_chain
(
ngx_output_chain_ctx_t
*ctx,
ngx_chain_t
*in);
153
ngx_int_t
ngx_chain_writer
(
void
*ctx,
ngx_chain_t
*in);
154
155
ngx_int_t
ngx_chain_add_copy
(
ngx_pool_t
*pool,
ngx_chain_t
**chain,
156
ngx_chain_t
*in);
157
ngx_chain_t
*
ngx_chain_get_free_buf
(
ngx_pool_t
*p,
ngx_chain_t
**free);
158
void
ngx_chain_update_chains
(
ngx_pool_t
*p,
ngx_chain_t
**free,
159
ngx_chain_t
**busy,
ngx_chain_t
**out,
ngx_buf_tag_t
tag);
160
161
162
#endif
/* _NGX_BUF_H_INCLUDED_ */
Generated on Sun Nov 10 2013 09:49:06 for Groonga 3.0.9 Source Code Document by
1.8.1.2